/** * Gets the preterminal yield (i.e., tags) of the tree. All data in * preterminal nodes is returned as a list ordered by the natural left to * right order of the tree. Null values, if any, are inserted into the * list like any other value. Pre-leaves are nodes of height 1. * * @return a {@code List} of the data in the tree's pre-leaves. */ public List<Label> preTerminalYield() { return preTerminalYield(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()); } }
/** * Converts a tree to the Morfette training format. */ private static String treeToMorfette(Tree tree) { StringBuilder sb = new StringBuilder(); List<Label> yield = tree.yield(); List<Label> tagYield = tree.preTerminalYield(); assert yield.size() == tagYield.size(); int listLen = yield.size(); for (int i = 0; i < listLen; ++i) { CoreLabel token = (CoreLabel) yield.get(i); CoreLabel tag = (CoreLabel) tagYield.get(i); String morphStr = token.originalText(); if (morphStr == null || morphStr.equals("")) { morphStr = tag.value(); } String lemma = token.lemma(); if (lemma == null || lemma.equals("")) { lemma = token.value(); } sb.append(String.format("%s %s %s%n", token.value(), lemma, morphStr)); } return sb.toString(); }
/** * Gets the preterminal yield (i.e., tags) of the tree. All data in * preleaf nodes is returned as a list ordered by the natural left to * right order of the tree. Null values, if any, are inserted into the * list like any other value. Pre-leaves are nodes of height 1. * * @param y The list in which the preterminals of the tree will be * placed. Normally, this will be empty when the routine is called, * but if not, the new yield is added to the end of the list. * @return a {@code List} of the data in the tree's pre-leaves. */ public List<Label> preTerminalYield(List<Label> y) { if (isPreTerminal()) { y.add(label()); } else { Tree[] kids = children(); for (Tree kid : kids) { kid.preTerminalYield(y); } } return y; }
List<Label> pretermYield = tree1.preTerminalYield(); List<Label> yield = tree1.yield(); int yieldLen = yield.size();
private static void replacePOSTags(Tree tree) { List<Label> yield = tree.yield(); List<Label> preYield = tree.preTerminalYield(); assert yield.size() == preYield.size(); MorphoFeatureSpecification spec = new FrenchMorphoFeatureSpecification(); for(int i = 0; i < yield.size(); i++) { // Morphological Analysis String morphStr = ((CoreLabel) yield.get(i)).originalText(); if (morphStr == null || morphStr.equals("")) { morphStr = preYield.get(i).value(); // POS subcategory String subCat = ((CoreLabel) yield.get(i)).category(); if (subCat != null && subCat != "") { morphStr += "-" + subCat + "--"; } else { morphStr += "---"; } } MorphoFeatures feats = spec.strToFeatures(morphStr); if(feats.getAltTag() != null && !feats.getAltTag().equals("")) { CoreLabel cl = (CoreLabel) preYield.get(i); cl.setValue(feats.getAltTag()); cl.setTag(feats.getAltTag()); } } }
List<Label> tags = kid.preTerminalYield(); for (Label tag : tags) { if (tag.value().equals("EX")) { List<Label> tags = kid.preTerminalYield(); for (Label tag : tags) { if (tag.value().equals("EX")) {
List<Label> tags = kid.preTerminalYield(); for (Label tag : tags) { if (tag.value().equals("EX")) { List<Label> tags = kid.preTerminalYield(); for (Label tag : tags) { if (tag.value().equals("EX")) {
uposLabels = uposTree.preTerminalYield(); } else { uposLabels = tree.preTerminalYield();
for (Tree tree : treebank) { List<Label> yield = tree.yield(); List<Label> preterm = tree.preTerminalYield(); assert yield.size() == preterm.size(); int yieldLen = yield.size();
pw.println(SentenceUtils.listToString(gold.preTerminalYield())); pw.println(SentenceUtils.listToString(gold.yield())); gold.pennPrint(pw); pw.println(tree.preTerminalYield()); pw.println(tree.yield()); tree.pennPrint(pw);
pw.println(SentenceUtils.listToString(tree.preTerminalYield()));
List<Label> uPOSTags = t.preTerminalYield(); List<IndexedWord> yield = sg.vertexListSorted();
List<Label> pretermList = tree.preTerminalYield(); List<Label> yield = tree.yield(); assert yield.size() == pretermList.size();
List<Label> uposLabels = uposTree.preTerminalYield(); for (IndexedWord token: sg.vertexListSorted()) { int idx = token.index() - 1;
if (hasV(t.preTerminalYield()) && ! baseCat.equals("WHPP") && ! baseCat.equals("RRC") && ! baseCat.equals("QP") && ! baseCat.equals("PRT")) { if (hasV(t.preTerminalYield())) { cat = cat + "-v"; if (englishTrain.dominatesI && hasI(t.preTerminalYield())) { cat = cat + "-i"; if (englishTrain.dominatesC && hasC(t.preTerminalYield())) { cat = cat + "-c";
List<Label> pretermYield = tree.preTerminalYield();
if (dominatesV && hasV(t.preTerminalYield())) {
static public void countMWEStatistics(Tree t, TwoDimensionalCounter<String, String> unigramTagger, TwoDimensionalCounter<String, String> labelPreterm, TwoDimensionalCounter<String, String> pretermLabel, TwoDimensionalCounter<String, String> labelTerm, TwoDimensionalCounter<String, String> termLabel) { updateTagger(unigramTagger,t); //Count MWE statistics TregexMatcher m = pMWE.matcher(t); while (m.findNextMatchingNode()) { Tree match = m.getMatch(); String label = match.value(); if(RESOLVE_DUMMY_TAGS && label.equals(FrenchXMLTreeReader.MISSING_PHRASAL)) continue; String preterm = SentenceUtils.listToString(match.preTerminalYield()); String term = SentenceUtils.listToString(match.yield()); labelPreterm.incrementCount(label,preterm); pretermLabel.incrementCount(preterm,label); labelTerm.incrementCount(label,term); termLabel.incrementCount(term, label); } }
/** * Gets the preterminal yield (i.e., tags) of the tree. All data in * preterminal nodes is returned as a list ordered by the natural left to * right order of the tree. Null values, if any, are inserted into the * list like any other value. Pre-leaves are nodes of height 1. * * @return a {@code List} of the data in the tree's pre-leaves. */ public List<Label> preTerminalYield() { return preTerminalYield(new ArrayList<>()); }