Coder Social home page Coder Social logo

chaoannricardo / language-evaluation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bckim92/language-evaluation

0.0 1.0 0.0 34.7 MB

:clipboard: Collection of evaluation code for natural language generation.

License: Other

Python 31.24% Perl 68.76%

language-evaluation's Introduction

language-evaluation (Experimental)

Collection of evaluation code for natural language generation.

Note: API could change frequently without notice

Metrics

  • CocoEvaluator: coco-caption (BLEU1-4, METEOR, ROUGE, CIDEr, SPICE)
  • RougeEvaluator: sentence-level rouge (ROUGE-1, ROUGE-2, ROUGE-L with f-measure)
  • Rouge155Evaluator: summary-level rouge (ROUGE-1, ROUGE-2, ROUGE-L with f-measure)

Requirements

  • Java 1.8.0+ (used by coco-caption evaluator)
  • Python 3.6+
  • libxml-parser-perl (used by ROUGE.1.5.5.pl)

Installation and Usage

Install external dependencies (e.g. Java 1.8.0+, libxml-parser-perl):

# Oracle Java
sudo add-apt-repository ppa:webupd8team/java
sudo apt upadte
apt-get install oracle-java8-installer

# libxml-parser-perl
sudo apt install libxml-parser-perl

Then run:

pip install git+https://github.com/bckim92/language-evaluation.git
python -c "import language_evaluation; language_evaluation.download('coco')"

Python API (or see language_evaluation_test.py):

import language_evaluation
from pprint import PrettyPrinter
pprint = PrettyPrinter().pprint

predicts = ['i am a boy', 'she is a girl']
answers = ['am i a boy ?', 'is she a girl ?']

evaluator = language_evaluation.CocoEvaluator()
results = evaluator.run_evaluation(predicts, answers)
pprint(results)
# {'Bleu_1': 0.9999999997500004,
#  'Bleu_2': 0.5773502690332603,
#  'Bleu_3': 4.3679023223468616e-06,
#  'Bleu_4': 1.4287202142987477e-08,
#  'CIDEr': 3.333333333333333,
#  'METEOR': 0.43354749322305886,
#  'ROUGE_L': 0.75,
#  'SPICE': 0.6666666666666666}

evaluator = language_evaluation.RougeEvaluator(num_parallel_calls=5)
results = evaluator.run_evaluation(predicts, answers)
pprint(results)
# {'rouge1': 1.0,
#  'rouge2': 0.3333333333333333,
#  'rougeL': 0.75}

evaluator = language_evaluation.Rouge155Evaluator(num_parallel_calls=5)
results = evaluator.run_evaluation(predicts, answers)
pprint(results)
# {'rouge1': 1.0,
#  'rouge2': 0.3333333333333333,
#  'rougeL': 0.75}

Notes

  • TODOs
    • Support more metrics (e.g. embedding-based)
    • Support command-line interface
    • Support full functionality and configuration for rouge
    • Implement summary-level rouge scorer in pure python
    • Add tests & CI

Related Projects

License

See LICENSE.md.

language-evaluation's People

Contributors

bckim92 avatar j-min avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.