/** * Make a new label with this <code>String</code> as the value. * This implementation ignores the options * * @param labelStr The String that will be used for balue * @param options This argument is ignored * @return The newly created Label */ public Label newLabel(String labelStr, int options) { return new CategoryWordTag(labelStr); }
/** * Create a new <code>CategoryWordTag Label</code>, where the label is * formed from * the <code>Label</code> object passed in. Depending on what fields * each label has, other things will be <code>null</code>. * * @param oldLabel The Label that the new label is being created from * @return a new label of a particular type */ public Label newLabel(Label oldLabel) { return new CategoryWordTag(oldLabel); }
/** * Make a new label with this <code>String</code> as the "name". * * @param labelStr The string to use as a label * @return The newly created Label */ public Label newLabel(String labelStr) { return new CategoryWordTag(labelStr); }
/** * Create a new CategoryWordTag label, where the label is formed from * the various <code>String</code> objects passed in. * * @param word The word part of the label * @param tag The tag part of the label * @param category The category part of the label * @return The newly created Label */ public Label newLabel(String word, String tag, String category) { // System.out.println("Making new CWT label: " + category + " | " + // word + " | " + tag); return new CategoryWordTag(category, word, tag); }
/** * Make a new label with this <code>String</code> as the "name". * * @param labelStr The string to use as a label * @return The newly created Label */ public Label newLabelFromString(String labelStr) { CategoryWordTag cwt = new CategoryWordTag(); cwt.setFromString(labelStr); return cwt; }
/** * Changes the ROOT label, and adds a Lexicon.BOUNDARY daughter to it. * This is needed for the dependency parser. * <i>Note:</i> This is a destructive operation on the tree passed in!! * * @param t The current tree into which a boundary is inserted */ public void addRoot(Tree t) { if (t.isLeaf()) { log.info("Warning: tree is leaf: " + t); t = tf.newTreeNode(tlp.startSymbol(), Collections.singletonList(t)); } t.setLabel(new CategoryWordTag(tlp.startSymbol(), Lexicon.BOUNDARY, Lexicon.BOUNDARY_TAG)); List<Tree> preTermChildList = new ArrayList<>(); Tree boundaryTerm = tf.newLeaf(new Word(Lexicon.BOUNDARY));//CategoryWordTag(Lexicon.BOUNDARY,Lexicon.BOUNDARY,"")); preTermChildList.add(boundaryTerm); Tree boundaryPreTerm = tf.newTreeNode(new CategoryWordTag(Lexicon.BOUNDARY_TAG, Lexicon.BOUNDARY, Lexicon.BOUNDARY_TAG), preTermChildList); List<Tree> childList = t.getChildrenAsList(); childList.add(boundaryPreTerm); t.setChildren(childList); }
/** * Do nothing other than decorate the label with @ */ private static Label makeSimpleSyntheticLabel(Tree t) { String topCat = t.label().value(); String labelStr = '@' + topCat; String word = ((HasWord) t.label()).word(); String tag = ((HasTag) t.label()).tag(); return new CategoryWordTag(labelStr, word, tag); }
String tag = tagIndex.get(edge.tag); String state = stateIndex.get(edge.state); Label label = new CategoryWordTag(state, head, tag); if (edge.backEdge == null && edge.backHook == null) {
return tf.newTreeNode(new CategoryWordTag(finalCat, word, tag), newChildren); labelStr = ("@ " + leftChild.label().value() + ' ' + rightChild.label().value()); return tf.newTreeNode(new CategoryWordTag(labelStr, word, tag), newChildren); labelStr = t.label().value(); return tf.newTreeNode(new CategoryWordTag(labelStr, word, tag), newChildren); } else { labelStr = t.label().value(); return tf.newTreeNode(new CategoryWordTag(labelStr, word, tag), newChildren);
subLabelStr = '@' + topCat + ": " + headStr + " ]"; Label subLabel = new CategoryWordTag(subLabelStr, word, tag); Tree subTree = tf.newTreeNode(subLabel, t.getChildrenAsList()); newChildren.add(markovOutsideBinarizeLocalTree(subTree, head, headLoc, topCat, new LinkedList<>(), true)); subLabelStr = '@' + topCat + ": " + headStr + ' ' + rightStr; Label subLabel = new CategoryWordTag(subLabelStr, word, tag); Tree subTree = tf.newTreeNode(subLabel, t.getChildrenAsList().subList(0, len - 1)); newChildren.add(markovOutsideBinarizeLocalTree(subTree, head, headLoc, topCat, ll, true)); subLabelStr = '@' + topCat + ": " + leftStr + ' ' + headStr + " ]"; Label subLabel = new CategoryWordTag(subLabelStr, word, tag); Tree subTree = tf.newTreeNode(subLabel, t.getChildrenAsList().subList(1, t.numChildren())); newChildren.add(t.getChild(0));
private Tree outsideBinarizeLocalTree(Tree t, String labelStr, String finalCat, int headNum, TaggedWord head, int leftProcessed, String leftStr, int rightProcessed, String rightStr) { List<Tree> newChildren = new ArrayList<>(2); Label label = new CategoryWordTag(labelStr, head.word(), head.tag());
return tf.newTreeNode(new CategoryWordTag(cat, word, cat), newChildren); Label label = new CategoryWordTag(cat, word, tag); result = tf.newTreeNode(label, newChildren);
result = tf.newTreeNode(new CategoryWordTag(cat, word, cat), Collections.<Tree>emptyList()); ArrayList<Tree> newKids = new ArrayList<>(); Tree[] kids = t.children();
CategoryWordTag newLabel = new CategoryWordTag(lab); newLabel.setCategory(s); if (lab instanceof HasTag) {
Label headLabel = new CategoryWordTag(headWordStr, headWordStr, headTagStr); int numTags = tagIndex.size();
Tree binarizeLocalTree(Tree t, int headNum, TaggedWord head) { //System.out.println("Working on: "+headNum+" -- "+t.label()); if (markovFactor) { String topCat = t.label().value(); Label newLabel = new CategoryWordTag(topCat, head.word(), head.tag()); t.setLabel(newLabel); Tree t2; if (insideFactor) { t2 = markovInsideBinarizeLocalTreeNew(t, headNum, 0, t.numChildren() - 1, true); // t2 = markovInsideBinarizeLocalTree(t, head, headNum, topCat, false); } else { t2 = markovOutsideBinarizeLocalTree(t, head, headNum, topCat, new LinkedList<>(), false); } if (DEBUG) { CategoryWordTag.printWordTag = false; StringBuilder sb1 = new StringBuilder(); localTreeString(t, sb1, 0); StringBuilder sb2 = new StringBuilder(); localTreeString(t2, sb2, 0); System.out.println("Old Local Tree: " + sb1); System.out.println("New Local Tree: " + sb2); CategoryWordTag.printWordTag = true; } return t2; } if (insideFactor) { return insideBinarizeLocalTree(t, headNum, head, 0, 0); } return outsideBinarizeLocalTree(t, t.label().value(), t.label().value(), headNum, head, 0, "", 0, ""); }
children.add(newChild); CategoryWordTag newLabel = new CategoryWordTag(lab); newLabel.setCategory(s); if (lab instanceof HasTag) {
String word = ((HasWord) t.label()).word(); String tag = ((HasTag) t.label()).tag(); return new CategoryWordTag(labelStr, word, tag);
tag = headLabel.tag(); Label label = new CategoryWordTag(cat, word, tag); t.setLabel(label);
return new CategoryWordTag(labelStr, word, tag);