上传文件至 /
This commit is contained in:
10
260423-2509165027.py
Normal file
10
260423-2509165027.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from sklearn.feature_extraction.text import CountVectorizer
|
||||||
|
docs=["Python 是 编程 语言"
|
||||||
|
"Java 是 编程 语言"
|
||||||
|
"Python Python Python"]
|
||||||
|
vectorizer = CountVectorizer()
|
||||||
|
bow_matrix = vectorizer.fit_transform(docs)
|
||||||
|
|
||||||
|
print("词表:", vectorizer.get_feature_names_out())
|
||||||
|
print("BoW矩阵:")
|
||||||
|
print(bow_matrix.toarray())
|
||||||
Reference in New Issue
Block a user