2017-03-26 4 views
0

회사 이름에서 조직 이름을 추출해야합니다. 엔티티를 추출 할 때 ','또는 '\ n'또는 '다른 이유로 인해 가끔'으로 인해 조직 이름이 나뉩니다.spaCy가 ',' ' n'또는 '기타 이유'로 인해 여러 엔터티를 표시하는 경우 동일한 유형의 엔터티를 병합하는 방법

spacy_data = nlp(text) 
spacy_data.ents if ent.label_ in =='ORG' 

expected output: capital international partners vi 
actual output: capital 
        international partners vi 

두 개의 다른 조직으로 표시됩니다. 최종 결과물을 capital_international_partners_vi으로 만들어서 한 단어로 된 벡터를 만드는 데 사용할 수 있습니다.

답변

1

spacy가 명명 된 엔티티를 추출하고 데이터베이스에 삽입하기 전에 텍스트를 사용하여 데이터를 정규화했습니다.

from textacy.preprocess import normalize_whitespace, preprocess_text 

def text_cleaner(text) : 

    cleaned_text = preprocess_text(my_text, no_currency_symbols = True, no_numbers = True, 
        lowercase=True, no_accents=True, no_contractions=True, no_punct = True).replace('\n','') 

    return normalize_whitespace(cleaned_text)