完成作业
This commit is contained in:
10
260423+2509165020/题目6.py
Normal file
10
260423+2509165020/题目6.py
Normal file
@@ -0,0 +1,10 @@
|
||||
sent1 = "猫 抓 老鼠"
|
||||
sent2 = "老鼠 抓 猫"
|
||||
vocab_sent = sorted(set(sent1.split() + sent2.split()))
|
||||
vec1 = [sent1.split().count(word) for word in vocab_sent]
|
||||
vec2 = [sent2.split().count(word) for word in vocab_sent]
|
||||
print("句子1向量:", vec1)
|
||||
print("句子2向量:", vec2)
|
||||
print("向量是否相同:", vec1 == vec2)
|
||||
large_vocab = [f"word_{i}" for i in range(10000)]
|
||||
print(f"大词表维度:{len(large_vocab)}")
|
||||
Reference in New Issue
Block a user