Library to calculate hLEPOR score (harmonic mean of enhanced Length Penalty, Precision, n-gram Position difference Penalty and Recall) has been created as port from Perl on materials of the following atricle by Aaron Li-Feng Han, Derek F. Wong, Lidia S. Chao, Liangye He Yi Lu, Junwen Xing, and Xiaodong Zeng. 2013. "Language-independent Model for Machine Translation Evaluation with Reinforced Factors". In Proceedings of the XIV Machine Translation Summit.
All hLepor score calculation functions take mandatory and optional parameters for input; mandatory parameters are: reference (ideal translation), hypothesis - new translation which has to be compared with reference.
Optional parameters are:
-
preprocessis a function to preprocess strings, default isstr.lower(). -
separate_punctuationallows different tokenization options: by default standardword_tokenize()function fromnltk.tokenizeis used, for this option you can specify the language (default is English), ifseparate_punctuation = False, sentence is tikenized by spaces.
Other optional parameters control hLepor algorithm:
alphaandbeta-- recall and precision weights, respectively, to calculate weighted Harmonic mean of precision and recall;n-- number of words in vicinity of current word in N-gram word alignment algorithm;weight_elp, weight_pos, weight_pr-- weigths for enhanced length penalty, N-gram Position Difference Penalty and weighted Harmonic mean of precision and recall for hLepor calculation.
Main functions:
- To calculate hLepor on one pair of sentences you need to pass these strings to single_hlepor_score function:
reference = 'Rising urban populations around the world have ushered in the concept of Smart Cities, in which digital innovations are used to address long-standing urban challenges.'
hypothesis = 'Rising urban populations around the world introduced the concept of Smart Cities, where long-standing urban challenges are addressed with digital innovations.'
hLepor_value = single_hlepor_score(reference, hypothesis)
round(hLepor_value, 4)
The result is 0.7550.
- To calculate hLepor on a set of sentences they need to be passed to hLepor as a list of strings:
reference = ['Rising urban populations around the world have ushered in the concept of Smart Cities, in which digital innovations are used to address long-standing urban challenges.', 'The related construction boom has put increasing demands on builders to erect structures and systems beautifully and efficiently.']
hypothesis = ['Rising urban populations around the world introduced the concept of Smart Cities, where long-standing urban challenges are addressed with digital innovations.', 'The related construction boom has put increasing demands on teams to build structures and systems beautifully and efficiently.']
hLepor_value = hlepor_score(reference, hypothesis)
round(hLepor_value, 4)
This code will calculate hLepor on each pair of sentences and mean value will be calculated, the result should be 0.8395.
Metadata
Release files for hLepor 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hLepor-0.0.4.tar.gz | 10.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hLepor-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.9 kB
Release files / hLepor-0.0.4.tar.gz
| Download URL | hLepor-0.0.4.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b63f20c7618f915947a67eb95268da1de3cf88d4300b02be6f948d4efdb6d3de
|
|
BLAKE2b-256 checksum How to use checksums |
bbc886a57259311eb927564ebab39725c8b069a6ce6d05f4c84f61047582c800
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.3
|
Release files / hLepor-0.0.4-py3-none-any.whl
| Download URL | hLepor-0.0.4-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
820d50502ff56882186019f4b5b3577bb4043bb262a422612dda176d3c2c7a16
|
|
BLAKE2b-256 checksum How to use checksums |
f2b3439f1ce0a2e2ac8d17969bf76023125da9803d80a94b738a8d0e04874486
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.3
|