Open sumitkumarjethani opened 2 years ago
Hi @sumitkumarjethani, thank you for this report. Let's get it fixed!
Could you please provide:
app.py
, or at least the body of the runTextRankEntities()
functionMany thanks! Paco
Yeah sure!
""" Returns text rank entites """
def getTextRankEntities(doc):
entities = []
for phrase in doc._.phrases:
phrase_dict = {}
phrase_dict['entitie'] = phrase.text
phrase_dict['score'] = phrase.rank
phrase_dict['n_gram'] = len(phrase.text.split())
phrase_dict['count'] = phrase.count
entities.append(phrase_dict)
return entities
""" Main function to run text rank entites """
def runTextRankEntities(content):
entities = []
nlp = spacy.load("models/ca_core_news_lg-3.2.0/ca_core_news_lg/ca_core_news_lg-3.2.0") --> here you have to put the catalan pipeline name
nlp.add_pipe("textrank")
logger.info("Extracting entities with textrank algorithm")
doc = nlp(content)
entities = getTextRankEntities(doc)
logger.info("Entities extracted")
return entities
pip install spacy
Any other requirements please let me know and I will try to respond as soon as possible.
Thank you very much
Hi,
I use this library together with spacy for the extraction of the most important words. However, when using the catalan model of spacy, the algorithm gives the following error:
`File "/code/app.py", line 20, in getNlpEntities
File "/code/nlp/textRankEntities.py", line 51, in runTextRankEntities
File "/usr/local/lib/python3.9/site-packages/spacy/language.py", line 1022, in call
File "/usr/local/lib/python3.9/site-packages/spacy/util.py", line 1617, in raise_error
File "/usr/local/lib/python3.9/site-packages/spacy/language.py", line 1017, in call
File "/usr/local/lib/python3.9/site-packages/pytextrank/base.py", line 253, in call
File "/usr/local/lib/python3.9/site-packages/pytextrank/base.py", line 363, in calc_textrank
File "/usr/local/lib/python3.9/site-packages/pytextrank/base.py", line 548, in _collect_phrases
File "/usr/local/lib/python3.9/site-packages/pytextrank/base.py", line 549, in
File "/usr/local/lib/python3.9/site-packages/pytextrank/base.py", line 592, in _calc_discounted_normalised_rank
ZeroDivisionError: division by zero`