本文整理汇总了Java中cc.mallet.grmm.learning.GenericAcrfData2TokenSequence类的典型用法代码示例。如果您正苦于以下问题:Java GenericAcrfData2TokenSequence类的具体用法?Java GenericAcrfData2TokenSequence怎么用?Java GenericAcrfData2TokenSequence使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenericAcrfData2TokenSequence类属于cc.mallet.grmm.learning包,在下文中一共展示了GenericAcrfData2TokenSequence类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testLabelsAtEnd
import cc.mallet.grmm.learning.GenericAcrfData2TokenSequence; //导入依赖的package包/类
public void testLabelsAtEnd () throws IOException, ClassNotFoundException
{
GenericAcrfData2TokenSequence p = new GenericAcrfData2TokenSequence (2);
p.setLabelsAtEnd (true);
InstanceList training = new InstanceList (p);
training.addThruPipe (new LineGroupIterator (new StringReader (labelsAtEndData), Pattern.compile ("^$"), true));
assertEquals (1, training.size ());
Instance inst1 = training.get (0);
StringTokenization toks = (StringTokenization) inst1.getData ();
LabelsSequence ls1 = (LabelsSequence) inst1.getTarget ();
assertEquals (4, ls1.size ());
assertEquals (3, toks.get(0).getFeatures ().size ());
assertEquals ("LBLB LBLD", ls1.getLabels (0).toString ());
LabelAlphabet globalDict = p.getLabelAlphabet (0);
assertEquals (2, p.numLevels ());
assertEquals (globalDict, ls1.getLabels (0).get (0).getLabelAlphabet ());
}
开发者ID:mimno,项目名称:GRMM,代码行数:23,代码来源:TestGenericAcrfData2TokenSequence.java
示例2: testNoTokenText
import cc.mallet.grmm.learning.GenericAcrfData2TokenSequence; //导入依赖的package包/类
public void testNoTokenText ()
{
GenericAcrfData2TokenSequence p = new GenericAcrfData2TokenSequence (2);
p.setFeaturesIncludeToken(false);
p.setIncludeTokenText(false);
InstanceList training = new InstanceList (p);
training.addThruPipe (new LineGroupIterator (new StringReader (sampleFixedData), Pattern.compile ("^$"), true));
assertEquals (1, training.size ());
Instance inst1 = training.get (0);
LabelsSequence ls1 = (LabelsSequence) inst1.getTarget ();
assertEquals (4, ls1.size ());
TokenSequence ts1 = (TokenSequence) inst1.getData ();
assertEquals (3, ts1.get(0).getFeatures().size ());
assertEquals (2, ts1.get(1).getFeatures().size ());
}
开发者ID:mimno,项目名称:GRMM,代码行数:21,代码来源:TestGenericAcrfData2TokenSequence.java
示例3: ignoretestLabelsAtEnd
import cc.mallet.grmm.learning.GenericAcrfData2TokenSequence; //导入依赖的package包/类
public void ignoretestLabelsAtEnd () throws IOException, ClassNotFoundException
{
GenericAcrfData2TokenSequence p = new GenericAcrfData2TokenSequence (2);
p.setLabelsAtEnd (true);
InstanceList training = new InstanceList (p);
training.addThruPipe (new LineGroupIterator (new StringReader (labelsAtEndData), Pattern.compile ("^$"), true));
assertEquals (1, training.size ());
Instance inst1 = training.get (0);
StringTokenization toks = (StringTokenization) inst1.getData ();
LabelsSequence ls1 = (LabelsSequence) inst1.getTarget ();
assertEquals (4, ls1.size ());
assertEquals (3, toks.get(0).getFeatures ().size ());
assertEquals ("LBLB LBLD", ls1.getLabels (0).toString ());
LabelAlphabet globalDict = p.getLabelAlphabet (0);
assertEquals (2, p.numLevels ());
assertEquals (globalDict, ls1.getLabels (0).get (0).getLabelAlphabet ());
}
开发者ID:cmoen,项目名称:mallet,代码行数:23,代码来源:TestGenericAcrfData2TokenSequence.java
示例4: ignoretestNoTokenText
import cc.mallet.grmm.learning.GenericAcrfData2TokenSequence; //导入依赖的package包/类
public void ignoretestNoTokenText ()
{
GenericAcrfData2TokenSequence p = new GenericAcrfData2TokenSequence (2);
p.setFeaturesIncludeToken(false);
p.setIncludeTokenText(false);
InstanceList training = new InstanceList (p);
training.addThruPipe (new LineGroupIterator (new StringReader (sampleFixedData), Pattern.compile ("^$"), true));
assertEquals (1, training.size ());
Instance inst1 = training.get (0);
LabelsSequence ls1 = (LabelsSequence) inst1.getTarget ();
assertEquals (4, ls1.size ());
TokenSequence ts1 = (TokenSequence) inst1.getData ();
assertEquals (3, ts1.get(0).getFeatures().size ());
assertEquals (2, ts1.get(1).getFeatures().size ());
}
开发者ID:cmoen,项目名称:mallet,代码行数:21,代码来源:TestGenericAcrfData2TokenSequence.java
示例5: main
import cc.mallet.grmm.learning.GenericAcrfData2TokenSequence; //导入依赖的package包/类
public static void main (String[] args) throws FileNotFoundException
{
File trainFile = new File (args[0]);
File testFile = new File (args[1]);
File crfFile = new File (args[2]);
Pipe pipe = new SerialPipes (new Pipe[] {
new GenericAcrfData2TokenSequence (2),
new TokenSequence2FeatureVectorSequence (true, true),
});
InstanceList training = new InstanceList (pipe);
training.addThruPipe (new LineGroupIterator (new FileReader (trainFile),
Pattern.compile ("\\s*"),
true));
InstanceList testing = new InstanceList (pipe);
testing.addThruPipe (new LineGroupIterator (new FileReader (testFile),
Pattern.compile ("\\s*"),
true));
ACRF.Template[] tmpls = new ACRF.Template[] {
new ACRF.BigramTemplate (0),
new ACRF.BigramTemplate (1),
new ACRF.PairwiseFactorTemplate (0,1),
new CrossTemplate1 (0,1)
};
ACRF acrf = new ACRF (pipe, tmpls);
ACRFTrainer trainer = new DefaultAcrfTrainer ();
trainer.train (acrf, training, null, testing, 99999);
FileUtils.writeGzippedObject (crfFile, acrf);
}
开发者ID:mimno,项目名称:GRMM,代码行数:36,代码来源:SimpleCrfExample.java
示例6: testFromSerialization
import cc.mallet.grmm.learning.GenericAcrfData2TokenSequence; //导入依赖的package包/类
public void testFromSerialization () throws IOException, ClassNotFoundException
{
Pipe p = new GenericAcrfData2TokenSequence ();
InstanceList training = new InstanceList (p);
training.addThruPipe (new LineGroupIterator (new StringReader (sampleData), Pattern.compile ("^$"), true));
Pipe p2 = (Pipe) TestSerializable.cloneViaSerialization (p);
InstanceList l1 = new InstanceList (p);
l1.addThruPipe (new LineGroupIterator (new StringReader (sampleData2), Pattern.compile ("^$"), true));
InstanceList l2 = new InstanceList (p2);
l2.addThruPipe (new LineGroupIterator (new StringReader (sampleData2), Pattern.compile ("^$"), true));
// the readResolve alphabet thing doesn't kick in on first deserialization
assertTrue (p.getTargetAlphabet () != p2.getTargetAlphabet ());
assertEquals (1, l1.size ());
assertEquals (1, l2.size ());
Instance inst1 = l1.get (0);
Instance inst2 = l2.get (0);
LabelsSequence ls1 = (LabelsSequence) inst1.getTarget ();
LabelsSequence ls2 = (LabelsSequence) inst2.getTarget ();
assertEquals (4, ls1.size ());
assertEquals (4, ls2.size ());
for (int i = 0; i < 4; i++) {
assertEquals (ls1.get (i).toString (), ls2.get (i).toString ());
}
}
开发者ID:mimno,项目名称:GRMM,代码行数:33,代码来源:TestGenericAcrfData2TokenSequence.java
示例7: testFixedNumLabels
import cc.mallet.grmm.learning.GenericAcrfData2TokenSequence; //导入依赖的package包/类
public void testFixedNumLabels () throws IOException, ClassNotFoundException
{
Pipe p = new GenericAcrfData2TokenSequence (2);
InstanceList training = new InstanceList (p);
training.addThruPipe (new LineGroupIterator (new StringReader (sampleFixedData), Pattern.compile ("^$"), true));
assertEquals (1, training.size ());
Instance inst1 = training.get (0);
LabelsSequence ls1 = (LabelsSequence) inst1.getTarget ();
assertEquals (4, ls1.size ());
}
开发者ID:mimno,项目名称:GRMM,代码行数:14,代码来源:TestGenericAcrfData2TokenSequence.java
示例8: main
import cc.mallet.grmm.learning.GenericAcrfData2TokenSequence; //导入依赖的package包/类
public static void main (String[] args) throws FileNotFoundException
{
File trainFile = new File (args[0]);
File testFile = new File (args[1]);
File crfFile = new File (args[2]);
Pipe pipe = new SerialPipes (new Pipe[] {
new GenericAcrfData2TokenSequence (2),
new TokenSequence2FeatureVectorSequence (true, true),
});
InstanceList training = new InstanceList (pipe);
training.addThruPipe (new LineGroupIterator (new FileReader (trainFile),
Pattern.compile ("\\s*"),
true));
InstanceList testing = new InstanceList (pipe);
training.addThruPipe (new LineGroupIterator (new FileReader (testFile),
Pattern.compile ("\\s*"),
true));
ACRF.Template[] tmpls = new ACRF.Template[] {
new ACRF.BigramTemplate (0),
new ACRF.BigramTemplate (1),
new ACRF.PairwiseFactorTemplate (0,1),
new CrossTemplate1 (0,1)
};
ACRF acrf = new ACRF (pipe, tmpls);
ACRFTrainer trainer = new DefaultAcrfTrainer ();
trainer.train (acrf, training, null, testing, 99999);
FileUtils.writeGzippedObject (crfFile, acrf);
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:36,代码来源:SimpleCrfExample.java
示例9: ignoretestFromSerialization
import cc.mallet.grmm.learning.GenericAcrfData2TokenSequence; //导入依赖的package包/类
public void ignoretestFromSerialization () throws IOException, ClassNotFoundException
{
Pipe p = new GenericAcrfData2TokenSequence ();
InstanceList training = new InstanceList (p);
training.addThruPipe (new LineGroupIterator (new StringReader (sampleData), Pattern.compile ("^$"), true));
Pipe p2 = (Pipe) TestSerializable.cloneViaSerialization (p);
InstanceList l1 = new InstanceList (p);
l1.addThruPipe (new LineGroupIterator (new StringReader (sampleData2), Pattern.compile ("^$"), true));
InstanceList l2 = new InstanceList (p2);
l2.addThruPipe (new LineGroupIterator (new StringReader (sampleData2), Pattern.compile ("^$"), true));
// the readResolve alphabet thing doesn't kick in on first deserialization
assertTrue (p.getTargetAlphabet () != p2.getTargetAlphabet ());
assertEquals (1, l1.size ());
assertEquals (1, l2.size ());
Instance inst1 = l1.get (0);
Instance inst2 = l2.get (0);
LabelsSequence ls1 = (LabelsSequence) inst1.getTarget ();
LabelsSequence ls2 = (LabelsSequence) inst2.getTarget ();
assertEquals (4, ls1.size ());
assertEquals (4, ls2.size ());
for (int i = 0; i < 4; i++) {
assertEquals (ls1.get (i).toString (), ls2.get (i).toString ());
}
}
开发者ID:cmoen,项目名称:mallet,代码行数:33,代码来源:TestGenericAcrfData2TokenSequence.java
示例10: ignoretestFixedNumLabels
import cc.mallet.grmm.learning.GenericAcrfData2TokenSequence; //导入依赖的package包/类
public void ignoretestFixedNumLabels () throws IOException, ClassNotFoundException
{
Pipe p = new GenericAcrfData2TokenSequence (2);
InstanceList training = new InstanceList (p);
training.addThruPipe (new LineGroupIterator (new StringReader (sampleFixedData), Pattern.compile ("^$"), true));
assertEquals (1, training.size ());
Instance inst1 = training.get (0);
LabelsSequence ls1 = (LabelsSequence) inst1.getTarget ();
assertEquals (4, ls1.size ());
}
开发者ID:cmoen,项目名称:mallet,代码行数:14,代码来源:TestGenericAcrfData2TokenSequence.java
注:本文中的cc.mallet.grmm.learning.GenericAcrfData2TokenSequence类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论