Spacy - 引理数

Spacy - number of lemma

在使用向量作为递归神经网络的输入后,我使用 spacy 将句子中的每个单词替换为 number/code。

import spacy
 str="basing based base"
 sp = spacy.load('en_core_web_sm')
 sentence=sp(str)
 for w in sentence:
    print(w.text,w.lemma)

在keras神经网络的第一层,嵌入层,我必须知道查找中的最大单词数table,有人知道这个数字吗? 谢谢

词条索引实际上是散列,因此没有从0到词条数的连续索引行。即使 sp.vocab.strings["randomnonwordstring#"] 也给你一个整数。

对于条目 "base",ID 是 4715552063986449646 in sp.vocab(请注意它是形式和词条的共享词汇)。你永远不会在内存中容纳如此多的嵌入。

正确的解决方案是创建字典,根据训练数据中的内容将单词转换为索引。