public static GrammaticalRelation valueOf(String s) { return valueOf(Language.Any, s); }
static public void setUp(Properties props){ ArgumentParser.fillOptions(DepPatternFactory.class, props); ArgumentParser.fillOptions(PatternFactory.class, props); for(String s: ignoreRels.split("[,;]")){ ignoreRelsSet.add(GrammaticalRelation.valueOf(s)); } for(String s: allowedTagsForTrigger.split("[,;]")){ allowedTagPatternForTrigger.add(Pattern.compile(s)); } }
public static void main(String[] args) { final String[] names = {"dep", "pred", "prep_to","rcmod"}; for (String name : names) { GrammaticalRelation reln = valueOf(Language.English, name); System.out.println("Data for GrammaticalRelation loaded as valueOf(\"" + name + "\"):"); System.out.println("\tShort name: " + reln.getShortName()); System.out.println("\tLong name: " + reln.getLongName()); System.out.println("\tSpecific name: " + reln.getSpecific()); } }
/** * Returns the EnglishGrammaticalRelation having the given string * representation (e.g., "nsubj"), or null if no such is found. * * @param s The short name of the GrammaticalRelation * @return The EnglishGrammaticalRelation with that name */ public static GrammaticalRelation valueOf(String s) { return GrammaticalRelation.valueOf(s, synchronizedValues, valuesLock()); // // TODO does this need to be changed? // // modification NOTE: do not commit until go-ahead // // If this is a collapsed relation (indicated by a "_" separating // // the type and the dependent, instantiate a collapsed version. // // Currently handcode against conjunctions and prepositions, but // // should do this in a more robust fashion. // String[] tuples = s.trim().split("_", 2); // if (tuples.length == 2) { // String reln = tuples[0]; // String specific = tuples[1]; // if (reln.equals(PREPOSITIONAL_MODIFIER.getShortName())) { // return getPrep(specific); // } else if (reln.equals(CONJUNCT.getShortName())) { // return getConj(specific); // } // } // // return null; }
/** * Returns the EnglishGrammaticalRelation having the given string * representation (e.g. "nsubj"), or null if no such is found. * * @param s The short name of the GrammaticalRelation * @return The EnglishGrammaticalRelation with that name */ public static GrammaticalRelation valueOf(String s) { return GrammaticalRelation.valueOf(s, synchronizedValues, valuesLock()); // // TODO does this need to be changed? // // modification NOTE: do not commit until go-ahead // // If this is a collapsed relation (indicated by a "_" separating // // the type and the dependent, instantiate a collapsed version. // // Currently handcode against conjunctions and prepositions, but // // should do this in a more robust fashion. // String[] tuples = s.trim().split("_", 2); // if (tuples.length == 2) { // String reln = tuples[0]; // String specific = tuples[1]; // if (reln.equals(PREPOSITIONAL_MODIFIER.getShortName())) { // return getPrep(specific); // } else if (reln.equals(CONJUNCT.getShortName())) { // return getConj(specific); // } // } // // return null; }
public static GrammaticalRelation valueOf(String s) { return GrammaticalRelation.valueOf(s, values(), valuesLock()); }
public static GrammaticalRelation valueOf(String s) { return GrammaticalRelation.valueOf(s, values(), valuesLock()); }
GrammaticalRelation reln; synchronized (stringsToRelations) { reln = (stringsToRelations.get(language) != null ? valueOf(s, stringsToRelations.get(language)) : null);
/** * A helper to add a single word to a given dependency tree * @param toModify The tree to add the word to. * @param root The root of the tree where we should be adding the word. * @param rel The relation to add the word with. * @param coreLabel The word to add. */ @SuppressWarnings("UnusedDeclaration") private static void addWord(SemanticGraph toModify, IndexedWord root, String rel, CoreLabel coreLabel) { IndexedWord dependent = new IndexedWord(coreLabel); toModify.addVertex(dependent); toModify.addEdge(root, dependent, GrammaticalRelation.valueOf(Language.English, rel), Double.NEGATIVE_INFINITY, false); }
String govName = line.substring(firstParen + 1, commaSpace); String childName = line.substring(commaSpace+2, line.length() - 1); GrammaticalRelation grel = GrammaticalRelation.valueOf(depName); if (depName.startsWith("prep_")) { String prep = depName.substring(5);
tree.addEdge(governor, dependent, GrammaticalRelation.valueOf(Language.English, relation), Double.NEGATIVE_INFINITY, false);
@Override public void evaluate(SemanticGraph sg, SemgrexMatcher sm) { String relation = sm.getRelnString(edgeName); IndexedWord govNode = getNamedNode(govName, sm); IndexedWord depNode = getNamedNode(depName, sm); SemanticGraphEdge edge = sg.getEdge(govNode, depNode, GrammaticalRelation.valueOf(relation)); if (edge != null) { sg.removeEdge(edge); } }
private Pair<IndexedWord, GrammaticalRelation> getGovAndReln(double govPseudoIndex, IndexedWord word, String relationName, List<IndexedWord> sortedTokens) { IndexedWord gov; GrammaticalRelation reln; if (relationName.equals("root")) { reln = GrammaticalRelation.ROOT; } else { reln = GrammaticalRelation.valueOf(this.lang, relationName); } if (govPseudoIndex == 0.0) { gov = new IndexedWord(word.docID(), word.sentIndex(), 0); gov.setValue("ROOT"); } else { gov = this.getToken(sortedTokens, govPseudoIndex); } return Generics.newPair(gov, reln); }
toModify.addEdge(root, subject, GrammaticalRelation.valueOf(Language.English, rel), Double.NEGATIVE_INFINITY, false);
tree.addVertex(subj); tree.addVertex(be); tree.addEdge(adj, be, GrammaticalRelation.valueOf(Language.English, "cop"), Double.NEGATIVE_INFINITY, false); tree.addEdge(adj, subj, GrammaticalRelation.valueOf(Language.English, "nsubj"), Double.NEGATIVE_INFINITY, false); tree.addEdge(adj, pobj, GrammaticalRelation.valueOf(Language.English, prep), Double.NEGATIVE_INFINITY, false);
GrammaticalRelation td3reln = UniversalChineseGrammaticalRelations.valueOf(td1Dep.value()); if (td3reln == null) { td3reln = GrammaticalRelation.valueOf(Language.UniversalChinese, td1Dep.value());
GrammaticalRelation td3reln = ChineseGrammaticalRelations.valueOf(td1Dep.value()); if (td3reln == null) { td3reln = GrammaticalRelation.valueOf(Language.Chinese, td1Dep.value());
tree.addEdge(governor, dependent, GrammaticalRelation.valueOf(Language.English, relation), Double.NEGATIVE_INFINITY, false);
private void readDep(IndexedWord gov, String reln) { readWhiteSpace(); if (!isLeftBracket(peek())) { // it's a leaf String label = readName(); IndexedWord dep = makeVertex(label); sg.addVertex(dep); if (gov == null) sg.roots.add(dep); sg.addEdge(gov, dep, GrammaticalRelation.valueOf(this.language, reln), Double.NEGATIVE_INFINITY, false); } else { readLeftBracket(); String label = readName(); IndexedWord dep = makeVertex(label); sg.addVertex(dep); if (gov == null) sg.roots.add(dep); if (gov != null && reln != null) { sg.addEdge(gov, dep, GrammaticalRelation.valueOf(this.language, reln), Double.NEGATIVE_INFINITY, false); } readWhiteSpace(); while (!isRightBracket(peek()) && !isEOF) { reln = readName(); readRelnSeparator(); readDep(dep, reln); readWhiteSpace(); } readRightBracket(); } }
GrammaticalRelation rel = GrammaticalRelation.valueOf(ie.dep); graph.addEdge(source, target, rel, 1.0, ie.isExtra);