本文整理汇总了Java中cc.mallet.util.PropertyList.add方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyList.add方法的具体用法?Java PropertyList.add怎么用?Java PropertyList.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cc.mallet.util.PropertyList
的用法示例。
在下文中一共展示了PropertyList.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initStartEndFs
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
private static void initStartEndFs ()
{
for (int i = 0; i < maxWindowSize; i++) {
startfs[i] = PropertyList.add ("<START"+i+">", 1.0, null);
endfs[i] = PropertyList.add ("<END"+i+">", 1.0, null);
}
}
示例2: makeConjunctions
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
/** Recursively makes conjunctions by iterating through features at each offset
* @param iters iterate over the PropertyLists at each offset
* @param currIndex which offset we're currently on, e..g 1 in the list [0,1,2]
* @param conjunctions list of conjunctions
* @param j which offset list we're currently on, e.g. [0,1,2] in the list [[0,1],[0,1,2]]
* @param tsSize size of token sequence
* @param newfs new features
* @param tsi token sequence index
* @param oldfs old features
* @param iterIndices counter to keep track how far in each iterator in "iters"
* @return new features
*/
private PropertyList makeConjunctions (PropertyList.Iterator[] iters, int currIndex, int[][] conjunctions,
int j, int tsSize, PropertyList newfs, int tsi, PropertyList[] oldfs,
int[] iterIndices) {
if (iters.length == currIndex) { // base case: add feature for current conjunction of iters
// avoid redundant doubling of feature space; include only upper triangle
if (redundant (conjunctions, j, iterIndices)) {
return newfs;
}
String newFeature = "";
double newValue = 1.0;
for (int i=0; i < iters.length; i++) {
String s = iters[i].getKey();
if (featureRegex != null && !featureRegex.matcher(s).matches())
return newfs;
newFeature += (i==0 ? "" : "_&_") + s + (conjunctions[j][i]==0 ? "" : ("@" + conjunctions[j][i]));
newValue *= iters[i].getNumericValue();
}
//System.err.println ("Adding new feature " + newFeature);
newfs = PropertyList.add (newFeature, newValue, newfs);
}
else { // recursive step
while (iters[currIndex].hasNext()) {
iters[currIndex].next();
iterIndices[currIndex]++;
newfs = makeConjunctions (iters, currIndex+1, conjunctions, j, tsSize, newfs, tsi, oldfs, iterIndices);
}
// reset iterator at currIndex
iters[currIndex] = getOffsetIter (conjunctions, j, currIndex, tsSize, tsi, oldfs);
iterIndices[currIndex] = -1;
}
return newfs;
}
示例3: pipe
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public Instance pipe (Instance carrier)
{
TokenSequence ts = (TokenSequence) carrier.getData();
int tsSize = ts.size();
PropertyList[] newFeatures = new PropertyList[tsSize];
for (int i = 0; i < tsSize; i++) {
Token t = ts.get (i);
PropertyList pl = t.getFeatures();
newFeatures[i] = pl;
for (int position = i + leftBoundary; position < i + rightBoundary; position++) {
if (position == i && !includeCurrentToken)
continue;
PropertyList pl2;
if (position < 0)
pl2 = startfs[-position];
else if (position >= tsSize)
pl2 = endfs[position-tsSize];
else
pl2 = ts.get(position).getFeatures ();
PropertyList.Iterator pl2i = pl2.iterator();
while (pl2i.hasNext()) {
pl2i.next();
String key = pl2i.getKey();
if (featureRegex == null || featureRegex.matcher(key).matches()) {
newFeatures[i] = PropertyList.add ((namePrefixLeft == null || position-i>0 ? namePrefix : namePrefixLeft)+key,
pl2i.getNumericValue(), newFeatures[i]);
}
}
}
}
for (int i = 0; i < tsSize; i++) {
// Put the new PropertyLists in place
ts.get (i).setFeatures (newFeatures[i]);
}
return carrier;
}
示例4: addExactMatch
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
private PropertyList addExactMatch(Record[] records,
Alphabet fieldAlph, Alphabet valueAlph, PropertyList features) {
for (int fi = 0; fi < exactMatchFields.length; fi++) {
int matches = 0;
int comparisons = 0;
for (int i = 0; i < records.length
&& exactMatchFields.length > 0; i++) {
FeatureVector valsi = records[i]
.values(exactMatchFields[fi]);
for (int j = i + 1; j < records.length && valsi != null; j++) {
FeatureVector valsj = records[j]
.values(exactMatchFields[fi]);
if (valsj != null) {
comparisons++;
for (int ii = 0; ii < valsi.numLocations(); ii++) {
if (valsj.contains(valueAlph.lookupObject(valsi
.indexAtLocation(ii)))) {
matches++;
break;
}
}
}
}
if (matches == comparisons && comparisons > 1)
features = PropertyList.add(fieldAlph
.lookupObject(exactMatchFields[fi])
+ "_all_match", 1.0, features);
if (matches > 0)
features = PropertyList.add(fieldAlph
.lookupObject(exactMatchFields[fi])
+ "_exists_match", 1.0, features);
}
}
return features;
}
示例5: testOne
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public void testOne ()
{
PropertyList pl = null;
pl = PropertyList.add ("one", 1.0, pl);
pl = PropertyList.add ("two", 2.0, pl);
pl = PropertyList.add ("three", 3, pl);
assertTrue (pl.lookupNumber("one") == 1.0);
pl = PropertyList.remove ("three", pl);
assertTrue (pl.lookupNumber("three") == 0.0);
pl = PropertyList.add ("color", "red", pl);
assertTrue (pl.lookupObject("color").equals("red"));
}
示例6: makeConjunctions
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
/**
* Recursively makes conjunctions by iterating through features at each
* offset
*
* @param iters
* iterate over the PropertyLists at each offset
* @param currIndex
* which offset we're currently on, e..g 1 in the list [0,1,2]
* @param conjunctions
* list of conjunctions
* @param j
* which offset list we're currently on, e.g. [0,1,2] in the list
* [[0,1],[0,1,2]]
* @param tsSize
* size of token sequence
* @param newfs
* new features
* @param tsi
* token sequence index
* @param oldfs
* old features
* @param iterIndices
* counter to keep track how far in each iterator in "iters"
* @return new features
*/
private PropertyList makeConjunctions(PropertyList.Iterator[] iters,
int currIndex, int[][] conjunctions, int j, int tsSize,
PropertyList newfs, int tsi, PropertyList[] oldfs, int[] iterIndices) {
if (iters.length == currIndex) { // base case: add feature for current
// conjunction of iters
// avoid redundant doubling of feature space; include only upper
// triangle
if (redundant(conjunctions, j, iterIndices)) {
return newfs;
}
String newFeature = "";
double newValue = 1.0;
for (int i = 0; i < iters.length; i++) {
String s = iters[i].getKey();
if (featureRegex != null && !featureRegex.matcher(s).matches())
return newfs;
newFeature += (i == 0 ? "" : "_&_")
+ s
+ (("@" + conjunctions[j][i]));
newValue *= iters[i].getNumericValue();
}
// System.err.println ("Adding new feature " + newFeature);
newfs = PropertyList.add(newFeature, newValue, newfs);
} else { // recursive step
while (iters[currIndex].hasNext()) {
iters[currIndex].next();
iterIndices[currIndex]++;
newfs = makeConjunctions(iters, currIndex + 1, conjunctions, j,
tsSize, newfs, tsi, oldfs, iterIndices);
}
// reset iterator at currIndex
iters[currIndex] = getOffsetIter(conjunctions, j, currIndex,
tsSize, tsi, oldfs);
iterIndices[currIndex] = -1;
}
return newfs;
}
示例7: setNumericProperty
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public void setNumericProperty (String key, double value)
{
properties = PropertyList.add (key, value, properties);
}
示例8: setFeatureValue
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public void setFeatureValue (String key, double value) {
features = PropertyList.add (key, value, features); }
示例9: setNumericProperty
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public void setNumericProperty (String key, double value) {
properties = PropertyList.add( key, value, properties );
}
示例10: setProperty
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public void setProperty (String key, Object value) {
properties = PropertyList.add( key, value, properties );
}
示例11: setProperty
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public void setProperty (String key, Object value)
{
properties = PropertyList.add (key, value, properties);
}
示例12: setNumericProperty
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public void setNumericProperty (String key, double value)
{
properties = PropertyList.add (key, value, properties);
}
示例13: setProperty
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public void setProperty (String key, Object value) {
properties = PropertyList.add (key, value, properties);
}
示例14: setNumericProperty
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public void setNumericProperty (String key, double value) {
properties = PropertyList.add (key, value, properties);
}
示例15: setFeatureValue
import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public void setFeatureValue (String key, double value) {
features = PropertyList.add (key, value, features);
}