/** Initializes this node as an artificial root node. */ public void initRoot() { init(DEPLib.ROOT_ID, DEPLib.ROOT_TAG, DEPLib.ROOT_TAG, DEPLib.ROOT_TAG, new DEPFeat()); }
/** * Constructs a feature map by decoding the specific features. * @param feats the features to be added. * See the {@code feats} parameter in {@link DEPFeat#add(String)}. */ public DEPFeat(String feats) { add(feats); }
public void copy(DEPNode node) { init(node.id, node.form, node.lemma, node.pos, (DEPFeat)node.d_feats.clone()); }
public String toString() { if (isEmpty()) return DEPReader.BLANK_COLUMN; StringBuilder build = new StringBuilder(); List<String> keys = new ArrayList<String>(keySet()); Collections.sort(keys); for (String key : keys) { build.append(DELIM_FEATS); build.append(key); build.append(DELIM_KEY_VALUE); build.append(get(key)); } return build.toString().substring(DELIM_FEATS.length()); } }
void evalSubPOS(String inputFile) throws Exception { BufferedReader reader = UTInput.createBufferedFileReader(inputFile); Pattern delim = Pattern.compile("\t"); int correct = 0, total = 0; DEPFeat p, g; String[] ls; String line; while ((line = reader.readLine()) != null) { line = line.trim(); if (!line.isEmpty()) { ls = delim.split(line); g = new DEPFeat(ls[6]); p = new DEPFeat(ls[7]); if (g.get("SubPOS").equals(p.get("SubPOS"))) correct++; total++; } } System.out.printf("%5.2f (%d/%d)\n", 100d*correct/total, correct, total); }
/** * Puts an extra feature to this node using the specific key and value. * This method overwrites an existing value of the same key with the current value. */ public void addFeat(String key, String value) { d_feats.put(key, value); }
/** @return the value of the specific feature if exists; otherwise, {@code null}. */ public String getFeat(String key) { return d_feats.get(key); }
/** Removes the feature with the specific key. */ public String removeFeat(String key) { return d_feats.remove(key); }
public String putFeat(String key, String value) { return d_head.c2d.d_feats.put(key, value); }
public String getFeat(String key) { return d_feats.get(key); }
public DEPNode(int id, String form) { init(id, form, null, null, new DEPFeat()); }
if (line.isEmpty()) continue; gFeats = new DEPFeat(gold[goldIndex]); aFeats = new DEPFeat(auto[autoIndex]); if ((gPred = gFeats.get(DEPLib.FEAT_PB)) != null) counts[1]++; if ((aPred = aFeats.get(DEPLib.FEAT_PB)) != null) counts[2]++; if ((gPred = gFeats.get(DEPLib.FEAT_PB)) != null) aPred = aFeats.get(DEPLib.FEAT_PB); counts[1]++; counts[2]++;
/** * Adds the specific features to this map. * @param feats {@code "_"} or {@code feat(|feat)*}.<br> * {@code "_"}: indicates no feature.<br> * {@code feat ::= key=value} (e.g., {@code pos=VBD}). */ public void add(String feats) { if (feats.equals(DEPReader.BLANK_COLUMN)) return; String key, value; int idx; for (String feat : P_FEATS.split(feats)) { idx = feat.indexOf(DELIM_KEY_VALUE); if (idx > 0) { key = feat.substring(0, idx); value = feat.substring(idx+1); put(key, value); } } }
public DEPNode(int id, POSNode node) { init(id, node.form, node.lemma, node.pos, new DEPFeat()); }
/** Initializes the dependency head of a constituent. */ public C2DInfo(CTNode head) { s_label = null; b_head = false; if (head.c2d == null) // for terminals: head = itself { d_head = head; p_head = null; d_feats = new DEPFeat(); } else // for phrases: head = child { d_head = head.c2d.getDependencyHead(); p_head = head; } }
/** Called by {@link LGAsk#generateQuestionFromAsk(DEPTree, String)}. */ private DEPNode getNode(DEPNode head, String form, String lemma, String pos, String deprel, String label) { DEPNode aux = new DEPNode(0, form, lemma, pos, new DEPFeat()); aux.initXHeads(); aux.initSHeads(); aux.setHead(head, deprel); if (label != null) aux.addSHead(head, label); return aux; }
public DEPTree getNullTree() { DEPTree tree = new DEPTree(); DEPNode dummy = new DEPNode(1, "NULL", "NULL", "NULL", new DEPFeat()); dummy.setHead(tree.get(0), "NULL"); tree.add(dummy); tree.initXHeads(); tree.initSHeads(); return tree; }
private DEPTree getNullTree() { DEPTree tree = new DEPTree(); DEPNode dummy = new DEPNode(1, "NULL", "NULL", "NULL", new DEPFeat()); dummy.setHead(tree.get(0), "NULL"); tree.add(dummy); tree.initXHeads(); tree.initSHeads(); return tree; }