Skip to content

Instantly share code, notes, and snippets.

@sergey-tihon
Created June 20, 2014 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergey-tihon/7d0ca6fdb9d2703d0b36 to your computer and use it in GitHub Desktop.
Save sergey-tihon/7d0ca6fdb9d2703d0b36 to your computer and use it in GitHub Desktop.
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
Copy link

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