Skip to content

Commit

Permalink
fix setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kahne committed Mar 22, 2020
1 parent c61443e commit 517270e
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 9 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ build
var
*.so
*.egg-info
__pycache__
__pycache__
dist
*.sh
CMakeLists.txt
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include VERSION
include LICENSE
recursive-include src *.cpp *.hpp
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1
0.1.3
22 changes: 16 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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++',
),
]
Expand Down Expand Up @@ -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',
Expand All @@ -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,
)
1 change: 1 addition & 0 deletions src/fastwer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string>
#include <sstream>
#include <cmath>
#include <cassert>

#define WHITESPACE ' '

Expand Down

0 comments on commit 517270e

Please sign in to comment.