반응형
gensim의 자연어 처리 패키지 중 Phrases라는 함수가 있는데, 이는 개수 기반 구문을 감지하고 컨트롤할 수 있게 해 준다. (참조: https://radimrehurek.com/gensim/models/phrases.html)
The phrases function in the NLP packages is detecting phrases based on collocation counts and supporting the NLP easily. (reference: https://radimrehurek.com/gensim/models/phrases.html)
하지만 버젼이 업그레이드되면서 과거의 사용 방법과 비교하여 약간의 변동사항이 있다.
However, the usage of the function has been updated.
아래와 같이 sentences를 Phrases로 변환하여 얻은 데이터를 판다스 데이터프레임에 넣으려고 할 때에 두 가지 에러가 발견될 것이다.
If you type the old version style of that function usage, you would encounter 2 errors.
1. phrases.export_phrases error
2. decode error - no decode function
해결방법은 아래와 같다.
Check the below!
Before(?)
temp = pd.DataFrame([[k.decode('utf-8'), v] for k, v in phrases.export_phrases(sentences)],
columns=['phrase', 'score']).assign(length=n)
After(gensim version: 4.3.0)
temp = pd.DataFrame([[k, v] for k, v in phrases.export_phrases().items()],
columns=['phrase', 'score']).assign(length=n)
Yay~!
728x90
반응형