@Deprecated public class InMemoryLookupCache extends Object implements VocabCache<VocabWord>, Serializable
| Modifier and Type | Field and Description |
|---|---|
org.nd4j.linalg.primitives.Counter<String> |
docFrequencies
Deprecated.
|
Map<String,VocabWord> |
tokens
Deprecated.
|
Map<String,VocabWord> |
vocabs
Deprecated.
|
org.nd4j.linalg.primitives.Counter<String> |
wordFrequencies
Deprecated.
|
| Constructor and Description |
|---|
InMemoryLookupCache()
Deprecated.
|
InMemoryLookupCache(boolean addUnk)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addToken(VocabWord word)
Deprecated.
Adds a token
to the cache
|
void |
addWordToIndex(int index,
long elementId)
Deprecated.
|
void |
addWordToIndex(int index,
String word)
Deprecated.
|
boolean |
containsWord(String word)
Deprecated.
Returns true if the cache contains the given word
|
int |
docAppearedIn(String word)
Deprecated.
Count of documents a word appeared in
|
VocabWord |
elementAtIndex(int index)
Deprecated.
Returns SequenceElement at the given index or null
|
boolean |
equals(Object o)
Deprecated.
|
Map<String,VocabWord> |
getTokens()
Deprecated.
|
Map<String,VocabWord> |
getVocabs()
Deprecated.
|
org.nd4j.linalg.primitives.Counter<String> |
getWordFrequencies()
Deprecated.
|
int |
hashCode()
Deprecated.
|
boolean |
hasToken(String token)
Deprecated.
Returns whether the cache
contains this token or not
|
void |
importVocabulary(VocabCache<VocabWord> vocabCache)
Deprecated.
imports vocabulary
|
void |
incrementDocCount(String word,
long howMuch)
Deprecated.
Increment the document count
|
void |
incrementTotalDocCount()
Deprecated.
Increment the doc count
|
void |
incrementTotalDocCount(long by)
Deprecated.
Increment the doc count
|
void |
incrementWordCount(String word)
Deprecated.
Increment the count for the given word
|
void |
incrementWordCount(String word,
int increment)
Deprecated.
Increment the count for the given word by
the amount increment
|
int |
indexOf(String word)
Deprecated.
Returns the index of a given word
|
static InMemoryLookupCache |
load(InputStream from)
Deprecated.
Load a look up cache from an input stream
delimited by \n
|
void |
loadVocab()
Deprecated.
Load vocab
|
int |
numWords()
Deprecated.
Returns the number of words in the cache
|
void |
putVocabWord(String word)
Deprecated.
|
void |
removeElement(String label)
Deprecated.
Removes element with specified label from vocabulary
Please note: Huffman index should be updated after element removal
|
void |
removeElement(VocabWord element)
Deprecated.
Removes specified element from vocabulary
Please note: Huffman index should be updated after element removal
|
void |
saveVocab()
Deprecated.
Saves the vocab: this allow for reuse of word frequencies
|
void |
setCountForDoc(String word,
long count)
Deprecated.
Set the count for the number of documents the word appears in
|
void |
setTokens(Map<String,VocabWord> tokens)
Deprecated.
|
void |
setVocabs(Map<String,VocabWord> vocabs)
Deprecated.
|
void |
setWordFrequencies(org.nd4j.linalg.primitives.Counter<String> cnt)
Deprecated.
|
VocabWord |
tokenFor(long id)
Deprecated.
|
VocabWord |
tokenFor(String word)
Deprecated.
Returns the token (again not necessarily in the vocab)
for this word
|
Collection<VocabWord> |
tokens()
Deprecated.
All of the tokens in the cache, (not necessarily apart of the vocab)
|
String |
toString()
Deprecated.
|
long |
totalNumberOfDocs()
Deprecated.
Returns the total of number of documents encountered in the corpus
|
long |
totalWordOccurrences()
Deprecated.
The total number of word occurrences
|
void |
updateWordsOccurencies()
Deprecated.
Updates counters
|
boolean |
vocabExists()
Deprecated.
Vocab exists already
|
Collection<VocabWord> |
vocabWords()
Deprecated.
Returns all of the vocab word nodes
|
String |
wordAtIndex(int index)
Deprecated.
Returns the word contained at the given index or null
|
VocabWord |
wordFor(long id)
Deprecated.
|
VocabWord |
wordFor(String word)
Deprecated.
|
int |
wordFrequency(String word)
Deprecated.
Returns the number of times the word has occurred
|
Collection<String> |
words()
Deprecated.
Returns all of the words in the vocab
|
public org.nd4j.linalg.primitives.Counter<String> wordFrequencies
public org.nd4j.linalg.primitives.Counter<String> docFrequencies
public InMemoryLookupCache()
@Deprecated public InMemoryLookupCache(boolean addUnk)
public void setWordFrequencies(org.nd4j.linalg.primitives.Counter<String> cnt)
public org.nd4j.linalg.primitives.Counter<String> getWordFrequencies()
public Collection<String> words()
words in interface VocabCache<VocabWord>public void incrementWordCount(String word)
incrementWordCount in interface VocabCache<VocabWord>word - the word to increment the count forpublic void incrementWordCount(String word, int increment)
incrementWordCount in interface VocabCache<VocabWord>word - the word to increment the count forincrement - the amount to increment bypublic int wordFrequency(String word)
wordFrequency in interface VocabCache<VocabWord>word - the word to retrieve the occurrence frequency forpublic boolean containsWord(String word)
containsWord in interface VocabCache<VocabWord>word - the word to check forpublic String wordAtIndex(int index)
wordAtIndex in interface VocabCache<VocabWord>index - the index of the word to getpublic VocabWord elementAtIndex(int index)
VocabCacheelementAtIndex in interface VocabCache<VocabWord>public int indexOf(String word)
indexOf in interface VocabCache<VocabWord>word - the index of a given wordpublic Collection<VocabWord> vocabWords()
vocabWords in interface VocabCache<VocabWord>public long totalWordOccurrences()
totalWordOccurrences in interface VocabCache<VocabWord>public VocabWord wordFor(String word)
wordFor in interface VocabCache<VocabWord>word - public VocabWord wordFor(long id)
wordFor in interface VocabCache<VocabWord>public void addWordToIndex(int index,
String word)
addWordToIndex in interface VocabCache<VocabWord>index - word - public void addWordToIndex(int index,
long elementId)
addWordToIndex in interface VocabCache<VocabWord>@Deprecated public void putVocabWord(String word)
VocabCacheputVocabWord in interface VocabCache<VocabWord>word - public int numWords()
numWords in interface VocabCache<VocabWord>public int docAppearedIn(String word)
VocabCachedocAppearedIn in interface VocabCache<VocabWord>word - the number of documents the word appeared inpublic void incrementDocCount(String word, long howMuch)
VocabCacheincrementDocCount in interface VocabCache<VocabWord>word - the word to increment bypublic void setCountForDoc(String word, long count)
VocabCachesetCountForDoc in interface VocabCache<VocabWord>word - the word to set the count forcount - the count of the wordpublic long totalNumberOfDocs()
VocabCachetotalNumberOfDocs in interface VocabCache<VocabWord>public void incrementTotalDocCount()
VocabCacheincrementTotalDocCount in interface VocabCache<VocabWord>public void incrementTotalDocCount(long by)
VocabCacheincrementTotalDocCount in interface VocabCache<VocabWord>by - the number to increment bypublic Collection<VocabWord> tokens()
VocabCachetokens in interface VocabCache<VocabWord>public void addToken(VocabWord word)
VocabCacheaddToken in interface VocabCache<VocabWord>word - the word to addpublic VocabWord tokenFor(String word)
VocabCachetokenFor in interface VocabCache<VocabWord>word - the word to get the token forpublic VocabWord tokenFor(long id)
tokenFor in interface VocabCache<VocabWord>public boolean hasToken(String token)
VocabCachehasToken in interface VocabCache<VocabWord>token - the token to tespublic void importVocabulary(VocabCache<VocabWord> vocabCache)
VocabCacheimportVocabulary in interface VocabCache<VocabWord>public void updateWordsOccurencies()
VocabCacheupdateWordsOccurencies in interface VocabCache<VocabWord>public void removeElement(String label)
VocabCacheremoveElement in interface VocabCache<VocabWord>label - label of the element to be removedpublic void removeElement(VocabWord element)
VocabCacheremoveElement in interface VocabCache<VocabWord>element - SequenceElement to be removedpublic void saveVocab()
VocabCachesaveVocab in interface VocabCache<VocabWord>public boolean vocabExists()
VocabCachevocabExists in interface VocabCache<VocabWord>public static InMemoryLookupCache load(InputStream from)
from - the input stream to read frompublic void loadVocab()
VocabCacheloadVocab in interface VocabCache<VocabWord>Copyright © 2017. All rights reserved.