/** * Create a Pipe for adding conjunctions of specified features. * @param thisFeatureName Name of this conjunction feature. * @param featureNames String giving name for each subfeature i. * @param offsets For each subfeature i, which offset from the current timestep * must i appear at. * @param isNonNegated If element i is false, then the negation of the * feature is added to the conjuction. */ public OffsetFeatureConjunction (String thisFeatureName, String[] featureNames, int[] offsets, boolean[] isNonNegated, boolean tagAllTimesteps) { this.thisFeatureName = thisFeatureName; this.featurePatterns = patternify (featureNames); this.offsets = offsets; this.isNonNegated = isNonNegated; this.tagAllTimesteps = tagAllTimesteps; }
public OffsetFeatureConjunction (String thisFeatureName, String[] featureNames, int[] offsets, boolean tagAllTimesteps) { this (thisFeatureName, featureNames, offsets, trueArray(featureNames.length), tagAllTimesteps); }
break; boolean featurePresent = hasMatchingFeature (ts.get(pos), featurePatterns [fnum]); if (featurePresent != isNonNegated [fnum]) { passes = false;
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); }
break; boolean featurePresent = hasMatchingFeature (ts.get(pos), featurePatterns [fnum]); if (featurePresent != isNonNegated [fnum]) { passes = false;
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); }
public OffsetFeatureConjunction (String thisFeatureName, String[] featureNames, int[] offsets) { this (thisFeatureName, featureNames, offsets, trueArray(featureNames.length), false); }
/** * Create a Pipe for adding conjunctions of specified features. * @param thisFeatureName Name of this conjunction feature. * @param featureNames String giving name for each subfeature i. * @param offsets For each subfeature i, which offset from the current timestep * must i appear at. * @param isNonNegated If element i is false, then the negation of the * feature is added to the conjuction. */ public OffsetFeatureConjunction (String thisFeatureName, String[] featureNames, int[] offsets, boolean[] isNonNegated, boolean tagAllTimesteps) { this.thisFeatureName = thisFeatureName; this.featurePatterns = patternify (featureNames); this.offsets = offsets; this.isNonNegated = isNonNegated; this.tagAllTimesteps = tagAllTimesteps; }
break; boolean featurePresent = hasMatchingFeature (ts.get(pos), featurePatterns [fnum]); if (featurePresent != isNonNegated [fnum]) { passes = false;
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 }, 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 },
public OffsetFeatureConjunction (String thisFeatureName, String[] featureNames, int[] offsets, boolean tagAllTimesteps) { this (thisFeatureName, featureNames, offsets, trueArray(featureNames.length), tagAllTimesteps); }
/** * Create a Pipe for adding conjunctions of specified features. * @param thisFeatureName Name of this conjunction feature. * @param featureNames String giving name for each subfeature i. * @param offsets For each subfeature i, which offset from the current timestep * must i appear at. * @param isNonNegated If element i is false, then the negation of the * feature is added to the conjuction. */ public OffsetFeatureConjunction (String thisFeatureName, String[] featureNames, int[] offsets, boolean[] isNonNegated, boolean tagAllTimesteps) { this.thisFeatureName = thisFeatureName; this.featurePatterns = patternify (featureNames); this.offsets = offsets; this.isNonNegated = isNonNegated; this.tagAllTimesteps = tagAllTimesteps; }
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 }, 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 },
public OffsetFeatureConjunction (String thisFeatureName, String[] featureNames, int[] offsets, boolean tagAllTimesteps) { this (thisFeatureName, featureNames, offsets, trueArray(featureNames.length), tagAllTimesteps); }
public OffsetFeatureConjunction (String thisFeatureName, String[] featureNames, int[] offsets) { this (thisFeatureName, featureNames, offsets, trueArray(featureNames.length), false); }
public OffsetFeatureConjunction (String thisFeatureName, String[] featureNames, int[] offsets) { this (thisFeatureName, featureNames, offsets, trueArray(featureNames.length), false); }