@Test public void testCreateFex() throws Exception { FeatureManifest featureManifest = new FeatureManifest(file); featureManifest.useCompressedName(); featureManifest.setVariable("*default-parser*", ViewNames.PARSE_STANFORD); FeatureExtractor fex = featureManifest.createFex(); Constituent c = tas.get(0).getView(ViewNames.TOKENS).getConstituents().get(0); assertEquals("My", c.getSurfaceForm()); Set<Feature> features = fex.getFeatures(c); Iterator<Feature> iterator = features.iterator(); Feature feature = iterator.next(); assertEquals("f:#ctxt#:context1::#wd:mother-in-law", feature.getName()); }
private FeatureExtractor createFex(Tree<String> tree, Map<String, FeatureExtractor> cf) throws EdisonException { String label = tree.getLabel(); if (tree.isLeaf()) { if (label.startsWith("wn")) return getWordNetFeatureExtractor(Collections.singletonList(label), cf); else if (cf.containsKey(definition(label))) return cf.get(definition(label)); else return getLeafFeature(label, cf); } else if (label.equals("list")) return processList(tree, cf); else if (label.equals("conjoin")) return processConjunction(tree, cf); else if (ParameterizedFeatureExtractors.fexes.containsKey(label)) return getParameterizedFex(tree, cf); else if (label.equals("conjoin-and-include")) return processIncludeWithPrefix(tree, cf); else if (label.equals("bigram")) return bigrams(tree, cf); else if (label.equals("trigram")) return trigrams(tree, cf); else if (label.equals("define")) throw new EdisonException("'define' can only be a top level statement " + "or at the beginning of a feature descriptor\n" + tree); else if (label.equals("transform-input")) return processTransform(tree, cf); else if (label.equals("if")) return processQuery(tree, cf); else throw new EdisonException("Invalid feature description: " + tree); }
FeatureManifest { private FeatureExtractor createFex(Tree<String> tree, Map<String, FeatureExtractor> cf) throws EdisonException { String label = tree.getLabel(); if (tree.isLeaf()) { if (label.startsWith("wn")) return getWordNetFeatureExtractor(Collections.singletonList(label), cf); else if (cf.containsKey(definition(label))) return cf.get(definition(label)); else return getLeafFeature(label, cf); } else if (label.equals("list")) return processList(tree, cf); else if (label.equals("conjoin")) return processConjunction(tree, cf); else if (ParameterizedFeatureExtractors.fexes.containsKey(label)) return getParameterizedFex(tree, cf); else if (label.equals("conjoin-and-include")) return processIncludeWithPrefix(tree, cf); else if (label.equals("bigram")) return bigrams(tree, cf); else if (label.equals("trigram")) return trigrams(tree, cf); else if (label.equals("define")) throw new EdisonException("'define' can only be a top level statement " + "or at the beginning of a feature descriptor\n" + tree); else if (label.equals("transform-input")) return processTransform(tree, cf); else if (label.equals("if")) return processQuery(tree, cf); else throw new EdisonException("Invalid feature description: " + tree); } }
FeatureManifest { private FeatureExtractor createFex(Tree<String> tree, Map<String, FeatureExtractor> cf) throws EdisonException { String label = tree.getLabel(); if (tree.isLeaf()) { if (label.startsWith("wn")) return getWordNetFeatureExtractor(Collections.singletonList(label), cf); else if (cf.containsKey(definition(label))) return cf.get(definition(label)); else return getLeafFeature(label, cf); } else if (label.equals("list")) return processList(tree, cf); else if (label.equals("conjoin")) return processConjunction(tree, cf); else if (ParameterizedFeatureExtractors.fexes.containsKey(label)) return getParameterizedFex(tree, cf); else if (label.equals("conjoin-and-include")) return processIncludeWithPrefix(tree, cf); else if (label.equals("bigram")) return bigrams(tree, cf); else if (label.equals("trigram")) return trigrams(tree, cf); else if (label.equals("define")) throw new EdisonException("'define' can only be a top level statement " + "or at the beginning of a feature descriptor\n" + tree); else if (label.equals("transform-input")) return processTransform(tree, cf); else if (label.equals("if")) return processQuery(tree, cf); else throw new EdisonException("Invalid feature description: " + tree); } FeatureManifest(String path);  FeatureManifest(InputStream file); }
FeatureManifest { private FeatureExtractor createFex(Tree<String> tree, Map<String, FeatureExtractor> cf) throws EdisonException { String label = tree.getLabel(); if (tree.isLeaf()) { if (label.startsWith("wn")) return getWordNetFeatureExtractor(Collections.singletonList(label), cf); else if (cf.containsKey(definition(label))) return cf.get(definition(label)); else return getLeafFeature(label, cf); } else if (label.equals("list")) return processList(tree, cf); else if (label.equals("conjoin")) return processConjunction(tree, cf); else if (ParameterizedFeatureExtractors.fexes.containsKey(label)) return getParameterizedFex(tree, cf); else if (label.equals("conjoin-and-include")) return processIncludeWithPrefix(tree, cf); else if (label.equals("bigram")) return bigrams(tree, cf); else if (label.equals("trigram")) return trigrams(tree, cf); else if (label.equals("define")) throw new EdisonException("'define' can only be a top level statement " + "or at the beginning of a feature descriptor\n" + tree); else if (label.equals("transform-input")) return processTransform(tree, cf); else if (label.equals("if")) return processQuery(tree, cf); else throw new EdisonException("Invalid feature description: " + tree); } FeatureManifest(String path);  FeatureManifest(InputStream file); static void setFeatureExtractor(String name, FeatureExtractor fex); static void setTransformer(String name, FeatureInputTransformer t); static Set<String> getKnownFeatureExtractors(); void setVariable(String key, String value); FeatureExtractor createFex(); FeatureExtractor createFex(FeatureInputTransformer transformer); FeatureExtractor processQuery(Tree<String> tree, Map<String, FeatureExtractor> cf); String getIncludedFeatures(); void useCompressedName(); }
FeatureManifest { private FeatureExtractor createFex(Tree<String> tree, Map<String, FeatureExtractor> cf) throws EdisonException { String label = tree.getLabel(); if (tree.isLeaf()) { if (label.startsWith("wn")) return getWordNetFeatureExtractor(Collections.singletonList(label), cf); else if (cf.containsKey(definition(label))) return cf.get(definition(label)); else return getLeafFeature(label, cf); } else if (label.equals("list")) return processList(tree, cf); else if (label.equals("conjoin")) return processConjunction(tree, cf); else if (ParameterizedFeatureExtractors.fexes.containsKey(label)) return getParameterizedFex(tree, cf); else if (label.equals("conjoin-and-include")) return processIncludeWithPrefix(tree, cf); else if (label.equals("bigram")) return bigrams(tree, cf); else if (label.equals("trigram")) return trigrams(tree, cf); else if (label.equals("define")) throw new EdisonException("'define' can only be a top level statement " + "or at the beginning of a feature descriptor\n" + tree); else if (label.equals("transform-input")) return processTransform(tree, cf); else if (label.equals("if")) return processQuery(tree, cf); else throw new EdisonException("Invalid feature description: " + tree); } FeatureManifest(String path);  FeatureManifest(InputStream file); static void setFeatureExtractor(String name, FeatureExtractor fex); static void setTransformer(String name, FeatureInputTransformer t); static Set<String> getKnownFeatureExtractors(); void setVariable(String key, String value); FeatureExtractor createFex(); FeatureExtractor createFex(FeatureInputTransformer transformer); FeatureExtractor processQuery(Tree<String> tree, Map<String, FeatureExtractor> cf); String getIncludedFeatures(); void useCompressedName();  }