当前位置: 首页>>代码示例>>Java>>正文


Java PropertyList.Iterator方法代码示例

本文整理汇总了Java中cc.mallet.util.PropertyList.Iterator方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyList.Iterator方法的具体用法?Java PropertyList.Iterator怎么用?Java PropertyList.Iterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cc.mallet.util.PropertyList的用法示例。


在下文中一共展示了PropertyList.Iterator方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pipe

import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public Instance pipe (Instance carrier)
{
	TokenSequence ts = (TokenSequence) carrier.getData();
	int tsSize = ts.size();
	for (int i = tsSize-1; i >= 0; i--) {
		Token t = ts.get (i);
		String text = t.getText();
		if (featureRegex != null && !featureRegex.matcher(text).matches())
			continue;
		for (int j = 0; j < i; j++) {
			if (ts.get(j).getText().equals(text)) {
				PropertyList.Iterator iter = ts.get(j).getFeatures().iterator();
				while (iter.hasNext()) {
					iter.next();
					String key = iter.getKey();
					if (filterRegex == null || (filterRegex.matcher(key).matches() ^ !includeFiltered))
						t.setFeatureValue (namePrefix+key, iter.getNumericValue());
				}
				break;
			}
			if (firstMentionName != null)
				t.setFeatureValue (firstMentionName, 1.0);
		}
	}
	return carrier;
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:27,代码来源:FeaturesOfFirstMention.java

示例2: 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());
	}
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:15,代码来源:AugmentableFeatureVector.java

示例3: toStringWithFeatureNames

import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
public String toStringWithFeatureNames () {
	StringBuffer sb = new StringBuffer ();
	sb.append (getText());
	if (features != null) {
		PropertyList.Iterator iter = features.iterator();
		while (iter.hasNext()) {
			iter.next();
			sb.append (" " + iter.getKey());
		}
	}
	return sb.toString();
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:13,代码来源:Token.java

示例4: 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;
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:45,代码来源:OffsetConjunctions.java

示例5: getOffsetIters

import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
/** Get iterators for each token in this offset */
private PropertyList.Iterator[] getOffsetIters (int [][] conjunctions, int j, int tsSize, int tsi,
																								PropertyList[] oldfs) {		
	PropertyList.Iterator[] iters = new PropertyList.Iterator[conjunctions[j].length];
	// get iterators for offsets
	for (int iteri=0; iteri < iters.length; iteri++) {
		iters[iteri] = getOffsetIter (conjunctions, j, iteri, tsSize, tsi, oldfs);
		if (iters[iteri]==null)
			return null;
	}
	return iters;
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:13,代码来源:OffsetConjunctions.java

示例6: getOffsetIter

import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
private PropertyList.Iterator getOffsetIter (int [][] conjunctions, int j, int iteri, int tsSize, int tsi,
																						 PropertyList[] oldfs) {
	PropertyList.Iterator iter;
	if (tsi+conjunctions[j][iteri] < 0)
		iter = startfs[-(tsi+conjunctions[j][iteri])-1].iterator();
	else if (conjunctions[j][iteri]+tsi > tsSize-1)
		iter = endfs[tsi+conjunctions[j][iteri]-tsSize].iterator();
	else if (oldfs[conjunctions[j][iteri]+tsi] == null)
		iter = null;
	else
		iter = oldfs[tsi+conjunctions[j][iteri]].iterator();
	return iter;
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:14,代码来源:OffsetConjunctions.java

示例7: 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;
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:37,代码来源:FeaturesInWindow.java

示例8: hasMatchingFeature

import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
private boolean hasMatchingFeature (Token token, Pattern pattern)
{
	PropertyList.Iterator iter = token.getFeatures ().iterator ();
	while (iter.hasNext()) {
		iter.next();
		if (pattern.matcher (iter.getKey()). matches ()) {
			if (iter.getNumericValue() == 1.0) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:14,代码来源:OffsetFeatureConjunction.java

示例9: 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());
	}
}
 
开发者ID:sameeraxiomine,项目名称:largelda,代码行数:15,代码来源:BigAugmentableFeatureVector.java

示例10: 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;
}
 
开发者ID:siqil,项目名称:udaner,代码行数:63,代码来源:ModOffsetConjunctions.java

示例11: getOffsetIters

import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
/** Get iterators for each token in this offset */
private PropertyList.Iterator[] getOffsetIters(int[][] conjunctions, int j,
		int tsSize, int tsi, PropertyList[] oldfs) {
	PropertyList.Iterator[] iters = new PropertyList.Iterator[conjunctions[j].length];
	// get iterators for offsets
	for (int iteri = 0; iteri < iters.length; iteri++) {
		iters[iteri] = getOffsetIter(conjunctions, j, iteri, tsSize, tsi,
				oldfs);
		if (iters[iteri] == null)
			return null;
	}
	return iters;
}
 
开发者ID:siqil,项目名称:udaner,代码行数:14,代码来源:ModOffsetConjunctions.java

示例12: getOffsetIter

import cc.mallet.util.PropertyList; //导入方法依赖的package包/类
private PropertyList.Iterator getOffsetIter(int[][] conjunctions, int j,
		int iteri, int tsSize, int tsi, PropertyList[] oldfs) {
	PropertyList.Iterator iter;
	if (tsi + conjunctions[j][iteri] < 0)
		iter = startfs[-(tsi + conjunctions[j][iteri]) - 1].iterator();
	else if (conjunctions[j][iteri] + tsi > tsSize - 1)
		iter = endfs[tsi + conjunctions[j][iteri] - tsSize].iterator();
	else if (oldfs[conjunctions[j][iteri] + tsi] == null)
		iter = null;
	else
		iter = oldfs[tsi + conjunctions[j][iteri]].iterator();
	return iter;
}
 
开发者ID:siqil,项目名称:udaner,代码行数:14,代码来源:ModOffsetConjunctions.java

示例13: 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;
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:48,代码来源:SparseVector.java

示例14: 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;
}
 
开发者ID:sameeraxiomine,项目名称:largelda,代码行数:48,代码来源:BigSparseVector.java


注:本文中的cc.mallet.util.PropertyList.Iterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。