public TypedDependency(Edu.Stanford.Nlp.Trees.TypedDependency other) { this.reln = other.reln; this.gov = other.gov; this.dep = other.dep; this.extra = other.extra; }
public TypedDependency(GrammaticalRelation reln, IndexedWord gov, IndexedWord dep) { // TODO FIXME: these should all be final. That they are mutable is // awful design. Awful. It means that underlying data structures // can be mutated in ways you don't intend. For example, there was // a time when you could call typedDependenciesCollapsed() and it // would change the GrammaticalStructure because of the way that // object mutated its TypedDependency objects. // = false; // to code whether the dependency preserves the tree structure or not // cdm: todo: remove this field and use typing on reln? Expand implementation of SEMANTIC_DEPENDENT this.reln = reln; this.gov = gov; this.dep = dep; }
public virtual void SetReln(GrammaticalRelation reln) { this.reln = reln; }
public _GrammaticalRelation_504(Language baseArg1, string baseArg2, string baseArg3, GrammaticalRelation baseArg4) : base(baseArg1, baseArg2, baseArg3, baseArg4) { this.serialVersionUID = 1L; }
/// <summary>Read in typed dependencies.</summary> /// <remarks> /// Read in typed dependencies. Warning created typed dependencies are not /// backed by any sort of a tree structure. /// </remarks> /// <param name="filename"/> /// <exception cref="System.IO.IOException"/> protected internal static IList <ICollection <TypedDependency> > ReadDeps(string filename) { LineNumberReader breader = new LineNumberReader(new FileReader(filename)); IList <ICollection <TypedDependency> > readDeps = new List <ICollection <TypedDependency> >(); ICollection <TypedDependency> deps = new List <TypedDependency>(); for (string line = breader.ReadLine(); line != null; line = breader.ReadLine()) { if (line.Equals("null(-0,-0)") || line.Equals("null(-1,-1)")) { readDeps.Add(deps); deps = new List <TypedDependency>(); continue; } // relex parse error try { if (line.Equals(string.Empty)) { if (deps.Count != 0) { //System.out.println(deps); readDeps.Add(deps); deps = new List <TypedDependency>(); } continue; } int firstParen = line.IndexOf("("); int commaSpace = line.IndexOf(", "); string depName = Sharpen.Runtime.Substring(line, 0, firstParen); string govName = Sharpen.Runtime.Substring(line, firstParen + 1, commaSpace); string childName = Sharpen.Runtime.Substring(line, commaSpace + 2, line.Length - 1); GrammaticalRelation grel = GrammaticalRelation.ValueOf(depName); if (depName.StartsWith("prep_")) { string prep = Sharpen.Runtime.Substring(depName, 5); grel = EnglishGrammaticalRelations.GetPrep(prep); } if (depName.StartsWith("prepc_")) { string prepc = Sharpen.Runtime.Substring(depName, 6); grel = EnglishGrammaticalRelations.GetPrepC(prepc); } if (depName.StartsWith("conj_")) { string conj = Sharpen.Runtime.Substring(depName, 5); grel = EnglishGrammaticalRelations.GetConj(conj); } if (grel == null) { throw new Exception("Unknown grammatical relation '" + depName + "'"); } //Word govWord = new Word(govName.substring(0, govDash)); IndexedWord govWord = new IndexedWord(); govWord.SetValue(NormalizeNumbers(govName)); govWord.SetWord(govWord.Value()); //Word childWord = new Word(childName.substring(0, childDash)); IndexedWord childWord = new IndexedWord(); childWord.SetValue(NormalizeNumbers(childName)); childWord.SetWord(childWord.Value()); TypedDependency dep = new DependencyScoring.TypedDependencyStringEquality(grel, govWord, childWord); deps.Add(dep); } catch (Exception e) { breader.Close(); throw new Exception("Error on line " + breader.GetLineNumber() + ":\n\n" + e); } } if (deps.Count != 0) { readDeps.Add(deps); } //log.info("last: "+readDeps.get(readDeps.size()-1)); breader.Close(); return(readDeps); }
public TypedDependencyStringEquality(GrammaticalRelation reln, IndexedWord gov, IndexedWord dep) : base(reln, gov, dep) { }