/// <summary> /// 搜索token的直接关联关系 /// </summary> /// <param name="sentence"></param> /// <param name="token"></param> /// <returns></returns> private List <edu.stanford.nlp.trees.TypedDependency> FindDeirctRefs(edu.stanford.nlp.util.CoreMap sentence, edu.stanford.nlp.ling.CoreLabel token) { string tokenValue = token.ToString(); List <edu.stanford.nlp.trees.TypedDependency> tds = new List <edu.stanford.nlp.trees.TypedDependency>(); edu.stanford.nlp.semgraph.SemanticGraph dependencies = sentence.get(enhancedPlusPlusDependenciesAnnotationClass) as edu.stanford.nlp.semgraph.SemanticGraph; java.util.Collection typedDependencies = dependencies.typedDependencies(); java.util.Iterator itr = typedDependencies.iterator(); while (itr.hasNext()) { edu.stanford.nlp.trees.TypedDependency td = itr.next() as edu.stanford.nlp.trees.TypedDependency; string tdValue = td.toString(); if (tdValue.IndexOf(tokenValue) != -1) { tds.Add(td); } } return(tds); }
/// <summary> /// 搜索与target token相关的dpendency关系集合 /// </summary> /// <param name="dependencies"></param> /// <param name="token"></param> /// <returns></returns> private List <edu.stanford.nlp.trees.TypedDependency> FindRefs(edu.stanford.nlp.semgraph.SemanticGraph dependencies, edu.stanford.nlp.ling.CoreLabel token) { List <edu.stanford.nlp.trees.TypedDependency> tds = new List <edu.stanford.nlp.trees.TypedDependency>(); string tokenValue = token.ToString(); java.util.Collection typedDependencies = dependencies.typedDependencies(); java.util.Iterator itr = typedDependencies.iterator(); while (itr.hasNext()) { edu.stanford.nlp.trees.TypedDependency td = itr.next() as edu.stanford.nlp.trees.TypedDependency; string tdValue = td.toString(); if (tdValue.IndexOf(tokenValue) != -1) { tds.Add(td); } } return(tds); }