private void addPOSView(List<String> pos, TextAnnotation ta) { // POS View TokenLabelView posView = new TokenLabelView(ViewNames.POS, "GoldStandard", ta, 1.0); for (int j = 0; j < pos.size(); j++) posView.addTokenLabel(j, pos.get(j), 1.0); ta.addView(ViewNames.POS, posView); }
private void populateTokenLabelView(TextAnnotation ta, List<String> tags, String viewName) { TokenLabelView v = new TokenLabelView(viewName, ta); for (int tkid = 0; tkid < tags.size(); tkid++) v.addTokenLabel(tkid, tags.get(tkid), 1.0D); ta.addView(viewName, v); }
private void addPOSView(List<String> pos, TextAnnotation ta) { // POS View TokenLabelView posView = new TokenLabelView(ViewNames.POS, "GoldStandard", ta, 1.0); for (int j = 0; j < pos.size(); j++) posView.addTokenLabel(j, pos.get(j), 1.0); ta.addView(ViewNames.POS, posView); }
private void populateTokenLabelView(TextAnnotation ta, List<String> tags, String viewName) { TokenLabelView v = new TokenLabelView(viewName, ta); for (int tkid = 0; tkid < tags.size(); tkid++) v.addTokenLabel(tkid, tags.get(tkid), 1.0D); ta.addView(viewName, v); }
private void addView(TextAnnotation ta, List<String> labels) { TokenLabelView labelView = new TokenLabelView(viewName, ta); List constituents = ta.getView(ViewNames.TOKENS).getConstituents(); assert constituents.size() == labels.size(); for (int i = 0; i < constituents.size(); ++i) { Constituent constituent = (Constituent) constituents.get(i); labelView.addTokenLabel(constituent.getStartSpan(), labels.get(i), 1.0D); } ta.addView(viewName, labelView); }
protected void addGoldPOSView(TextAnnotation ta, List<String> sentencePOS) { TokenLabelView posView = new TokenLabelView(ViewNames.POS, ta); List<Constituent> constituents = ta.getView(ViewNames.TOKENS).getConstituents(); assert constituents.size() == sentencePOS.size(); for (int i = 0; i < constituents.size(); ++i) { Constituent constituent = (Constituent) constituents.get(i); posView.addTokenLabel(constituent.getStartSpan(), sentencePOS.get(i), 1.0D); } ta.addView(ViewNames.POS, posView); }
protected void addGoldPOSView(TextAnnotation ta, List<String> sentencePOS) { TokenLabelView posView = new TokenLabelView(ViewNames.POS, ta); List constituents = ta.getView(ViewNames.TOKENS).getConstituents(); assert constituents.size() == sentencePOS.size(); for (int i = 0; i < constituents.size(); ++i) { Constituent constituent = (Constituent) constituents.get(i); posView.addTokenLabel(constituent.getStartSpan(), sentencePOS.get(i), 1.0D); } ta.addView(ViewNames.POS, posView); }
protected void addGoldPOSView(TextAnnotation ta, List<String> sentencePOS) { TokenLabelView posView = new TokenLabelView(ViewNames.POS, ta); List<Constituent> constituents = ta.getView(ViewNames.TOKENS).getConstituents(); assert constituents.size() == sentencePOS.size(); for (int i = 0; i < constituents.size(); ++i) { Constituent constituent = (Constituent) constituents.get(i); posView.addTokenLabel(constituent.getStartSpan(), sentencePOS.get(i), 1.0D); } ta.addView(ViewNames.POS, posView); }
protected void addGoldView(TextAnnotation ta, List<String> labels) { TokenLabelView posView = new TokenLabelView(viewName, ta); List<Constituent> constituents = ta.getView(ViewNames.TOKENS).getConstituents(); for (int i = 0; i < constituents.size(); ++i) { Constituent constituent = (Constituent) constituents.get(i); posView.addTokenLabel(constituent.getStartSpan(), labels.get(i), 1.0D); } ta.addView(viewName, posView); } }
protected void addGoldView(TextAnnotation ta, List<String> labels) { TokenLabelView posView = new TokenLabelView(viewName, ta); List<Constituent> constituents = ta.getView(ViewNames.TOKENS).getConstituents(); for (int i = 0; i < constituents.size(); ++i) { Constituent constituent = (Constituent) constituents.get(i); posView.addTokenLabel(constituent.getStartSpan(), labels.get(i), 1.0D); } ta.addView(viewName, posView); } }
/** * Helper for create a TokenLabelView from a stream of token labels */ private static int createTokenLabelView( Stream<Pair<Integer, String>> tokenLabels, TextAnnotation ta, String viewName) { TokenLabelView view = new TokenLabelView(viewName, "GoldStandard", ta, 1.0); tokenLabels.forEach(label -> view.addTokenLabel(label.getFirst(), label.getSecond(), 1.0)); ta.addView(viewName, view); return view.count(); }
/** * Helper for create a TokenLabelView from a stream of token labels */ private static int createTokenLabelView( Stream<Pair<Integer, String>> tokenLabels, TextAnnotation ta, String viewName) { TokenLabelView view = new TokenLabelView(viewName, "GoldStandard", ta, 1.0); tokenLabels.forEach(label -> view.addTokenLabel(label.getFirst(), label.getSecond(), 1.0)); ta.addView(viewName, view); return view.count(); }
@Override public void addView(TextAnnotation ta) { TokenLabelView view = new TokenLabelView(getViewName(), "WordNet", ta, 1.0); for (int i = 0; i < ta.size(); i++) { String word = ta.getToken(i).toLowerCase().trim(); POS wnPOS = WordNetHelper.getWNPOS(WordHelpers.getPOS(ta, i)); String lemma; if (wnPOS == null) lemma = ta.getToken(i); else { try { lemma = wn.getLemma(word, wnPOS); } catch (JWNLException e) { lemma = ta.getToken(i); } } view.addTokenLabel(i, lemma, 1.0); } ta.addView(getViewName(), view); }
@Override public void addView(TextAnnotation ta) { TokenLabelView posView = new TokenLabelView(ViewNames.POS, "ParsePOS", ta, 1.0); int tokenId = 0; for (int sentenceId = 0; sentenceId < ta.getNumberOfSentences(); sentenceId++) { Tree<String> parseTree = ((TreeView) (ta.getView(parseViewName))).getTree(sentenceId); parseTree = ParseUtils.snipNullNodes(parseTree); parseTree = ParseUtils.stripFunctionTags(parseTree); if (parseTree.getYield().size() != ta.getSentence(sentenceId).size()) { Sentence s = ta.getSentence(sentenceId); System.err.println(":"+s+":"); List<Tree<String>> tree = parseTree.getYield(); System.err.println("-"+tree+"-"); throw new IllegalStateException("Parse tree size != ta.size()"); } for (Tree<String> y : parseTree.getYield()) { posView.addTokenLabel(tokenId++, y.getParent().getLabel(), 1.0); } } ta.addView(getViewName(), posView); // return posView; }
public TokenLabelView getView(SenseManager manager, TextAnnotation ta) { String viewName = SenseManager.getPredictedViewName(); TokenLabelView view = new TokenLabelView(viewName, VerbSenseConstants.systemIdentifier, ta, 1.0); for (SenseStructure y : this.ys) { SenseInstance senseInstance = y.getInstance(); IntPair predicateSpan = senseInstance.getConstituent().getSpan(); String sense = manager.getSense(y.getLabel()); view.addTokenLabel(predicateSpan.getFirst(), sense, 1.0); } return view; } }
public TokenLabelView getView(SenseManager manager, TextAnnotation ta) { String viewName = SenseManager.getPredictedViewName(); TokenLabelView view = new TokenLabelView(viewName, VerbSenseConstants.systemIdentifier, ta, 1.0); for (SenseStructure y : this.ys) { SenseInstance senseInstance = y.getInstance(); IntPair predicateSpan = senseInstance.getConstituent().getSpan(); String sense = manager.getSense(y.getLabel()); view.addTokenLabel(predicateSpan.getFirst(), sense, 1.0); } return view; } }
@Override public void addView(TextAnnotation ta) { TokenLabelView posView = new TokenLabelView(ViewNames.POS, "ParsePOS", ta, 1.0); int tokenId = 0; for (int sentenceId = 0; sentenceId < ta.getNumberOfSentences(); sentenceId++) { Tree<String> parseTree = ((TreeView) (ta.getView(parseViewName))).getTree(sentenceId); parseTree = ParseUtils.snipNullNodes(parseTree); parseTree = ParseUtils.stripFunctionTags(parseTree); if (parseTree.getYield().size() != ta.getSentence(sentenceId).size()) throw new IllegalStateException("Parse tree size != ta.size()"); for (Tree<String> y : parseTree.getYield()) { posView.addTokenLabel(tokenId++, y.getParent().getLabel(), 1.0); } } ta.addView(getViewName(), posView); }
@Override public void addView(TextAnnotation ta) { TokenLabelView posView = new TokenLabelView(ViewNames.POS, "ParsePOS", ta, 1.0); int tokenId = 0; for (int sentenceId = 0; sentenceId < ta.getNumberOfSentences(); sentenceId++) { Tree<String> parseTree = ((TreeView) (ta.getView(parseViewName))).getTree(sentenceId); parseTree = ParseUtils.snipNullNodes(parseTree); parseTree = ParseUtils.stripFunctionTags(parseTree); if (parseTree.getYield().size() != ta.getSentence(sentenceId).size()) throw new IllegalStateException("Parse tree size != ta.size()"); for (Tree<String> y : parseTree.getYield()) { posView.addTokenLabel(tokenId++, y.getParent().getLabel(), 1.0); } } ta.addView(getViewName(), posView); }
@Override public void addView(TextAnnotation input) { TokenLabelView view = new TokenLabelView(getViewName(), "PorterStemmer", input, 1.0); synchronized (instance) { for (int i = 0; i < input.size(); i++) { stemmer.setCurrent(input.getToken(i)); stemmer.stem(); view.addTokenLabel(i, stemmer.getCurrent(), 1.0); } } input.addView(getViewName(), view); }
@Override public void addView(TextAnnotation input) { TokenLabelView view = new TokenLabelView(getViewName(), "PorterStemmer", input, 1.0); synchronized (instance) { for (int i = 0; i < input.size(); i++) { stemmer.setCurrent(input.getToken(i)); stemmer.stem(); view.addTokenLabel(i, stemmer.getCurrent(), 1.0); } } input.addView(getViewName(), view); }