edu.stanford.nlp.tagger.maxent.HistoryTable Maven / Gradle / Ivy
Show all versions of stanford-corenlp Show documentation
/**
* Title: StanfordMaxEnt
* Description: A Maximum Entropy Toolkit
* Copyright: Copyright (c) Kristina Toutanova
* Company: Stanford University
*/
package edu.stanford.nlp.tagger.maxent;
import edu.stanford.nlp.util.Index;
import edu.stanford.nlp.util.HashIndex;
/**
* Notes: This maintains a two way lookup between a History and
* an Integer index.
*
* @author Kristina Toutanova
* @version 1.0
*/
public class HistoryTable {
// todo cdm: just remove this class and use the Index directly where uses of it appears?
private static final int capacity = 1000000;
private final Index idx;
public HistoryTable() {
idx = new HashIndex<>(capacity);
}
void release() {
idx.clear();
}
int add(History h) {
return idx.addToIndex(h);
}
History getHistory(int index) {
return idx.get(index);
}
int getIndex(History h) {
return idx.indexOf(h);
}
int size() {
return idx.size();
}
}