public FeatureConjunction (Alphabet dictionary, int[] features, boolean[] negations) { this (getName (dictionary, features, negations), dictionary, features, negations, true); }
public FeatureConjunction (Alphabet dictionary, int[] features) { this (getName (dictionary, features, null), dictionary, features, null, true, true, false); }
public static String getName (Alphabet dictionary, int feature1, int feature2) { if (feature1 < feature2) return getName (dictionary, new int[] {feature1, feature2}); else return getName (dictionary, new int[] {feature2, feature1}); //assert (feature1 != feature2); //String string1 = dictionary.lookupObject(feature1).toString(); //String string2 = dictionary.lookupObject(feature2).toString(); //if (feature1 < feature2) //return string1 + conjunctionString + string2; //else //return string2 + conjunctionString + string1; }
public static String getName (Alphabet dictionary, int[] features, boolean[] negations) { if (true) { if (negations != null) for (int i = 0; i < negations.length; i++) if (negations[i]) throw new UnsupportedOperationException ("Doesn't yet check for sub-duplicates with negations."); return getName (dictionary, features); } // Split apart any feature[i] that is itself a conjunction feature //int[] featureIndices = getFeatureIndices (dictionary, dictionary.lookupObject( // xxx Add code here to do the sorting... // Make sure the the features area sorted for (int i = 1; i < features.length; i++) if (features[i-1] >= features[i]) throw new IllegalArgumentException ("feature index not sorted, or contains duplicate"); StringBuffer sb = new StringBuffer (); for (int i = 0; i < features.length; i++) { if (i > 0) sb.append (conjunctionString); if (negations != null && negations[i]) sb.append (negationString); sb.append (dictionary.lookupObject(features[i]).toString()); } return sb.toString(); }
for (int j = 0; j < fv.indices.length; j++) { if (conjunctions[ci] != fv.indices[j]) { int index = newVocab.lookupIndex (FeatureConjunction.getName (v, conjunctions[ci], fv.indices[j])); if (index == newVocab.size()-1 && index % 3 == 0) logger.info ("New feature "+ newVocab.lookupObject(index));
int index = newVocab.lookupIndex (FeatureConjunction.getName (v, fv.indices[i], fv.indices[j])); if (index != -1) // this can be -1 if newVocab.growthStopped newIndices[size++] = index;