lexnlp.extract.de.percents
: Extracting percents¶
The lexnlp.extract.de.percents
module contains methods that allow for the extraction
of percents from text for “DE” locale. Sample percents that are covered by this module include:
- 15 Volumenprozent
- zwanzig Prozent
- zwanzig %
- 20%
The full list of current unit test cases can be found here: https://github.com/LexPredict/lexpredict-lexnlp/tree/master/lexnlp/extract/de/tests/test_percents
Extracting percents¶
-
lexnlp.extract.de.percents.
get_percent_list
(*args, **kwargs)¶
Example
>>> import lexnlp.extract.de.percents
>>> text = "zwanzig Prozent"
>>> print(lexnlp.extract.de.percents.get_percent_list(text))
[{'location_start': 0,
'location_end': 15,
'source_text': 'zwanzig Prozent',
'unit_name': 'prozent',
'amount': 20,
'real_amount': 20}]
-
lexnlp.extract.de.percents.
get_percents
(text: str, float_digits=4) → Generator¶ Get percent usages within text. :param text: :param return_sources: :param float_digits: :return:
Example
>>> import lexnlp.extract.de.percents
>>> print(list(lexnlp.extract.de.percents.get_percents("1%")))
[{'location_start': 0,
'location_end': 2,
'source_text': '1%',
'unit_name': '%',
'amount': 1.0,
'real_amount': 1.0}]