From 517270e66bb0dc92f91c5281b190bf7cb6d358af Mon Sep 17 00:00:00 2001 From: Changhan Wang Date: Sun, 22 Mar 2020 18:38:07 -0400 Subject: [PATCH] fix setup.py --- .gitignore | 5 ++++- MANIFEST.in | 3 +++ README.md | 31 ++++++++++++++++++++++++++++++- VERSION | 2 +- setup.py | 22 ++++++++++++++++------ src/fastwer.hpp | 1 + 6 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 MANIFEST.in diff --git a/.gitignore b/.gitignore index 51646f6..394ea3a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,7 @@ build var *.so *.egg-info -__pycache__ \ No newline at end of file +__pycache__ +dist +*.sh +CMakeLists.txt \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..b09172c --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +include VERSION +include LICENSE +recursive-include src *.cpp *.hpp diff --git a/README.md b/README.md index 17689d2..b42dc63 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,33 @@ -fastWER +FastWER ==== +A PyPI package for fast word/character error rate (WER/CER) calculation +* fast (cpp implementation) +* sentence-level and corpus-level WER/CER scores + + +# Installation +```bash +pip install fastwer +``` + +# Example +```python +import fastwer +hypo = ['This is an example .', 'This is another example .'] +ref = ['This is the example :)', 'That is the example .'] + +# Corpus-Level WER: 40.0 +fastwer.score(hypo, ref) +# Corpus-Level CER: 25.5814 +fastwer.score(hypo, ref, char_level=True) + +# Sentence-Level WER: 40.0 +fastwer.score_sent(hypo[0], ref[0]) +# Sentence-Level CER: 22.7273 +fastwer.score_sent(hypo[0], ref[0], char_level=True) +``` + + +# Contact Changhan Wang (wangchanghan@gmail.com) diff --git a/VERSION b/VERSION index ceab6e1..7693c96 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1 \ No newline at end of file +0.1.3 \ No newline at end of file diff --git a/setup.py b/setup.py index 7cddfe6..703467d 100644 --- a/setup.py +++ b/setup.py @@ -6,18 +6,25 @@ # import setuptools -from setuptools import setup, find_packages, Extension +from setuptools import setup, Extension from setuptools.command.build_ext import build_ext import sys -import pybind11 + +class PyBind11Helper(object): + def __init__(self, user: bool = False): + self.user = user + + def get_include(self): + import pybind11 + return pybind11.get_include(self.user) ext_modules = [ Extension( 'fastwer', ['src/fastwer.cpp', 'src/bindings.cpp'], - include_dirs=[pybind11.get_include(), pybind11.get_include(user=True)], + include_dirs=[PyBind11Helper().get_include(), PyBind11Helper(user=True).get_include()], language='c++', ), ] @@ -99,7 +106,9 @@ def build_extensions(self): setup( name='fastwer', version=version, - description='fastWER: a fast implementation of Word Error Rate', + author='Changhan Wang', + author_email='wangchanghan@gmail.com', + description='A PyPI package for fast word/character error rate (WER/CER) calculation', url='https://github.com/kahne/fastwer', classifiers=[ 'Intended Audience :: Science/Research', @@ -115,8 +124,9 @@ def build_extensions(self): setup_requires=['setuptools>=18.0'], install_requires=['pybind11'], ext_modules=ext_modules, - packages=find_packages(exclude=['tests']), - package_data={'fastwer': ['VERSION']}, + packages=['fastwer'], + package_dir={'fastwer': 'src'}, + # data_files=[('', ['VERSION', 'LICENSE'])], cmdclass={'build_ext': BuildExt}, zip_safe=False, ) diff --git a/src/fastwer.hpp b/src/fastwer.hpp index e2c7b55..147514f 100644 --- a/src/fastwer.hpp +++ b/src/fastwer.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #define WHITESPACE ' '