Created
June 20, 2014 15:46
-
-
Save sergey-tihon/7d0ca6fdb9d2703d0b36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Dependency> GetDependency(Tree tree) | |
{ | |
var tlp = new PennTreebankLanguagePack(); | |
var gsf = tlp.grammaticalStructureFactory(); | |
var gs = gsf.newGrammaticalStructure(tree); | |
var dependencies = gs.typedDependenciesCollapsedTree(); | |
return (from TypedDependency dependency in dependencies.toArray() | |
select new Dependency | |
{ | |
Dependent = dependency.dep().value().Replace("\\/", "/"), | |
Governor = dependency.gov().value().Replace("\\/", "/"), | |
Name = dependency.reln().getShortName() | |
}).ToList(); | |
} | |
public struct Dependency | |
{ | |
public string Governor; | |
public string Dependent; | |
public string Name; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi sergey-tihon..I want help from you to regarding above code. I want to extract governor and dependent from perticular tag. for ex. nsubj(good-4, phone-5). then extract what is at the position governor and what is at dependent position..how i can do this? n I am taking this list of dependency from text file.