def mmap_extract(text):
"""
Function-wrapper for metamap binary. Extracts concepts
found in text.
!!!! REMEMBER TO START THE METAMAP TAGGER AND
WordSense DISAMBIGUATION SERVER !!!!
Input:
- text: str,
a piece of text or sentence
Output:
- concepts: list,
list of metamap concepts extracted
"""
# Tokenize into sentences
sents = sent_tokenize(text)
mm = MetaMap.get_instance(settings['load']['path']['metamap'])
concepts, errors = mm.extract_concepts(sents, range(len(sents)),
word_sense_disambiguation=True)
if errors:
print 'Errors with extracting concepts!'
print errors
return concepts
评论列表
文章目录