本文整理了Java中cc.mallet.types.Alphabet.lookupIndex()
方法的一些代码示例,展示了Alphabet.lookupIndex()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Alphabet.lookupIndex()
方法的具体详情如下:
包路径:cc.mallet.types.Alphabet
类名称:Alphabet
方法名:lookupIndex
[英]Return -1 if entry isn't present.
[中]如果条目不存在,则返回-1。
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public Alphabet (Object[] entries) {
this (entries.length);
for (Object entry : entries)
this.lookupIndex(entry);
}
代码示例来源:origin: cc.mallet/mallet
public Alphabet (Object[] entries) {
this (entries.length);
for (Object entry : entries)
this.lookupIndex(entry);
}
代码示例来源:origin: cc.mallet/mallet
public Transducer.TransitionIterator transitionIterator (Object o)
{
int inputIndex = inputAlphabet.lookupIndex (o, false);
if (inputIndex == -1)
throw new IllegalArgumentException ("Input not in dictionary.");
return transitionIterator (inputIndex);
}
代码示例来源:origin: cc.mallet/mallet
public double logProbability (Object key)
{
if (dictionary == null)
throw new IllegalStateException ("This Multinomial has no dictionary.");
return logProbability (dictionary.lookupIndex (key));
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public int location (Object entry)
{
if (dictionary == null)
throw new IllegalStateException ("This FeatureVector has no dictionary.");
int i = dictionary.lookupIndex (entry, false);
if (i < 0)
return -1;
else
return location (i);
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
/** Load an alphabet from a file, one item per line */
public static Alphabet loadFromFile(File alphabetFile) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(alphabetFile));
Alphabet alphabet = new Alphabet();
String item;
while ((item = reader.readLine()) != null) {
alphabet.lookupIndex(item);
}
reader.close();
return alphabet;
}
代码示例来源:origin: cc.mallet/mallet
public void testReadResolve () throws IOException, ClassNotFoundException
{
Alphabet dict = new Alphabet ();
dict.lookupIndex ("TEST1");
dict.lookupIndex ("TEST2");
dict.lookupIndex ("TEST3");
Alphabet dict2 = (Alphabet) TestSerializable.cloneViaSerialization (dict);
assertTrue (dict == dict2);
}
代码示例来源:origin: cc.mallet/mallet
/** Create a dummy alphabet with <code>n</code> dimensions */
public static Alphabet alphabetOfSize (int n) {
Alphabet alphabet = new Alphabet();
for (int i = 0; i < n; i++) {
alphabet.lookupIndex("d" + i);
}
return alphabet;
}
代码示例来源:origin: cc.mallet/mallet
public boolean contains (Object o)
{
int index = dictionary.lookupIndex (o, false);
if (index == -1)
return false;
return contains (index);
}
代码示例来源:origin: cc.mallet/mallet
private static Alphabet dictOfSize (int size)
{
Alphabet ret = new Alphabet ();
for (int i = 0; i < size; i++)
ret.lookupIndex ("feature"+i);
return ret;
}
代码示例来源:origin: cc.mallet/mallet
public double probability (Object key)
{
if (dictionary == null)
throw new IllegalStateException ("This Multinomial has no dictionary.");
return probability (dictionary.lookupIndex (key));
}
代码示例来源:origin: com.github.steveash.mallet/mallet
private static Alphabet dictOfSize (int n)
{
Alphabet dict = new Alphabet ();
for (int i = 0; i < n; i++) {
dict.lookupIndex ("feature"+i);
}
return dict;
}
代码示例来源:origin: com.github.steveash.mallet/mallet
private static Alphabet dictOfSize (int size)
{
Alphabet ret = new Alphabet ();
for (int i = 0; i < size; i++)
ret.lookupIndex ("feature"+i);
return ret;
}
代码示例来源:origin: com.github.steveash.mallet/mallet
private void expandDict (Alphabet fd, int size)
{
fd.startGrowth ();
for (int i = 0; i < size; i++)
fd.lookupIndex ("feature"+i, true);
}
代码示例来源:origin: com.github.steveash.mallet/mallet
private static Alphabet dictOfSize (int size)
{
Alphabet ret = new Alphabet ();
for (int i = 0; i < size; i++)
ret.lookupIndex ("feature"+i);
return ret;
}
代码示例来源:origin: cc.mallet/mallet
public void testSetRankOrder ()
{
Alphabet v = new Alphabet ();
RankedFeatureVector rfv =
new RankedFeatureVector (v, new int[] {v.lookupIndex ("a"), v.lookupIndex ("b"), v.lookupIndex ("c"), v.lookupIndex ("d") },
new double[] {3.0, 1.0, 2.0, 6.0});
System.out.println ("vector size ="+rfv.numLocations());
for (int i = 0; i < rfv.numLocations(); i++)
System.out.println ("Rank="+i+" value="+rfv.getValueAtRank(i));
}
代码示例来源:origin: cc.mallet/mallet
public Transducer.TransitionIterator transitionIterator (Sequence inputSequence,
int inputPosition)
{
int inputIndex = inputAlphabet.lookupIndex (inputSequence.get(inputPosition), false);
if (inputIndex == -1)
throw new IllegalArgumentException ("Input not in dictionary.");
return transitionIterator (inputIndex);
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public Record (Alphabet fieldAlph, Alphabet valueAlph, String[][] vals) {
this(fieldAlph, valueAlph);
for (int i = 0; i < vals.length; i++) {
AugmentableFeatureVector afv = new AugmentableFeatureVector(valueAlph, false);
for (int j = 1; j < vals[i].length; j++)
afv.add(valueAlph.lookupIndex(vals[i][j]), 1.0);
field2values.put(fieldAlph.lookupIndex(vals[i][0]), afv.toFeatureVector());
}
}
代码示例来源:origin: cc.mallet/mallet
public Alphabet getPrunedAlphabet(int minDocs, int maxDocs, int minCount, int maxCount) {
Alphabet inputAlphabet = instances.getDataAlphabet();
Alphabet outputAlphabet = new Alphabet();
for (int inputType = 0; inputType < numFeatures; inputType++) {
if (featureCounts[inputType] >= minCount && featureCounts[inputType] <= maxCount && documentFrequencies[inputType] >= minDocs && documentFrequencies[inputType] <= maxDocs) {
outputAlphabet.lookupIndex(inputAlphabet.lookupObject(inputType));
}
}
return outputAlphabet;
}
代码示例来源:origin: cc.mallet/mallet
public FeatureSequence toFeatureSequence (Alphabet dict) {
FeatureSequence fs = new FeatureSequence( dict, this.size() );
for (int i = 0; i < this.size(); i++)
fs.add (dict.lookupIndex( (this.get(i)).getText()));
return fs;
}
内容来源于网络,如有侵权,请联系作者删除!