MCPcopy Create free account
hub / github.com/clab/dynet / from_corpus

Method from_corpus

examples/python-utils/util.py:9–14  ·  view source on GitHub ↗
(cls, corpus)

Source from the content-addressed store, hash-verified

7
8 @classmethod
9 def from_corpus(cls, corpus):
10 w2i = {}
11 for sent in corpus:
12 for word in sent:
13 w2i.setdefault(word, len(w2i))
14 return Vocab(w2i)
15
16 def size(self):
17 return len(self.w2i.keys())

Callers

nothing calls this directly

Calls 1

VocabClass · 0.70

Tested by

no test coverage detected