Class InMemoryLookupCache
- java.lang.Object
-
- org.deeplearning4j.models.word2vec.wordstore.inmemory.InMemoryLookupCache
-
- All Implemented Interfaces:
Serializable
,VocabCache<VocabWord>
@Deprecated public class InMemoryLookupCache extends Object implements VocabCache<VocabWord>, Serializable
Deprecated.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description InMemoryLookupCache()
Deprecated.InMemoryLookupCache(boolean addUnk)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
addToken(VocabWord word)
Deprecated.Adds a token to the cachevoid
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 wordint
docAppearedIn(String word)
Deprecated.Count of documents a word appeared inVocabWord
elementAtIndex(int index)
Deprecated.Returns SequenceElement at the given index or nullboolean
equals(Object o)
Deprecated.Map<String,VocabWord>
getTokens()
Deprecated.Map<String,VocabWord>
getVocabs()
Deprecated.org.nd4j.common.primitives.Counter<String>
getWordFrequencies()
Deprecated.int
hashCode()
Deprecated.boolean
hasToken(String token)
Deprecated.Returns whether the cache contains this token or notvoid
importVocabulary(VocabCache<VocabWord> vocabCache)
Deprecated.imports vocabularyvoid
incrementDocCount(String word, long howMuch)
Deprecated.Increment the document countvoid
incrementTotalDocCount()
Deprecated.Increment the doc countvoid
incrementTotalDocCount(long by)
Deprecated.Increment the doc countvoid
incrementWordCount(String word)
Deprecated.Increment the count for the given wordvoid
incrementWordCount(String word, int increment)
Deprecated.Increment the count for the given word by the amount incrementint
indexOf(String word)
Deprecated.Returns the index of a given wordstatic InMemoryLookupCache
load(InputStream from)
Deprecated.Load a look up cache from an input stream delimited by \nvoid
loadVocab()
Deprecated.Load vocabint
numWords()
Deprecated.Returns the number of words in the cachevoid
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 removalvoid
removeElement(VocabWord element)
Deprecated.Removes specified element from vocabulary Please note: Huffman index should be updated after element removalvoid
saveVocab()
Deprecated.Saves the vocab: this allow for reuse of word frequenciesvoid
setCountForDoc(String word, long count)
Deprecated.Set the count for the number of documents the word appears invoid
setTokens(Map<String,VocabWord> tokens)
Deprecated.void
setVocabs(Map<String,VocabWord> vocabs)
Deprecated.void
setWordFrequencies(org.nd4j.common.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 wordCollection<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 corpuslong
totalWordOccurrences()
Deprecated.The total number of word occurrencesvoid
updateWordsOccurrences()
Deprecated.Updates countersboolean
vocabExists()
Deprecated.Vocab exists alreadyCollection<VocabWord>
vocabWords()
Deprecated.Returns all of the vocab word nodesString
wordAtIndex(int index)
Deprecated.Returns the word contained at the given index or nullVocabWord
wordFor(long id)
Deprecated.VocabWord
wordFor(String word)
Deprecated.int
wordFrequency(String word)
Deprecated.Returns the number of times the word has occurredCollection<String>
words()
Deprecated.Returns all of the words in the vocab
-
-
-
Constructor Detail
-
InMemoryLookupCache
public InMemoryLookupCache()
Deprecated.
-
InMemoryLookupCache
@Deprecated public InMemoryLookupCache(boolean addUnk)
Deprecated.
-
-
Method Detail
-
setWordFrequencies
public void setWordFrequencies(org.nd4j.common.primitives.Counter<String> cnt)
Deprecated.
-
getWordFrequencies
public org.nd4j.common.primitives.Counter<String> getWordFrequencies()
Deprecated.
-
words
public Collection<String> words()
Deprecated.Returns all of the words in the vocab- Specified by:
words
in interfaceVocabCache<VocabWord>
-
incrementWordCount
public void incrementWordCount(String word)
Deprecated.Increment the count for the given word- Specified by:
incrementWordCount
in interfaceVocabCache<VocabWord>
- Parameters:
word
- the word to increment the count for
-
incrementWordCount
public void incrementWordCount(String word, int increment)
Deprecated.Increment the count for the given word by the amount increment- Specified by:
incrementWordCount
in interfaceVocabCache<VocabWord>
- Parameters:
word
- the word to increment the count forincrement
- the amount to increment by
-
wordFrequency
public int wordFrequency(String word)
Deprecated.Returns the number of times the word has occurred- Specified by:
wordFrequency
in interfaceVocabCache<VocabWord>
- Parameters:
word
- the word to retrieve the occurrence frequency for- Returns:
- 0 if hasn't occurred or the number of times the word occurs
-
containsWord
public boolean containsWord(String word)
Deprecated.Returns true if the cache contains the given word- Specified by:
containsWord
in interfaceVocabCache<VocabWord>
- Parameters:
word
- the word to check for- Returns:
-
wordAtIndex
public String wordAtIndex(int index)
Deprecated.Returns the word contained at the given index or null- Specified by:
wordAtIndex
in interfaceVocabCache<VocabWord>
- Parameters:
index
- the index of the word to get- Returns:
- the word at the given index
-
elementAtIndex
public VocabWord elementAtIndex(int index)
Deprecated.Description copied from interface:VocabCache
Returns SequenceElement at the given index or null- Specified by:
elementAtIndex
in interfaceVocabCache<VocabWord>
- Returns:
-
indexOf
public int indexOf(String word)
Deprecated.Returns the index of a given word- Specified by:
indexOf
in interfaceVocabCache<VocabWord>
- Parameters:
word
- the index of a given word- Returns:
- the index of a given word or -1 if not found
-
vocabWords
public Collection<VocabWord> vocabWords()
Deprecated.Returns all of the vocab word nodes- Specified by:
vocabWords
in interfaceVocabCache<VocabWord>
- Returns:
-
totalWordOccurrences
public long totalWordOccurrences()
Deprecated.The total number of word occurrences- Specified by:
totalWordOccurrences
in interfaceVocabCache<VocabWord>
- Returns:
- the total number of word occurrences
-
wordFor
public VocabWord wordFor(String word)
Deprecated.- Specified by:
wordFor
in interfaceVocabCache<VocabWord>
- Parameters:
word
-- Returns:
-
wordFor
public VocabWord wordFor(long id)
Deprecated.- Specified by:
wordFor
in interfaceVocabCache<VocabWord>
-
addWordToIndex
public void addWordToIndex(int index, String word)
Deprecated.- Specified by:
addWordToIndex
in interfaceVocabCache<VocabWord>
- Parameters:
index
-word
-
-
addWordToIndex
public void addWordToIndex(int index, long elementId)
Deprecated.- Specified by:
addWordToIndex
in interfaceVocabCache<VocabWord>
-
putVocabWord
@Deprecated public void putVocabWord(String word)
Deprecated.Description copied from interface:VocabCache
Inserts the word as a vocab word (it gets the vocab word from the internal token store). Note that the index must be set on the token.- Specified by:
putVocabWord
in interfaceVocabCache<VocabWord>
- Parameters:
word
-
-
numWords
public int numWords()
Deprecated.Returns the number of words in the cache- Specified by:
numWords
in interfaceVocabCache<VocabWord>
- Returns:
- the number of words in the cache
-
docAppearedIn
public int docAppearedIn(String word)
Deprecated.Description copied from interface:VocabCache
Count of documents a word appeared in- Specified by:
docAppearedIn
in interfaceVocabCache<VocabWord>
- Parameters:
word
- the number of documents the word appeared in- Returns:
-
incrementDocCount
public void incrementDocCount(String word, long howMuch)
Deprecated.Description copied from interface:VocabCache
Increment the document count- Specified by:
incrementDocCount
in interfaceVocabCache<VocabWord>
- Parameters:
word
- the word to increment by
-
setCountForDoc
public void setCountForDoc(String word, long count)
Deprecated.Description copied from interface:VocabCache
Set the count for the number of documents the word appears in- Specified by:
setCountForDoc
in interfaceVocabCache<VocabWord>
- Parameters:
word
- the word to set the count forcount
- the count of the word
-
totalNumberOfDocs
public long totalNumberOfDocs()
Deprecated.Description copied from interface:VocabCache
Returns the total of number of documents encountered in the corpus- Specified by:
totalNumberOfDocs
in interfaceVocabCache<VocabWord>
- Returns:
- the total number of docs in the corpus
-
incrementTotalDocCount
public void incrementTotalDocCount()
Deprecated.Description copied from interface:VocabCache
Increment the doc count- Specified by:
incrementTotalDocCount
in interfaceVocabCache<VocabWord>
-
incrementTotalDocCount
public void incrementTotalDocCount(long by)
Deprecated.Description copied from interface:VocabCache
Increment the doc count- Specified by:
incrementTotalDocCount
in interfaceVocabCache<VocabWord>
- Parameters:
by
- the number to increment by
-
tokens
public Collection<VocabWord> tokens()
Deprecated.Description copied from interface:VocabCache
All of the tokens in the cache, (not necessarily apart of the vocab)- Specified by:
tokens
in interfaceVocabCache<VocabWord>
- Returns:
- the tokens for this cache
-
addToken
public boolean addToken(VocabWord word)
Deprecated.Description copied from interface:VocabCache
Adds a token to the cache- Specified by:
addToken
in interfaceVocabCache<VocabWord>
- Parameters:
word
- the word to add- Returns:
- true if token was added, false if updated
-
tokenFor
public VocabWord tokenFor(String word)
Deprecated.Description copied from interface:VocabCache
Returns the token (again not necessarily in the vocab) for this word- Specified by:
tokenFor
in interfaceVocabCache<VocabWord>
- Parameters:
word
- the word to get the token for- Returns:
- the vocab word for this token
-
tokenFor
public VocabWord tokenFor(long id)
Deprecated.- Specified by:
tokenFor
in interfaceVocabCache<VocabWord>
-
hasToken
public boolean hasToken(String token)
Deprecated.Description copied from interface:VocabCache
Returns whether the cache contains this token or not- Specified by:
hasToken
in interfaceVocabCache<VocabWord>
- Parameters:
token
- the token to tes- Returns:
- whether the token exists in the cache or not
-
importVocabulary
public void importVocabulary(VocabCache<VocabWord> vocabCache)
Deprecated.Description copied from interface:VocabCache
imports vocabulary- Specified by:
importVocabulary
in interfaceVocabCache<VocabWord>
-
updateWordsOccurrences
public void updateWordsOccurrences()
Deprecated.Description copied from interface:VocabCache
Updates counters- Specified by:
updateWordsOccurrences
in interfaceVocabCache<VocabWord>
-
removeElement
public void removeElement(String label)
Deprecated.Description copied from interface:VocabCache
Removes element with specified label from vocabulary Please note: Huffman index should be updated after element removal- Specified by:
removeElement
in interfaceVocabCache<VocabWord>
- Parameters:
label
- label of the element to be removed
-
removeElement
public void removeElement(VocabWord element)
Deprecated.Description copied from interface:VocabCache
Removes specified element from vocabulary Please note: Huffman index should be updated after element removal- Specified by:
removeElement
in interfaceVocabCache<VocabWord>
- Parameters:
element
- SequenceElement to be removed
-
saveVocab
public void saveVocab()
Deprecated.Description copied from interface:VocabCache
Saves the vocab: this allow for reuse of word frequencies- Specified by:
saveVocab
in interfaceVocabCache<VocabWord>
-
vocabExists
public boolean vocabExists()
Deprecated.Description copied from interface:VocabCache
Vocab exists already- Specified by:
vocabExists
in interfaceVocabCache<VocabWord>
- Returns:
-
load
public static InMemoryLookupCache load(InputStream from)
Deprecated.Load a look up cache from an input stream delimited by \n- Parameters:
from
- the input stream to read from- Returns:
- the in memory lookup cache
-
loadVocab
public void loadVocab()
Deprecated.Description copied from interface:VocabCache
Load vocab- Specified by:
loadVocab
in interfaceVocabCache<VocabWord>
-
-