for (Constituent c : chunk.getConstituentsCoveringToken(tokenId)) {
for (Constituent c : chunk.getConstituentsCoveringToken(tokenId)) {
for (Constituent c : chunk.getConstituentsCoveringToken(tokenId)) {
@Override public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException { lazyLoadClusters(brownClustersFile); if (!ta.hasView(viewGenerator.getViewName())) { synchronized (BrownClusterFeatureExtractor.class) { View view = null; try { view = viewGenerator.getView(ta); } catch (AnnotatorException e) { e.printStackTrace(); throw new EdisonException(e.getMessage()); } ta.addView(viewGenerator.getViewName(), view); } } SpanLabelView view = (SpanLabelView) ta.getView(viewGenerator.getViewName()); String word = ta.getToken(wordPosition); // What follows has a subtle bug: view.getLabel only gets the first // label for the word. A word can have multiple brown clusters though! // This has been fixed below. // String cluster = view.getLabel(wordPosition); // // return getBrownClusters(word, cluster); Set<Feature> features = new LinkedHashSet<>(); for (Constituent c : view.getConstituentsCoveringToken(wordPosition)) { String cluster = c.getLabel(); features.addAll(getBrownClusters(word, cluster)); } return features; }
@Override public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException { lazyLoadClusters(brownClustersFile); if (!ta.hasView(viewGenerator.getViewName())) { synchronized (BrownClusterFeatureExtractor.class) { View view = null; try { view = viewGenerator.getView(ta); } catch (AnnotatorException e) { e.printStackTrace(); throw new EdisonException(e.getMessage()); } ta.addView(viewGenerator.getViewName(), view); } } SpanLabelView view = (SpanLabelView) ta.getView(viewGenerator.getViewName()); String word = ta.getToken(wordPosition); // What follows has a subtle bug: view.getLabel only gets the first // label for the word. A word can have multiple brown clusters though! // This has been fixed below. // String cluster = view.getLabel(wordPosition); // // return getBrownClusters(word, cluster); Set<Feature> features = new LinkedHashSet<>(); for (Constituent c : view.getConstituentsCoveringToken(wordPosition)) { String cluster = c.getLabel(); features.addAll(getBrownClusters(word, cluster)); } return features; }