10 lines
427 B
Python
10 lines
427 B
Python
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)}") |