lexnlp.extract.en.entities.nltk_re
: Extracting companies¶
The lexnlp.extract.en.entities.nltk_re
module contains methods that allow for the extraction
of company names from text. Example statements that are covered by default in this module include:
- Deutsche Bank Securities Inc.
- ACME, INC.
- Wells Fargo Bank Minnesota, National Association
- Lexpredict LLC
The full list of current unit test cases can be found here: https://github.com/LexPredict/lexpredict-lexnlp/blob/master/lexnlp/extract/en/entities/tests/test_get_companies.py
Extracting conditions¶
-
lexnlp.extract.en.entities.nltk_re.
get_companies
(text: str, use_article: bool = False, use_sentence_splitter: bool = True) → Generator[[lexnlp.extract.common.annotations.company_annotation.CompanyAnnotation, None], None]¶ Find company names in text, optionally using the stricter article/prefix expression.
Example
>>> import lexnlp.extract.en.entities.nltk_re
>>> text = "This is Deutsche Bank Securities Inc."
>>> print(list(lexnlp.extract.en.entities.nltk_re.get_entities.nltk_re.get_companies(text)))
[('This is Deutsche Bank Securities', 'Inc', 'Bank')]
>>> text = "This is Lexpredict LLC"
>>> print(list(lexnlp.extract.en.entities.nltk_re.get_entities.nltk_re(text)))
[('This is Lexpredict', 'LLC', None)]