lexnlp.extract.en.definitions
: Extracting definition statements¶
The lexnlp.extract.en.definitions
module contains methods that allow for the extraction
of definitional statements from text. Example statements that are covered by default in this module are:
- X shall [not] include …
- X shall have the meaning …
- X is hereby changed to …
- X shall be interpreted …
- X shall for purposes …
- X shall be deemed to …
- X shall refer to …
- X shall mean …
- X is defined …
- The word “X” includes every description of …
- The term “X” means …
- Description of term (the “x”)
The full list of current unit test cases can be found here: https://github.com/LexPredict/lexpredict-lexnlp/tree/master/test_data/lexnlp/extract/en/tests/test_definitions
Extracting constraints¶
-
lexnlp.extract.en.definitions.
get_definitions
(text: str, return_sources=False, decode_unicode=True, return_coords=False, locator_type: lexnlp.extract.common.annotation_locator_type.AnnotationLocatorType = <AnnotationLocatorType.RegexpBased: 1>) → Generator¶ Find possible definitions in natural language in text. The text will be split to sentences first. :param return_coords: returns a (x, y) tuple in each record. x - definition’s text start, y - definition’s text end :param decode_unicode: :param return_sources: returns a tuple with the extracted term and the source sentence :param text: the input text :param locator_type: use default (Regexp-based) or ML-based locator :return: Generator[name] or Generator[name, text] or Generator[name, text, coords]
Example
>>> import lexnlp.extract.en.definitions
>>> text = 'and Acme, LLC ("Client")'
>>> print(list(lexnlp.extract.en.definitions.get_definitions(text)))
['Client']
>>> text = "“Advance” means a Revolving Credit Advance"
>>> print(list(lexnlp.extract.en.definitions.get_definitions(text)))
['Advance']