本文整理了Java中cc.mallet.types.InstanceList.iterator()
方法的一些代码示例,展示了InstanceList.iterator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。InstanceList.iterator()
方法的具体详情如下:
包路径:cc.mallet.types.InstanceList
类名称:InstanceList
方法名:iterator
暂无
代码示例来源:origin: com.github.steveash.mallet/mallet
public MultiIterator () {
this.i = lists.length == 0 ? null : lists[0].iterator ();
}
代码示例来源:origin: cc.mallet/mallet
public MultiIterator () {
this.i = lists.length == 0 ? null : lists[0].iterator ();
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public MultiIterator () {
this.i = lists.length == 0 ? null : lists[0].iterator ();
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public String toString () {
StringBuffer buf = new StringBuffer ();
buf.append ("[");
for (int listIndex = 0; listIndex < this.lists.length; listIndex++) {
if (this.lists[listIndex] != null) {
Iterator<Instance> i = this.lists[listIndex].iterator ();
boolean hasNext = i.hasNext ();
while (hasNext) {
Instance o = i.next ();
buf.append (String.valueOf (o));
hasNext = i.hasNext ();
if (listIndex < this.lists.length || hasNext) {
buf.append (", ");
}
}
}
}
buf.append ("]");
return buf.toString ();
}
代码示例来源:origin: cc.mallet/mallet
public String toString () {
StringBuffer buf = new StringBuffer ();
buf.append ("[");
for (int listIndex = 0; listIndex < this.lists.length; listIndex++) {
if (this.lists[listIndex] != null) {
Iterator<Instance> i = this.lists[listIndex].iterator ();
boolean hasNext = i.hasNext ();
while (hasNext) {
Instance o = i.next ();
buf.append (String.valueOf (o));
hasNext = i.hasNext ();
if (listIndex < this.lists.length || hasNext) {
buf.append (", ");
}
}
}
}
buf.append ("]");
return buf.toString ();
}
代码示例来源:origin: cc.mallet/mallet
public Instance next () {
if (this.index < lists.length) {
if (this.i.hasNext ()) {
return this.i.next ();
}
for (this.index++; this.index < lists.length; this.index++) {
final InstanceList list = lists[this.index];
if (list != null && lists[this.index].size () > 0) {
this.i = lists[this.index].iterator ();
return this.i.next ();
}
}
}
throw new NoSuchElementException ();
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public Instance next () {
if (this.index < lists.length) {
if (this.i.hasNext ()) {
return this.i.next ();
}
for (this.index++; this.index < lists.length; this.index++) {
final InstanceList list = lists[this.index];
if (list != null && lists[this.index].size () > 0) {
this.i = lists[this.index].iterator ();
return this.i.next ();
}
}
}
throw new NoSuchElementException ();
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public Instance next () {
if (this.index < lists.length) {
if (this.i.hasNext ()) {
return this.i.next ();
}
for (this.index++; this.index < lists.length; this.index++) {
final InstanceList list = lists[this.index];
if (list != null && lists[this.index].size () > 0) {
this.i = lists[this.index].iterator ();
return this.i.next ();
}
}
}
throw new NoSuchElementException ();
}
代码示例来源:origin: jdmp/java-data-mining-package
public int getSampleCount() {
int count = 0;
Iterator<?> it = instanceList.iterator();
while (it.hasNext()) {
Instance instance = (Instance) it.next();
Object data = instance.getData();
if (data instanceof FeatureVectorSequence) {
FeatureVectorSequence fvs = (FeatureVectorSequence) data;
count += fvs.size();
}
}
return count;
}
代码示例来源:origin: cc.mallet/mallet
/**
* Returns the next training/testing split.
* @return A pair of lists, where <code>InstanceList[0]</code> is the larger split (training)
* and <code>InstanceList[1]</code> is the smaller split (testing)
*/
public InstanceList[] nextSplit () {
InstanceList[] ret = new InstanceList[2];
ret[0] = new InstanceList (pipe);
for (int i=0; i < folds.length; i++) {
if (i==index)
continue;
Iterator<Instance> iter = folds[i].iterator();
while (iter.hasNext())
ret[0].add (iter.next());
}
ret[1] = folds[index].shallowClone();
index++;
return ret;
}
代码示例来源:origin: com.github.steveash.mallet/mallet
/**
* Returns the next training/testing split.
* @return A pair of lists, where <code>InstanceList[0]</code> is the larger split (training)
* and <code>InstanceList[1]</code> is the smaller split (testing)
*/
public InstanceList[] nextSplit () {
InstanceList[] ret = new InstanceList[2];
ret[0] = new InstanceList (pipe);
for (int i=0; i < folds.length; i++) {
if (i==index)
continue;
Iterator<Instance> iter = folds[i].iterator();
while (iter.hasNext())
ret[0].add (iter.next());
}
ret[1] = folds[index].shallowClone();
index++;
return ret;
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
private static SparseVector mean(InstanceList instances,
SparseVector meanVector) {
if (instances == null || instances.size() == 0)
return null;
Instance instance;
SparseVector v;
Iterator<Instance> instanceItr = instances.iterator();
double factor = 1.0 / (double) instances.size();
while (instanceItr.hasNext()) {
instance = (Instance) instanceItr.next();
v = (SparseVector) (instance.getData());
meanVector.plusEqualsSparse(v, factor);
}
return meanVector;
}
代码示例来源:origin: com.github.steveash.mallet/mallet
private static SparseVector mean(InstanceList instances,
SparseVector meanVector) {
if (instances == null || instances.size() == 0)
return null;
Instance instance;
SparseVector v;
Iterator<Instance> instanceItr = instances.iterator();
double factor = 1.0 / (double) instances.size();
while (instanceItr.hasNext()) {
instance = (Instance) instanceItr.next();
v = (SparseVector) (instance.getData());
meanVector.plusEqualsSparse(v, factor);
}
return meanVector;
}
代码示例来源:origin: cc.mallet/mallet
public static TestResults computeTestResults (InstanceList testList, List returnedList)
{
TestResults results = new TestResults (testList);
Iterator it1 = testList.iterator ();
Iterator it2 = returnedList.iterator ();
while (it1.hasNext ()) {
Instance inst = (Instance) it1.next ();
// System.out.println ("\n\nInstance");
LabelsAssignment lblseq = (LabelsAssignment) inst.getTarget ();
LabelsSequence target = lblseq.getLabelsSequence ();
LabelsSequence returned = (LabelsSequence) it2.next ();
// System.out.println (target);
compareLabelings (results, returned, target);
}
results.computeStatistics ();
return results;
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public static TestResults computeTestResults (InstanceList testList, List returnedList)
{
TestResults results = new TestResults (testList);
Iterator it1 = testList.iterator ();
Iterator it2 = returnedList.iterator ();
while (it1.hasNext ()) {
Instance inst = (Instance) it1.next ();
// System.out.println ("\n\nInstance");
LabelsAssignment lblseq = (LabelsAssignment) inst.getTarget ();
LabelsSequence target = lblseq.getLabelsSequence ();
LabelsSequence returned = (LabelsSequence) it2.next ();
// System.out.println (target);
compareLabelings (results, returned, target);
}
results.computeStatistics ();
return results;
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public static TestResults computeTestResults (InstanceList testList, List returnedList)
{
TestResults results = new TestResults (testList);
Iterator it1 = testList.iterator ();
Iterator it2 = returnedList.iterator ();
while (it1.hasNext ()) {
Instance inst = (Instance) it1.next ();
// System.out.println ("\n\nInstance");
LabelsAssignment lblseq = (LabelsAssignment) inst.getTarget ();
LabelsSequence target = lblseq.getLabelsSequence ();
LabelsSequence returned = (LabelsSequence) it2.next ();
// System.out.println (target);
compareLabelings (results, returned, target);
}
results.computeStatistics ();
return results;
}
代码示例来源:origin: cc.mallet/mallet
private static SparseVector mean(InstanceList instances,
SparseVector meanVector) {
if (instances == null || instances.size() == 0)
return null;
Instance instance;
SparseVector v;
Iterator<Instance> instanceItr = instances.iterator();
double factor = 1.0 / (double) instances.size();
while (instanceItr.hasNext()) {
instance = (Instance) instanceItr.next();
v = (SparseVector) (instance.getData());
meanVector.plusEqualsSparse(v, factor);
}
return meanVector;
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public InstanceList pipeInstances (Iterator<Instance> source)
{
// I think that pipes should be associated neither with InstanceLists, nor
// with Instances. -cas
InstanceList toked = new InstanceList (tokenizationPipe);
toked.addThruPipe (source);
InstanceList piped = new InstanceList (getFeaturePipe ());
piped.addThruPipe (toked.iterator());
return piped;
}
代码示例来源:origin: cc.mallet/mallet
public InstanceList pipeInstances (Iterator<Instance> source)
{
// I think that pipes should be associated neither with InstanceLists, nor
// with Instances. -cas
InstanceList toked = new InstanceList (tokenizationPipe);
toked.addThruPipe (source);
InstanceList piped = new InstanceList (getFeaturePipe ());
piped.addThruPipe (toked.iterator());
return piped;
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public InstanceList pipeInstances (Iterator<Instance> source)
{
// I think that pipes should be associated neither with InstanceLists, nor
// with Instances. -cas
InstanceList toked = new InstanceList (tokenizationPipe);
toked.addThruPipe (source);
InstanceList piped = new InstanceList (getFeaturePipe ());
piped.addThruPipe (toked.iterator());
return piped;
}
内容来源于网络,如有侵权,请联系作者删除!