Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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;
}
@jasmin24

This comment has been minimized.

Copy link

@jasmin24 jasmin24 commented Feb 19, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment