From ab56fbecc8a71c0bcbc281bb8c35a4df0b0b5311 Mon Sep 17 00:00:00 2001 From: Arthit Suriyawongkul Date: Thu, 27 May 2021 15:38:12 +0100 Subject: [PATCH 1/2] Use get_vector() instead of deprecated word_vec() --- pythainlp/word_vector/core.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pythainlp/word_vector/core.py b/pythainlp/word_vector/core.py index 14898c817..fc6f4eb83 100644 --- a/pythainlp/word_vector/core.py +++ b/pythainlp/word_vector/core.py @@ -50,7 +50,15 @@ def doesnt_match(words: List[str]) -> str: Pick the word "พริกไทย" (name of food) out of the list of meals ("อาหารเช้า", "อาหารเที่ยง", "อาหารเย็น"). - >>> from pythainlp.word_vector import doesnt_match + >>> from pythainlp. + + + + + + + + tor import doesnt_match >>> >>> words = ['อาหารเช้า','อาหารเที่ยง','อาหารเย็น','พริกไทย'] >>> doesnt_match(words) @@ -258,7 +266,7 @@ def sentence_vectorizer(text: str, use_mean: bool = True) -> ndarray: word = _TK_EOL if word in _MODEL.index_to_key: - vec += _MODEL.word_vec(word) + vec += _MODEL.get_vector(word) if use_mean: vec /= len_words From 521bc25f06e5cf7691f0eb098f4b6a4de989cc72 Mon Sep 17 00:00:00 2001 From: Arthit Suriyawongkul Date: Thu, 27 May 2021 15:50:06 +0100 Subject: [PATCH 2/2] Fix comment --- pythainlp/word_vector/core.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pythainlp/word_vector/core.py b/pythainlp/word_vector/core.py index fc6f4eb83..3333c6782 100644 --- a/pythainlp/word_vector/core.py +++ b/pythainlp/word_vector/core.py @@ -50,17 +50,9 @@ def doesnt_match(words: List[str]) -> str: Pick the word "พริกไทย" (name of food) out of the list of meals ("อาหารเช้า", "อาหารเที่ยง", "อาหารเย็น"). - >>> from pythainlp. - - - - - - - - tor import doesnt_match + >>> from pythainlp.word_vector import doesnt_match >>> - >>> words = ['อาหารเช้า','อาหารเที่ยง','อาหารเย็น','พริกไทย'] + >>> words = ['อาหารเช้า', 'อาหารเที่ยง', 'อาหารเย็น', 'พริกไทย'] >>> doesnt_match(words) พริกไทย @@ -196,7 +188,7 @@ def similarity(word1: str, word2: str) -> float: (train and electric train). >>> from pythainlp.word_vector import similarity - >>> similarity('รถไฟ','รถไฟฟ้า') + >>> similarity('รถไฟ', 'รถไฟฟ้า') 0.43387136 @@ -204,7 +196,7 @@ def similarity(word1: str, word2: str) -> float: (leopard and electric train). >>> from pythainlp.word_vector import similarity - >>> similarity('เสือดาว','รถไฟฟ้า') + >>> similarity('เสือดาว', 'รถไฟฟ้า') 0.04300258 """