2017-12-12 11 views
0

다음과 같이 nltk lemmatizer를 사용하고 있습니다. 언어 화 문제 (nltk)

from nltk.stem import WordNetLemmatizer 
lemmatizer = WordNetLemmatizer() 
mystring = "the sand rock needed to be mixed and shaked well before using it for construction works" 
splits=mystring.split() 
mystring = " ".join(lemmatizer.lemmatize(w) for w in splits) 
print(mystring) 

은 내가 (아래에서 설명)받을 출력에 출력 그러나

sand rock need to be mix and shake well before use it for construction work 

것으로 기대하고 그것의 기본 양식을 변경하지 않은 등 needed, mixed, shaked, using 같은 단어처럼 보인다.

sand rock needed to be mixed and shaked well before using it for construction work 

이 문제를 해결할 방법이 있습니까?

답변

0

두 번째 마지막 줄을이 부분으로 바꿀 수 있습니다.

mystring = " ".join(lemmatizer.lemmatize(w,pos ='v') for w in splits) 

pos는 음성 태그의 일부입니다.

+0

질문에 대답 할 수 있지만 답변의 핵심 부분과 OP 코드의 문제점을 설명하는 것이 좋습니다. – pirho