本文整理汇总了Java中cc.mallet.util.PropertyList.numericIterator方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyList.numericIterator方法的具体用法?Java PropertyList.numericIterator怎么用?Java PropertyList.numericIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cc.mallet.util.PropertyList
的用法示例。
在下文中一共展示了PropertyList.numericIterator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AugmentableFeatureVector
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public AugmentableFeatureVector (Alphabet dict, PropertyList pl, boolean binary,
boolean growAlphabet) {
this (dict, binary);
if (pl == null)
return;
PropertyList.Iterator iter = pl.numericIterator();
while (iter.hasNext()) {
iter.nextProperty();
//System.out.println ("AugmentableVector ("+dict.size()+") adding "+iter.getKey()+" "+iter.getNumericValue());
int index = dict.lookupIndex (iter.getKey(), growAlphabet);
if (index >= 0)
add (index, iter.getNumericValue());
}
}
示例2: BigAugmentableFeatureVector
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public BigAugmentableFeatureVector (BigAlphabet dict, PropertyList pl, boolean binary,
boolean growAlphabet) {
this (dict, binary);
if (pl == null)
return;
PropertyList.Iterator iter = pl.numericIterator();
while (iter.hasNext()) {
iter.nextProperty();
//System.out.println ("AugmentableVector ("+dict.size()+") adding "+iter.getKey()+" "+iter.getNumericValue());
int index = dict.lookupIndex (iter.getKey(), growAlphabet);
if (index >= 0)
add (index, iter.getNumericValue());
}
}
示例3: SparseVector
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public SparseVector (Alphabet dict, PropertyList pl, boolean binary,
boolean growAlphabet)
{
if (pl == null) {
// xxx Fix SparseVector so that it can properly represent a vector that has all zeros.
// Does this work?
indices = new int[0];
values = null;
return;
}
PropertyList.Iterator iter;
if (binary == false) {
binary = true;
// If all the property list features are binary, make a binary SparseVector even if the constructor argument "binary" is false.
// This will significantly save space, as well as multiplication time later! -akm 12/2007
iter = pl.numericIterator();
while (iter.hasNext()) {
iter.nextProperty();
if (iter.getNumericValue() != 1.0) {
binary = false;
break;
}
}
}
AugmentableFeatureVector afv = new AugmentableFeatureVector (dict, binary);
//afv.print();
//System.out.println ("SparseVector binary="+binary);
//pl.print();
iter = pl.numericIterator();
while (iter.hasNext()) {
iter.nextProperty();
//System.out.println ("SparseVector adding "+iter.getKey()+" "+iter.getNumericValue());
int index = dict.lookupIndex(iter.getKey(), growAlphabet);
if (index >=0) {
afv.add (index, iter.getNumericValue());
}
//System.out.println ("SparseVector afv adding "+iter.getKey()+" afv.numLocations="+afv.numLocations());
}
//afv.print();
// xxx Not so efficient?
SparseVector sv = afv.toSparseVector();
//System.out.println ("SparseVector sv.numLocations="+sv.numLocations());
this.indices = sv.indices;
this.values = sv.values;
}
示例4: BigSparseVector
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public BigSparseVector (BigAlphabet dict, PropertyList pl, boolean binary,
boolean growAlphabet)
{
if (pl == null) {
// xxx Fix SparseVector so that it can properly represent a vector that has all zeros.
// Does this work?
indices = new int[0];
values = null;
return;
}
PropertyList.Iterator iter;
if (binary == false) {
binary = true;
// If all the property list features are binary, make a binary SparseVector even if the constructor argument "binary" is false.
// This will significantly save space, as well as multiplication time later! -akm 12/2007
iter = pl.numericIterator();
while (iter.hasNext()) {
iter.nextProperty();
if (iter.getNumericValue() != 1.0) {
binary = false;
break;
}
}
}
BigAugmentableFeatureVector afv = new BigAugmentableFeatureVector (dict, binary);
//afv.print();
//System.out.println ("SparseVector binary="+binary);
//pl.print();
iter = pl.numericIterator();
while (iter.hasNext()) {
iter.nextProperty();
//System.out.println ("SparseVector adding "+iter.getKey()+" "+iter.getNumericValue());
int index = dict.lookupIndex(iter.getKey(), growAlphabet);
if (index >=0) {
afv.add (index, iter.getNumericValue());
}
//System.out.println ("SparseVector afv adding "+iter.getKey()+" afv.numLocations="+afv.numLocations());
}
//afv.print();
// xxx Not so efficient?
BigSparseVector sv = afv.toSparseVector();
//System.out.println ("SparseVector sv.numLocations="+sv.numLocations());
this.indices = sv.indices;
this.values = sv.values;
}