GithubHelp home page GithubHelp logo

mbforbes / textmetrics Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 65.24 MB

Automatic text metrics (BLEU, ROUGE, METEOR, +++)

License: MIT License

Python 83.63% Perl 16.37%
text-metrics text metrics nlp bleu rouge meteor ngrams vocabulary vocab

textmetrics's Introduction

textmetrics

Automatic text metrics---BLEU, ROUGE, and METEOR, plus extras like vocab and ngrams.

Usage

# Compares each candidate (c) separately against all references (r).
python -m textmetrics.main c1.txt c2.txt --references r1.txt r2.txt r3.txt

Installation

Requires:

  • Perl (for BLEU)
  • Java 1.8 (for METEOR)
  • Python 3.6+
pip install textmetrics

Features

  • BLEU
  • ROUGE
  • METEOR

Notes

BLEU and METEOR use the refernce implementations (in Perl and Java, respectively). We originally used the reference Perl implementation for ROUGE as well, but it ran so slowly that we opted for a Python reimplementation instead. (ROUGE's original Perl implementation is also more difficult to setup, even with wrapper libraries.)

Worklist

  • pypi

  • API support (possible to have interface for passing strings?)

  • ROUGE crashes things if it decides there aren't sentences (e.g., run with README.md as input and reference)

  • Add back in orig ROUGE for completeness (place behind switch)

  • BLEU perl script fails if the filename ends in gz because it tries to un-gzip it, which happens eventually when creating a lot of files. we should wrap the filename creation so this doesn't happen

  • ngrams has divide by zero error. With two simple files (two lines each, same first line, differing second line) running with 2.txt --references 1.txt 1.txt triggered this divide by zero

  • Demo + guide for better README (should cover file + API usage)

  • Tests

  • Early check in each module for whether program runnable + nice error message (e.g., no java or bad version, no perl or bad version, etc.)

Note to self: I followed this guide for packaging to pypi, and future uploads will probably look like:

# (1) ensure tests pass

# (2) bump version in setup.py

# (3) commit + push to github

# (4) generate distribution
python setup.py sdist bdist_wheel

# (5) Upload
twine upload dist/*

textmetrics's People

Contributors

mbforbes avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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.