public ArrayList<Word> yieldWords() { return yieldWords(new ArrayList<>()); }
public static void redoTags(Tree tree, Tagger tagger) { List<Word> words = tree.yieldWords(); List<TaggedWord> tagged = tagger.apply(words); List<Label> tags = tree.preTerminalYield(); if (tags.size() != tagged.size()) { throw new AssertionError("Tags are not the same size"); } for (int i = 0; i < tags.size(); ++i) { tags.get(i).setValue(tagged.get(i).tag()); } }
public ArrayList<Word> yieldWords(ArrayList<Word> y) { if (isLeaf()) { y.add(new Word(label())); } else { for (Tree kid : children()) { kid.yieldWords(y); } } return y; }
static public List<Tree> getTopParsesForOneTree(LexicalizedParser parser, int dvKBest, Tree tree, TreeTransformer transformer) { ParserQuery pq = parser.parserQuery(); List<Word> sentence = tree.yieldWords(); // Since the trees are binarized and otherwise manipulated, we // need to chop off the last word in order to remove the end of // sentence symbol if (sentence.size() <= 1) { return null; } sentence = sentence.subList(0, sentence.size() - 1); if (!pq.parse(sentence)) { log.info("Failed to use the given parser to reparse sentence \"" + sentence + "\""); return null; } List<Tree> parses = new ArrayList<>(); List<ScoredObject<Tree>> bestKParses = pq.getKBestPCFGParses(dvKBest); for (ScoredObject<Tree> so : bestKParses) { Tree result = so.object(); if (transformer != null) { result = transformer.transformTree(result); } parses.add(result); } return parses; }
String subTreeSpanString = StringUtils.joinWords(mentionSubTree.yieldWords(), " "); if (subTreeSpanString.equals(mentionSpanString)) {
/** * Returns the input sentence for the parser. */ private List<CoreLabel> getInputSentence(Tree t) { if (op.testOptions.forceTags) { if (op.testOptions.preTag) { List<TaggedWord> s = tagger.apply(t.yieldWords()); if(op.testOptions.verbose) { log.info("Guess tags: "+Arrays.toString(s.toArray())); log.info("Gold tags: "+t.labeledYield().toString()); } return SentenceUtils.toCoreLabelList(s); } else if(op.testOptions.noFunctionalForcing) { ArrayList<? extends HasWord> s = t.taggedYield(); for (HasWord word : s) { String tag = ((HasTag) word).tag(); tag = tag.split("-")[0]; ((HasTag) word).setTag(tag); } return SentenceUtils.toCoreLabelList(s); } else { return SentenceUtils.toCoreLabelList(t.taggedYield()); } } else { return SentenceUtils.toCoreLabelList(t.yieldWords()); } }
String subTreeSpanString = StringUtils.joinWords(mentionSubTree.yieldWords(), " "); if (subTreeSpanString.equals(mentionSpanString)) {
List<ParseRecord> records = Generics.newArrayList(); for (Tree goldTree : testTreebank) { List<Word> tokens = goldTree.yieldWords(); ParserQuery parserQuery = lexparser.parserQuery(); if (!parserQuery.parse(tokens)) { log.info(subtrees.get(i).first().yieldWords()); log.info(subtrees.get(i).first()); log.info(" MATCHED " + pair.object().second.yieldWords() + " ... " + pair.object().second() + " with a score of " + pair.score());
public ArrayList<Word> yieldWords() { return yieldWords(new ArrayList<>()); }
public ArrayList<Word> yieldWords() { return yieldWords(new ArrayList<Word>()); }
public ArrayList<Word> yieldWords() { return yieldWords(new ArrayList<Word>()); }
public ArrayList<Word> yieldWords() { return yieldWords(new ArrayList<>()); }
public static void redoTags(Tree tree, Tagger tagger) { List<Word> words = tree.yieldWords(); List<TaggedWord> tagged = tagger.apply(words); List<Label> tags = tree.preTerminalYield(); if (tags.size() != tagged.size()) { throw new AssertionError("Tags are not the same size"); } for (int i = 0; i < tags.size(); ++i) { tags.get(i).setValue(tagged.get(i).tag()); } }
public static void redoTags(Tree tree, Tagger tagger) { List<Word> words = tree.yieldWords(); List<TaggedWord> tagged = tagger.apply(words); List<Label> tags = tree.preTerminalYield(); if (tags.size() != tagged.size()) { throw new AssertionError("Tags are not the same size"); } for (int i = 0; i < tags.size(); ++i) { tags.get(i).setValue(tagged.get(i).tag()); } }
public static void redoTags(Tree tree, Tagger tagger) { List<Word> words = tree.yieldWords(); List<TaggedWord> tagged = tagger.apply(words); List<Label> tags = tree.preTerminalYield(); if (tags.size() != tagged.size()) { throw new AssertionError("Tags are not the same size"); } for (int i = 0; i < tags.size(); ++i) { tags.get(i).setValue(tagged.get(i).tag()); } }
static public List<Tree> getTopParsesForOneTree(LexicalizedParser parser, int dvKBest, Tree tree, TreeTransformer transformer) { ParserQuery pq = parser.parserQuery(); List<Word> sentence = tree.yieldWords(); // Since the trees are binarized and otherwise manipulated, we // need to chop off the last word in order to remove the end of // sentence symbol if (sentence.size() <= 1) { return null; } sentence = sentence.subList(0, sentence.size() - 1); if (!pq.parse(sentence)) { System.err.println("Failed to use the given parser to reparse sentence \"" + sentence + "\""); return null; } List<Tree> parses = new ArrayList<Tree>(); List<ScoredObject<Tree>> bestKParses = pq.getKBestPCFGParses(dvKBest); for (ScoredObject<Tree> so : bestKParses) { Tree result = so.object(); if (transformer != null) { result = transformer.transformTree(result); } parses.add(result); } return parses; }
public ArrayList<Word> yieldWords(ArrayList<Word> y) { if (isLeaf()) { y.add(new Word(label())); } else { for (Tree kid : children()) { kid.yieldWords(y); } } return y; }
public ArrayList<Word> yieldWords(ArrayList<Word> y) { if (isLeaf()) { y.add(new Word(label())); } else { for (Tree kid : children()) { kid.yieldWords(y); } } return y; }
public ArrayList<Word> yieldWords(ArrayList<Word> y) { if (isLeaf()) { y.add(new Word(label())); } else { for (Tree kid : children()) { kid.yieldWords(y); } } return y; }
/** * Returns the input sentence for the parser. */ private List<CoreLabel> getInputSentence(Tree t) { if (op.testOptions.forceTags) { if (op.testOptions.preTag) { List<TaggedWord> s = tagger.apply(t.yieldWords()); if(op.testOptions.verbose) { log.info("Guess tags: "+Arrays.toString(s.toArray())); log.info("Gold tags: "+t.labeledYield().toString()); } return SentenceUtils.toCoreLabelList(s); } else if(op.testOptions.noFunctionalForcing) { ArrayList<? extends HasWord> s = t.taggedYield(); for (HasWord word : s) { String tag = ((HasTag) word).tag(); tag = tag.split("-")[0]; ((HasTag) word).setTag(tag); } return SentenceUtils.toCoreLabelList(s); } else { return SentenceUtils.toCoreLabelList(t.taggedYield()); } } else { return SentenceUtils.toCoreLabelList(t.yieldWords()); } }