public NotenizerDependency(TypedDependency typedDependency) { _dependent = new NotenizerWord(typedDependency.dep()); _governor = new NotenizerWord(typedDependency.gov()); _relation = new NotenizerRelation(typedDependency.reln()); _originalDependency = typedDependency; }
public bool IsChildOfRoot() { IndexedWord root = GetRoot(); for (var iter = NounPhrase.Dependencies.iterator(); iter.hasNext();) { TypedDependency var = (TypedDependency)iter.next(); if (var.gov().Equals(root) && NounPhrase.PhraseArray.Contains(var.dep().word())) { return(true); } } return(false); }
public bool IsConnectedToSentiment() { for (var iter = NounPhrase.Dependencies.iterator(); iter.hasNext();) { TypedDependency var = (TypedDependency)iter.next(); var dep = var.dep(); var gov = var.gov(); if ((NounPhrase.PhraseArray.Contains(dep.word()) && sentimentLexicon.GetSentiment(gov.word()) != 0) || (NounPhrase.PhraseArray.Contains(gov.word()) && sentimentLexicon.GetSentiment(dep.word()) != 0)) { return(true); } } return(false); }
public string Tags(string input) { // Path to models extracted from `stanford-parser-3.6.0-models.jar` var jarRoot = @""; var modelsDirectory = jarRoot; var lp = LexicalizedParser.loadModel(modelsDirectory + @"\lexparser\englishPCFG.ser.gz"); // This option shows loading and using an explicit tokenizer var sent2 = input; var tokenizerFactory = PTBTokenizer.factory(new CoreLabelTokenFactory(), ""); var sent2Reader = new java.io.StringReader(sent2); var rawWords2 = tokenizerFactory.getTokenizer(sent2Reader).tokenize(); sent2Reader.close(); var tree2 = lp.apply(rawWords2); // Extract dependencies from lexical tree var tlp = new PennTreebankLanguagePack(); var gsf = tlp.grammaticalStructureFactory(); var gs = gsf.newGrammaticalStructure(tree2); var tdl = gs.typedDependenciesCCprocessed(); // Extract collapsed dependencies from parsed tree var tp = new TreePrint("penn,typedDependenciesCollapsed"); UnityEngine.Debug.Log(tdl); //tp.printTree(tree2); for (int i = 0; i < tdl.size(); i++) { TypedDependency node = (TypedDependency)tdl.get(i); string relation = node.reln().getShortName(); if (relation.Contains("nsubj")) { IndexedWord act = node.gov(); //node.dep().getword() action = act.value(); UnityEngine.Debug.Log("This is the action " + action); IndexedWord subject = node.dep(); subj = subject.value(); UnityEngine.Debug.Log("This is the subject " + subj); } if (relation.Contains("dobj")) { IndexedWord act = node.gov(); //node.dep().getword() action = act.value(); UnityEngine.Debug.Log("This is the action " + action); IndexedWord tar = node.dep(); target = tar.value(); UnityEngine.Debug.Log("This is the target " + target); } if (relation.Contains("nmod")) { IndexedWord tar_two = node.dep(); second_target = tar_two.value(); UnityEngine.Debug.Log("This is the target second " + second_target); } } return(tdl.ToString()); }