本文整理汇总了Java中cc.mallet.pipe.iterator.ArrayIterator类的典型用法代码示例。如果您正苦于以下问题:Java ArrayIterator类的具体用法?Java ArrayIterator怎么用?Java ArrayIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayIterator类属于cc.mallet.pipe.iterator包,在下文中一共展示了ArrayIterator类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testTokenAccuracy
import cc.mallet.pipe.iterator.ArrayIterator; //导入依赖的package包/类
public void testTokenAccuracy() {
Pipe p = makeSpacePredictionPipe();
InstanceList instances = new InstanceList(p);
instances.addThruPipe(new ArrayIterator(data));
InstanceList[] lists = instances.split(new Random(777), new double[] {
.5, .5 });
CRF crf = new CRF(p.getDataAlphabet(), p.getTargetAlphabet());
crf.addFullyConnectedStatesForLabels();
CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood(crf);
crft.setUseSparseWeights(true);
crft.trainIncremental(lists[0]);
TokenAccuracyEvaluator eval = new TokenAccuracyEvaluator(lists,
new String[] { "Train", "Test" });
eval.evaluateInstanceList(crft, lists[1], "Test");
assertEquals(0.9409, eval.getAccuracy("Test"), 0.001);
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:23,代码来源:TestCRF.java
示例2: testPrint
import cc.mallet.pipe.iterator.ArrayIterator; //导入依赖的package包/类
public void testPrint() {
Pipe p = new SerialPipes(new Pipe[] {
new CharSequence2TokenSequence("."), new TokenText(),
new TestCRFTokenSequenceRemoveSpaces(),
new TokenSequence2FeatureVectorSequence(),
new PrintInputAndTarget(), });
InstanceList one = new InstanceList(p);
String[] data = new String[] { "ABCDE", };
one.addThruPipe(new ArrayIterator(data));
CRF crf = new CRF(p, null);
crf.addFullyConnectedStatesForThreeQuarterLabels(one);
CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood(crf);
crf.setWeightsDimensionAsIn(one, false);
Optimizable mcrf = crft.getOptimizableCRF(one);
double[] params = new double[mcrf.getNumParameters()];
for (int i = 0; i < params.length; i++) {
params[i] = i;
}
mcrf.setParameters(params);
crf.print();
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:22,代码来源:TestCRF.java
示例3: testSpaceSerializable
import cc.mallet.pipe.iterator.ArrayIterator; //导入依赖的package包/类
public void testSpaceSerializable () throws IOException, ClassNotFoundException
{
Pipe p = makeSpacePredictionPipe ();
InstanceList training = new InstanceList (p);
training.addThruPipe (new ArrayIterator (data));
MEMM memm = new MEMM (p, null);
memm.addFullyConnectedStatesForLabels ();
memm.addStartState();
memm.setWeightsDimensionAsIn(training);
MEMMTrainer memmt = new MEMMTrainer (memm);
memmt.train (training, 10);
MEMM memm2 = (MEMM) TestSerializable.cloneViaSerialization (memm);
Optimizable.ByGradientValue mcrf1 = memmt.getOptimizableMEMM(training);
double val1 = mcrf1.getValue ();
Optimizable.ByGradientValue mcrf2 = memmt.getOptimizableMEMM(training);
double val2 = mcrf2.getValue ();
assertEquals (val1, val2, 1e-5);
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:23,代码来源:TestMEMM.java
示例4: disabledtestPrint
import cc.mallet.pipe.iterator.ArrayIterator; //导入依赖的package包/类
public void disabledtestPrint ()
{
Pipe p = new SerialPipes (new Pipe[] {
new CharSequence2TokenSequence("."),
new TokenText(),
new TestMEMM.TestMEMMTokenSequenceRemoveSpaces(),
new TokenSequence2FeatureVectorSequence(),
new PrintInputAndTarget(),
});
InstanceList one = new InstanceList (p);
String[] data = new String[] { "ABCDE", };
one.addThruPipe (new ArrayIterator (data));
MEMM crf = new MEMM (p, null);
crf.addFullyConnectedStatesForLabels();
crf.setWeightsDimensionAsIn (one);
MEMMTrainer memmt = new MEMMTrainer (crf);
MEMMTrainer.MEMMOptimizableByLabelLikelihood mcrf = memmt.getOptimizableMEMM(one);
double[] params = new double[mcrf.getNumParameters()];
for (int i = 0; i < params.length; i++) {
params [i] = i;
}
mcrf.setParameters (params);
crf.print ();
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:25,代码来源:TestMEMM.java
示例5: testMultiTagSerialization
import cc.mallet.pipe.iterator.ArrayIterator; //导入依赖的package包/类
public static void testMultiTagSerialization () throws IOException, ClassNotFoundException
{
Pipe origPipe = new SerialPipes (new Pipe[] {
new SimpleTaggerSentence2TokenSequence (),
new TokenText (),
new RegexMatches ("digits", Pattern.compile ("[0-9]+")),
new RegexMatches ("ampm", Pattern.compile ("[aApP][mM]")),
new OffsetFeatureConjunction ("time",
new String[] { "digits", "ampm" },
new int[] { 0, 1 },
true),
new PrintInputAndTarget (),
});
Pipe mtPipe = (Pipe) TestSerializable.cloneViaSerialization (origPipe);
InstanceList mtLst = new InstanceList (mtPipe);
mtLst.addThruPipe (new ArrayIterator (doc1));
Instance mtInst = mtLst.get (0);
TokenSequence mtTs = (TokenSequence) mtInst.getData ();
assertEquals (6, mtTs.size ());
assertEquals (1.0, mtTs.get (3).getFeatureValue ("time"), 1e-15);
assertEquals (1.0, mtTs.get (4).getFeatureValue ("time"), 1e-15);
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:24,代码来源:TestOffsetFeatureConjunctions.java
示例6: testSpaceViewer
import cc.mallet.pipe.iterator.ArrayIterator; //导入依赖的package包/类
public void testSpaceViewer () throws IOException
{
Pipe pipe = TestMEMM.makeSpacePredictionPipe ();
String[] data0 = { TestCRF.data[0] };
String[] data1 = { TestCRF.data[1] };
InstanceList training = new InstanceList (pipe);
training.addThruPipe (new ArrayIterator (data0));
InstanceList testing = new InstanceList (pipe);
testing.addThruPipe (new ArrayIterator (data1));
CRF crf = new CRF (pipe, null);
crf.addFullyConnectedStatesForLabels ();
CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood (crf);
crft.trainIncremental (training);
CRFExtractor extor = TestLatticeViewer.hackCrfExtor (crf);
Extraction extraction = extor.extract (new ArrayIterator (data1));
if (!outputDir.exists ()) outputDir.mkdir ();
DocumentViewer.writeExtraction (outputDir, extraction);
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:23,代码来源:TestDocumentViewer.java
示例7: disabledtestPrint
import cc.mallet.pipe.iterator.ArrayIterator; //导入依赖的package包/类
public void disabledtestPrint ()
{
Pipe p = new SerialPipes (new Pipe[] {
new CharSequence2TokenSequence("."),
new TokenText(),
new TestMEMMTokenSequenceRemoveSpaces(),
new TokenSequence2FeatureVectorSequence(),
new PrintInputAndTarget(),
});
InstanceList one = new InstanceList (p);
String[] data = new String[] { "ABCDE", };
one.addThruPipe (new ArrayIterator (data));
MEMM crf = new MEMM (p, null);
crf.addFullyConnectedStatesForLabels();
crf.setWeightsDimensionAsIn (one);
MEMMTrainer memmt = new MEMMTrainer (crf);
MEMMTrainer.MEMMOptimizableByLabelLikelihood mcrf = memmt.getOptimizableMEMM(one);
double[] params = new double[mcrf.getNumParameters()];
for (int i = 0; i < params.length; i++) {
params [i] = i;
}
mcrf.setParameters (params);
crf.print ();
}
开发者ID:shalomeir,项目名称:tctm,代码行数:25,代码来源:TestMEMM.java
示例8: ignoretestTokenAccuracy
import cc.mallet.pipe.iterator.ArrayIterator; //导入依赖的package包/类
public void ignoretestTokenAccuracy() {
Pipe p = makeSpacePredictionPipe();
InstanceList instances = new InstanceList(p);
instances.addThruPipe(new ArrayIterator(data));
InstanceList[] lists = instances.split(new Random(777), new double[] {
.5, .5 });
CRF crf = new CRF(p.getDataAlphabet(), p.getTargetAlphabet());
crf.addFullyConnectedStatesForLabels();
CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood(crf);
crft.setUseSparseWeights(true);
crft.trainIncremental(lists[0]);
TokenAccuracyEvaluator eval = new TokenAccuracyEvaluator(lists,
new String[] { "Train", "Test" });
eval.evaluateInstanceList(crft, lists[1], "Test");
assertEquals(0.9409, eval.getAccuracy("Test"), 0.001);
}
开发者ID:cmoen,项目名称:mallet,代码行数:23,代码来源:TestCRF.java
示例9: ignoretestSpaceSerializable
import cc.mallet.pipe.iterator.ArrayIterator; //导入依赖的package包/类
public void ignoretestSpaceSerializable () throws IOException, ClassNotFoundException
{
Pipe p = makeSpacePredictionPipe ();
InstanceList training = new InstanceList (p);
training.addThruPipe (new ArrayIterator (data));
MEMM memm = new MEMM (p, null);
memm.addFullyConnectedStatesForLabels ();
memm.addStartState();
memm.setWeightsDimensionAsIn(training);
MEMMTrainer memmt = new MEMMTrainer (memm);
memmt.train (training, 10);
MEMM memm2 = (MEMM) TestSerializable.cloneViaSerialization (memm);
Optimizable.ByGradientValue mcrf1 = memmt.getOptimizableMEMM(training);
double val1 = mcrf1.getValue ();
Optimizable.ByGradientValue mcrf2 = memmt.getOptimizableMEMM(training);
double val2 = mcrf2.getValue ();
assertEquals (val1, val2, 1e-5);
}
开发者ID:cmoen,项目名称:mallet,代码行数:23,代码来源:TestMEMM.java
示例10: ignoretestSpaceViewer
import cc.mallet.pipe.iterator.ArrayIterator; //导入依赖的package包/类
public void ignoretestSpaceViewer () throws IOException
{
Pipe pipe = TestMEMM.makeSpacePredictionPipe ();
String[] data0 = { TestCRF.data[0] };
String[] data1 = { TestCRF.data[1] };
InstanceList training = new InstanceList (pipe);
training.addThruPipe (new ArrayIterator (data0));
InstanceList testing = new InstanceList (pipe);
testing.addThruPipe (new ArrayIterator (data1));
CRF crf = new CRF (pipe, null);
crf.addFullyConnectedStatesForLabels ();
CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood (crf);
crft.trainIncremental (training);
CRFExtractor extor = TestLatticeViewer.hackCrfExtor (crf);
Extraction extraction = extor.extract (new ArrayIterator (data1));
if (!outputDir.exists ()) outputDir.mkdir ();
DocumentViewer.writeExtraction (outputDir, extraction);
}
开发者ID:cmoen,项目名称:mallet,代码行数:23,代码来源:TestDocumentViewer.java
示例11: createInstanceList
import cc.mallet.pipe.iterator.ArrayIterator; //导入依赖的package包/类
/**
* Creates a list of Malelt instances from a list of documents
* @param texts a list of documents
* @return a list of Mallet instances
* @throws IOException
*/
private InstanceList createInstanceList(List<String> texts) throws IOException
{
ArrayList<Pipe> pipes = new ArrayList<Pipe>();
pipes.add(new CharSequence2TokenSequence());
pipes.add(new TokenSequenceLowercase());
pipes.add(new TokenSequenceRemoveStopwords());
pipes.add(new TokenSequence2FeatureSequence());
InstanceList instanceList = new InstanceList(new SerialPipes(pipes));
instanceList.addThruPipe(new ArrayIterator(texts));
return instanceList;
}
开发者ID:socialsensor,项目名称:topic-detection,代码行数:18,代码来源:LDA.java
注:本文中的cc.mallet.pipe.iterator.ArrayIterator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论