完成作业

This commit is contained in:
2509165020
2026-04-23 15:48:24 +08:00
parent 5fa066766f
commit 92aa5a4826
3 changed files with 228 additions and 0 deletions

View 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)}")