622623624625626627628629
// (These were commented before...) // {-2,-1}, {-1,0}, {0,1}, {1,2}, // {-3,-2,-1}, {-2,-1,0}, {-1,0,1}, {0,1,2}, {1,2,3}, }), // new PrintInputAndTarget(), new TokenSequence2FeatureVectorSequence() }); return p; }
872873874875876877878879880881882
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);
894895896897898899900901902903904
public void testCopyStatesAndWeights() { 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);
940941942943944945946947948949950
Pipe p = new SerialPipes(new Pipe[] { new LineGroupString2TokenSequence(), new TokenSequenceMatchDataAndTarget(Pattern .compile("^(\\S+) (.*)"), 2, 1), new TokenSequenceParseFeatureString(false), new TokenText(), new TokenSequence2FeatureVectorSequence(true, false), new Target2LabelSequence(), new PrintInputAndTarget(), }); InstanceList data = new InstanceList(p); data.addThruPipe(new LineGroupIterator(new StringReader(toy), Pattern .compile("\n"), true));
481482483484485486487488489
// {-2, -1, 0}, {0, 1, 2}, {-3, -2, -1}, {1, 2, 3}, //{-2,-1}, {-1,0}, {0,1}, {1,2}, //{-3,-2,-1}, {-2,-1,0}, {-1,0,1}, {0,1,2}, {1,2,3}, }), // new PrintInputAndTarget(), new TokenSequence2FeatureVectorSequence() }); return p; }
595596597598599600601602603604605
{ 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));
3435363738394041424344
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*"),