lexpredict-lexnlp
lexpredict-lexnlp copied to clipboard
How to use the ML models
I can see that I can use the ML classifier to identify the definitions from the code. File - lexnlp.extract.en.definitions
def get_definitions(text: str,
return_sources=False,
decode_unicode=True,
return_coords=False,
locator_type: AnnotationLocatorType = AnnotationLocatorType.RegexpBased) -> 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]
"""
So I've tried giving the 'locator_type' as AnnotationLocatorType.MlWordVectorBased for the get_definitions() function, then I'm getting this error.
"parser_ml_classifier" object should be initialized (call load_compressed method)
I've gone through the definitions file and I can see this in line 43
parser_ml_classifier = LayeredDefinitionDetector()
I tried to run the load_compressed method inside the LayeredDefinitionDetector() but it is asking for a file_path and I don't understand which file path should be given. Am I missing something, could anyone guide me on how to use the ML models for definitions? Thanks!!