An open API service indexing awesome lists of open source software.

https://github.com/tikquuss/nlp_tools

Natural language processing tools (tokenizer, ...) and evaluation metrics (BLUE, ...) for morphologically complex languages such as those of Africa.
https://github.com/tikquuss/nlp_tools

african-languages evaluation-metrics nlp tokenizer

Last synced: 7 months ago
JSON representation

Natural language processing tools (tokenizer, ...) and evaluation metrics (BLUE, ...) for morphologically complex languages such as those of Africa.

Awesome Lists containing this project

README

          

```bash
pip install -r requirements.txt
```

# BLEU evaluation
```bash
python bleu.py --ref my/ref.txt --hyp my/hyp.txt --max_order 4 --smooth False
```
```python
import os, subprocess

ref = "my/ref.txt"
hyp = "my/hyp.txt"

command = "multi-bleu.perl %s < %s"
if os.name == "nt" :
command = "perl %s" % command
p = subprocess.Popen(command % (ref, hyp), stdout=subprocess.PIPE, shell=True)
result = p.communicate()[0].decode("utf-8")
if result.startswith('BLEU'):
bleu = float(result[7:result.index(',')])
else:
print('Impossible to parse BLEU score! "%s"' % result)
bleu = -1
```