public MentionExtractor(Dictionaries dict, Semantics semantics) { this.headFinder = new SemanticHeadFinder(); this.dictionaries = dict; this.semantics = semantics; this.mentionFinder = new RuleBasedCorefMentionFinder(); }
/* applies a TreeVisitor to all projections (including the node itself) of a node in a Tree. * Does nothing if head is not in root. * @return the maximal projection of head in root. */ public static Tree ApplyToProjections(ITreeVisitor v, Tree head, Tree root, IHeadFinder hf) { Tree projection = head; Tree parent = projection.Parent(root); if (parent == null && projection != root) { return(null); } v.VisitTree(projection); if (projection == root) { return(root); } while (hf.DetermineHead(parent) == projection) { projection = parent; v.VisitTree(projection); if (projection == root) { return(root); } parent = projection.Parent(root); } return(projection); }
/// <exception cref="System.TypeLoadException"/> /// <exception cref="System.IO.IOException"/> private CorefMentionFinder GetMentionFinder(Properties props, IHeadFinder headFinder) { switch (CorefProperties.MdType(props)) { case CorefProperties.MentionDetectionType.Dependency: { mdName = "dependency"; return(new DependencyCorefMentionFinder(props)); } case CorefProperties.MentionDetectionType.Hybrid: { mdName = "hybrid"; mentionAnnotatorRequirements.Add(typeof(TreeCoreAnnotations.TreeAnnotation)); mentionAnnotatorRequirements.Add(typeof(CoreAnnotations.BeginIndexAnnotation)); mentionAnnotatorRequirements.Add(typeof(CoreAnnotations.EndIndexAnnotation)); return(new HybridCorefMentionFinder(headFinder, props)); } case CorefProperties.MentionDetectionType.Rule: default: { mentionAnnotatorRequirements.Add(typeof(TreeCoreAnnotations.TreeAnnotation)); mentionAnnotatorRequirements.Add(typeof(CoreAnnotations.BeginIndexAnnotation)); mentionAnnotatorRequirements.Add(typeof(CoreAnnotations.EndIndexAnnotation)); mdName = "rule"; return(new RuleBasedCorefMentionFinder(headFinder, props)); } } }
public UnlabeledAttachmentEval(string str, bool runningAverages, IHeadFinder headFinder, IPredicate <string> punctRejectFilter) : base(str, runningAverages) { this.headFinder = headFinder; this.punctRejectWordFilter = punctRejectFilter; this.punctRejectFilter = new _IPredicate_58(this); }
public RuleBasedCorefMentionFinder(bool allowReparsing) { // protected int maxID = -1; SieveCoreferenceSystem.logger.Fine("Using SEMANTIC HEAD FINDER!!!!!!!!!!!!!!!!!!!"); this.headFinder = new SemanticHeadFinder(); this.allowReparsing = allowReparsing; }
public TreeAnnotator(IHeadFinder hf, ITreebankLangParserParams tlpp, Options op) { this.tlpParams = tlpp; this.hf = hf; this.tf = new LabeledScoredTreeFactory(); this.trainOptions = op.trainOptions; }
public override TregexMatcher Matcher(Tree root, Tree tree, IdentityDictionary<Tree, Tree> nodesToParents, Dictionary<string, Tree> namesToNodes, VariableStrings variableStrings, IHeadFinder headFinder) { return new CoordinationMatcher(this, root, tree, nodesToParents, namesToNodes, variableStrings, headFinder); }
/// <exception cref="System.TypeLoadException"/> /// <exception cref="System.IO.IOException"/> public DocumentMaker(Properties props, Dictionaries dictionaries) { this.props = props; this.dict = dictionaries; reader = GetDocumentReader(props); headFinder = CorefProperties.GetHeadFinder(props); md = CorefProperties.UseGoldMentions(props) ? new RuleBasedCorefMentionFinder(headFinder, props) : null; }
public TregexParser(TextReader stream, Func <string, string> basicCatFunction, IHeadFinder headFinder) : this(stream) { this.basicCatFunction = basicCatFunction; this.headFinder = headFinder; }
public override TregexMatcher Matcher(Tree root, Tree tree, IdentityDictionary <Tree, Tree> nodesToParents, Dictionary <string, Tree> namesToNodes, VariableStrings variableStrings, IHeadFinder headFinder) { return(new CoordinationMatcher(this, root, tree, nodesToParents, namesToNodes, variableStrings, headFinder)); }
/// <summary> /// Create a TreeNormalizer that maintains some functional annotations, /// particularly those involving temporal annotation. /// </summary> /// <param name="temporalAnnotation"> /// One of the constants: /// TEMPORAL_NONE (no temporal annotation kept on trees), /// TEMPORAL_ACL03PCFG (temporal annotation on NPs, and percolated down /// to head of constituent until and including POS tag), /// TEMPORAL_ANY_TMP_PERCOLATED (temporal annotation on any phrase is /// kept and percolated via head chain to and including POS tag), /// TEMPORAL_ALL_TERMINALS (temporal annotation is kept on NPs, and /// is placed on all POS tag daughters of that NP (but is not /// percolated down a head chain through phrasal categories), /// TEMPORAL_ALL_NP (temporal annotation on NPs, and it is percolated /// down via the head chain, but only through NPs: annotation stops /// at either a POS tag (which is annotated) or a non-NP head /// (which isn't annotated)), /// TEMPORAL_ALL_NP_AND_PP (keeps temporal annotation on NPs and PPs, /// and it is percolated down via the head chain, but only through /// NPs: annotation stops at either a POS tag (which is annotated) /// or a non-NP head (which isn't annotated)). /// TEMPORAL_NP_AND_PP_WITH_NP_HEAD (like TEMPORAL_ALL_NP_AND_PP /// except an NP is regarded as the head of a PP) /// TEMPORAL_ALL_NP_EVEN_UNDER_PP (like TEMPORAL_ALL_NP, but a PP-TMP /// annotation above an NP is 'passed down' to annotate that NP /// as temporal (but the PP itself isn't marked)) /// TEMPORAL_ALL_NP_PP_ADVP (keeps temporal annotation on NPs, PPs, and /// ADVPs /// and it is percolated down via the head chain, but only through /// those categories: annotation stops at either a POS tag /// (which is annotated) /// or a non-NP/PP/ADVP head (which isn't annotated)), /// TEMPORAL_9 (annotates like the previous one but /// does all NP inside node, and their children if /// pre-pre-terminal rather than only if head). /// </param> /// <param name="doSGappedStuff"> /// Leave -SBJ marking on subject NP and then mark /// S-G sentences with a gapped subject. /// </param> /// <param name="leaveItAll"> /// 0 means the usual stripping of functional tags and indices; /// 1 leaves all functional tags but still strips indices; /// 2 leaves everything /// </param> /// <param name="doAdverbialNP"> /// Leave -ADV functional tag on adverbial NPs and /// maybe add it to their head /// </param> /// <param name="headFinder"> /// A head finder that is used with some of the /// options for temporalAnnotation /// </param> public NPTmpRetainingTreeNormalizer(int temporalAnnotation, bool doSGappedStuff, int leaveItAll, bool doAdverbialNP, IHeadFinder headFinder) { this.temporalAnnotation = temporalAnnotation; this.doSGappedStuff = doSGappedStuff; this.leaveItAll = leaveItAll; this.doAdverbialNP = doAdverbialNP; this.headFinder = headFinder; }
public TregexParser(TextReader stream, Func<string, string> basicCatFunction, IHeadFinder headFinder) : this(stream) { this.basicCatFunction = basicCatFunction; this.headFinder = headFinder; }
/// <summary> /// Construct a new <code>GrammaticalStructure</code> from an existing parse tree. /// The new <code>GrammaticalStructure</code> has the same tree structure /// and label values as the given tree (but no shared storage). As part of /// construction, the parse tree is analyzed using definitions from /// {@link GrammaticalRelation <code>GrammaticalRelation</code>} to populate /// the new <code>GrammaticalStructure</code> with as many labeled grammatical /// relations as it can. /// </summary> /// <param name="t">Parse tree to make grammatical structure from</param> /// <param name="puncFilter">Filter for punctuation words</param> /// <param name="hf">HeadFinder to use when building it</param> /// <param name="threadSafe">Whether or not to support simultaneous instances among multiple threads</param> public EnglishGrammaticalStructure(Tree t, Predicate<string> puncFilter, IHeadFinder hf, bool threadSafe) : base((new CoordinationTransformer(hf)).TransformTree(t.DeepCopy()), EnglishGrammaticalRelations.Values(threadSafe), threadSafe ? EnglishGrammaticalRelations.valuesLock : null, hf, puncFilter) { // the tree is normalized (for index and functional tag stripping) inside CoordinationTransformer }
/// <summary> /// Returns a lexicalized Tree whose Labels are CategoryWordTag /// instances, all corresponds to the input tree. /// </summary> public static Tree Lexicalize(Tree t, IHeadFinder hf) { IFunction <Tree, Tree> a = TreeFunctions.GetLabeledTreeToCategoryWordTagTreeFunction(); Tree t1 = a.Apply(t); t1.PercolateHeads(hf); return(t1); }
public override IHeadFinder HeadFinder() { if (headFinder == null) { headFinder = new DybroFrenchHeadFinder(TreebankLanguagePack()); } //Superior for vanilla PCFG over Arun's headfinding rules return(headFinder); }
private void SetHeadFinder(IHeadFinder hf) { if (hf == null) { throw new ArgumentException(); } headFinder = hf; CompileAnnotations(hf); }
/// <summary>Constructor</summary> /// <param name="hf">the headfinder</param> /// <param name="performMWETransformation"> /// Parameter for backwards compatibility. /// If set to false, multi-word expressions won't be attached to a new "MWE" node /// </param> public CoordinationTransformer(IHeadFinder hf, bool performMWETransformation) { //to get rid of unwanted nodes and tag //to flatten date patterns //to restructure the QP constituents // default constructor this.headFinder = hf; this.performMWETransformation = performMWETransformation; qp = new QPTreeTransformer(performMWETransformation); }
// junk tree just for testing setCategoriesToAvoid (NP never matches VBZ but shouldn't pick the punctuation marks) // Tree.valueOf("(FOO (BAR a) (BAZ b))") // todo: If change to always do something rather than Exception (and edit hfFeads array) // , "BAR" private void RunTesting(IHeadFinder hf, string[] heads) { NUnit.Framework.Assert.AreEqual("Test arrays out of balance", testTrees.Length, heads.Length); for (int i = 0; i < testTrees.Length; i++) { Tree h = hf.DetermineHead(testTrees[i]); string headCat = h.Value(); NUnit.Framework.Assert.AreEqual("Wrong head found", heads[i], headCat); } }
internal TregexMatcher(Tree root, Tree tree, IdentityHashMap <Tree, Tree> nodesToParents, IDictionary <string, Tree> namesToNodes, VariableStrings variableStrings, IHeadFinder headFinder) { // these things are used by "find" this.root = root; this.tree = tree; this.nodesToParents = nodesToParents; this.namesToNodes = namesToNodes; this.variableStrings = variableStrings; this.headFinder = headFinder; }
public TregexMatcher(Tree root, Tree tree, IdentityDictionary<Tree, Tree> nodesToParents, Dictionary<string, Tree> namesToNodes, VariableStrings variableStrings, IHeadFinder headFinder) { this.root = root; this.tree = tree; this.nodesToParents = nodesToParents; this.namesToNodes = namesToNodes; this.variableStrings = variableStrings; this.headFinder = headFinder; }
public TregexMatcher(Tree root, Tree tree, IdentityDictionary <Tree, Tree> nodesToParents, Dictionary <string, Tree> namesToNodes, VariableStrings variableStrings, IHeadFinder headFinder) { this.root = root; this.tree = tree; this.nodesToParents = nodesToParents; this.namesToNodes = namesToNodes; this.variableStrings = variableStrings; this.headFinder = headFinder; }
public static ShallowParseMentionFinder GetInstance(IHeadFinder headFinder) { if (mInstance == null) { mInstance = new ShallowParseMentionFinder(headFinder); } else if (mInstance.HeadFinder != headFinder) { mInstance = new ShallowParseMentionFinder(headFinder); } return(mInstance); }
public DescriptionMatcher(DescriptionPattern n, Tree root, Tree tree, IdentityDictionary <Tree, Tree> nodesToParents, Dictionary <string, Tree> namesToNodes, VariableStrings variableStrings, IHeadFinder headFinder) : base(root, tree, nodesToParents, namesToNodes, variableStrings, headFinder) { myNode = n; // no need to reset anything - everything starts out as null or false. // lazy initialization of children to save time. // resetChildIter(); }
public static ShallowParseMentionFinder GetInstance(IHeadFinder headFinder) { if (mInstance == null) { mInstance = new ShallowParseMentionFinder(headFinder); } else if (mInstance.HeadFinder != headFinder) { mInstance = new ShallowParseMentionFinder(headFinder); } return mInstance; }
public static PennTreebankMentionFinder GetInstance(IHeadFinder headFinder) { if (mInstance == null) { mInstance = new PennTreebankMentionFinder(headFinder); } else if (mInstance.HeadFinder != headFinder) { mInstance = new PennTreebankMentionFinder(headFinder); } return mInstance; }
/// <summary> /// Returns the set of dependencies in a tree, according to some /// <see cref="Edu.Stanford.Nlp.Trees.IDependencyTyper{T}"/> /// . /// </summary> public static ICollection <E> DependencyObjectify <E>(Tree t, IHeadFinder hf, ITreeTransformer collinizer, IDependencyTyper <E> typer) { ICollection <E> deps = new List <E>(); Tree t1 = collinizer.TransformTree(t); if (t1 == null) { return(deps); } DependencyObjectifyHelper(t1, t1, hf, deps, typer); return(deps); }
public static PennTreebankMentionFinder GetInstance(IHeadFinder headFinder) { if (mInstance == null) { mInstance = new PennTreebankMentionFinder(headFinder); } else if (mInstance.HeadFinder != headFinder) { mInstance = new PennTreebankMentionFinder(headFinder); } return(mInstance); }
public NegraPennTreebankParserParams() : base(new NegraPennLanguagePack(defaultLeaveGF, defaultGFCharacter)) { //Features //Grammatical function parameters //TODO: fix this so it really works //wsg2010: Commented out by Roger? //return new NegraHeadFinder(); //return new LeftHeadFinder(); headFinder = new NegraHeadFinder(); // override output encoding: make it UTF-8 SetOutputEncoding("UTF-8"); }
public CollinsDepEval(string str, bool runningAverages, IHeadFinder hf, string startSymbol) : base(str, runningAverages) { this.hf = hf; this.startSymbol = startSymbol; precisions = new ClassicCounter <CollinsRelation>(); recalls = new ClassicCounter <CollinsRelation>(); f1s = new ClassicCounter <CollinsRelation>(); precisions2 = new ClassicCounter <CollinsRelation>(); recalls2 = new ClassicCounter <CollinsRelation>(); pnums2 = new ClassicCounter <CollinsRelation>(); rnums2 = new ClassicCounter <CollinsRelation>(); }
/// <summary> /// Construct a new /// <c>CollocationFinder</c> /// over the /// <c>Tree</c> /// t. /// </summary> /// <param name="t">parse tree</param> /// <param name="w">wordnet connection</param> /// <param name="hf"> /// /// <see cref="IHeadFinder"/> /// to use /// </param> public CollocationFinder(Tree t, IWordNetConnection w, IHeadFinder hf) { CoordinationTransformer transformer = new CoordinationTransformer(hf); this.wnConnect = w; this.qTree = transformer.TransformTree(t); this.collocationCollector = Generics.NewArrayList(); this.hf = hf; this.GetCollocationsList(); if (Debug) { log.Info("Collected collocations: " + collocationCollector); } }
/// <summary>Build a custom binarizer for Trees.</summary> /// <param name="hf">the HeadFinder to use in binarization</param> /// <param name="tlp">the TreebankLanguagePack to use</param> /// <param name="insideFactor">whether to do inside markovization</param> /// <param name="markovFactor">whether to markovize the binary rules</param> /// <param name="markovOrder">the markov order to use; only relevant with markovFactor=true</param> /// <param name="useWrappingLabels">whether to use state names (labels) that allow wrapping from right to left</param> /// <param name="unaryAtTop"> /// Whether to actually materialize the unary that rewrites /// a passive state to the active rule at the top of an original local /// tree. This is used only when compaction is happening /// </param> /// <param name="selectiveSplitThreshold">if selective split is used, this will be the threshold used to decide which state splits to keep</param> /// <param name="markFinalStates">whether or not to make the state names (labels) of the final active states distinctive</param> /// <param name="noRebinarization">if true, a node which already has exactly two children is not altered</param> public TreeBinarizer(IHeadFinder hf, ITreebankLanguagePack tlp, bool insideFactor, bool markovFactor, int markovOrder, bool useWrappingLabels, bool unaryAtTop, double selectiveSplitThreshold, bool markFinalStates, bool simpleLabels, bool noRebinarization ) { this.hf = hf; this.tlp = tlp; this.tf = new LabeledScoredTreeFactory(new CategoryWordTagFactory()); this.insideFactor = insideFactor; this.markovFactor = markovFactor; this.markovOrder = markovOrder; this.useWrappingLabels = useWrappingLabels; this.unaryAtTop = unaryAtTop; this.selectiveSplitThreshold = selectiveSplitThreshold; this.markFinalStates = markFinalStates; this.simpleLabels = simpleLabels; this.noRebinarization = noRebinarization; }
private static void DependencyObjectifyHelper <E>(Tree t, Tree root, IHeadFinder hf, ICollection <E> c, IDependencyTyper <E> typer) { if (t.IsLeaf() || t.IsPreTerminal()) { return; } Tree headDtr = hf.DetermineHead(t); foreach (Tree child in t.Children()) { DependencyObjectifyHelper(child, root, hf, c, typer); if (child != headDtr) { c.Add(typer.MakeDependency(headDtr, child, root)); } } }
// do all con/dis-juncts have to be considered to determine a match? // i.e. true if conj and not negated or disj and negated public CoordinationMatcher(CoordinationPattern n, Tree root, Tree tree, IdentityDictionary <Tree, Tree> nodesToParents, Dictionary <string, Tree> namesToNodes, VariableStrings variableStrings, IHeadFinder headFinder) : base(root, tree, nodesToParents, namesToNodes, variableStrings, headFinder) { myNode = n; children = new TregexMatcher[myNode.children.Count]; // lazy initialize the children... don't set children[i] yet //for (int i = 0; i < children.length; i++) { // TregexPattern node = myNode.children.get(i); // children[i] = node.matcher(root, tree, nodesToParents, // namesToNodes, variableStrings); //} currChild = 0; considerAll = myNode.isConj ^ myNode.IsNegated(); }
/// <summary> /// Uses the specified {@link HeadFinder <code>HeadFinder</code>} /// to determine the heads for this node and all its descendants, /// and to store references to the head word node and head tag node /// in this node's {@link CoreLabel <code>CoreLabel</code>} and the /// <code>CoreLabel</code>s of all its descendants. /// /// Note that, in contrast to {@link Tree#percolateHeads /// <code>Tree.percolateHeads()</code>}, which assumes {@link /// edu.stanford.nlp.ling.CategoryWordTag /// <code>CategoryWordTag</code>} labels and therefore stores head /// words and head tags merely as <code>string</code>s, this /// method stores references to the actual nodes. This mitigates /// potential problems in sentences which contain the same word more than once. /// </summary> /// <param name="hf">The headfinding algorithm to use</param> public override void PercolateHeads(IHeadFinder hf) { if (IsLeaf()) { TreeGraphNode hwn = HeadWordNode(); if (hwn == null) { SetHeadWordNode(this); } } else { foreach (Tree child in Children()) { child.PercolateHeads(hf); } TreeGraphNode head = SafeCast(hf.DetermineHead(this, _parent)); if (head != null) { TreeGraphNode hwn = head.HeadWordNode(); if (hwn == null && head.IsLeaf()) { // below us is a leaf SetHeadWordNode(head); } else { SetHeadWordNode(hwn); } TreeGraphNode htn = head.HeadTagNode(); if (htn == null && head.IsLeaf()) { // below us is a leaf SetHeadTagNode(this); } else { SetHeadTagNode(htn); } } } }
/// <summary>Set language-specific options according to flags.</summary> /// <remarks> /// Set language-specific options according to flags. This routine should process the option starting in args[i] (which /// might potentially be several arguments long if it takes arguments). It should return the index after the last index /// it consumed in processing. In particular, if it cannot process the current option, the return value should be i. /// <p/> /// Generic options are processed separately by /// <see cref="Options.SetOption(string[], int)"/> /// , and implementations of this /// method do not have to worry about them. The Options class handles routing options. TreebankParserParams that extend /// this class should call super when overriding this method. /// </remarks> /// <param name="args"/> /// <param name="i"/> public override int SetOptionFlag(string[] args, int i) { if (Sharpen.Runtime.EqualsIgnoreCase(args[i], "-headFinder") && (i + 1 < args.Length)) { try { IHeadFinder hf = (IHeadFinder)System.Activator.CreateInstance(Sharpen.Runtime.GetType(args[i + 1])); SetHeadFinder(hf); optionsString.Append("HeadFinder: " + args[i + 1] + "\n"); } catch (Exception e) { log.Info(e); log.Info(this.GetType().FullName + ": Could not load head finder " + args[i + 1]); } i += 2; } return(i); }
public TreeAnnotatorAndBinarizer(IHeadFinder annotationHF, IHeadFinder binarizationHF, ITreebankLangParserParams tlpParams, bool forceCNF, bool insideFactor, bool doSubcategorization, Options op) { this.trainOptions = op.trainOptions; if (doSubcategorization) { annotator = new TreeAnnotator(annotationHF, tlpParams, op); } else { annotator = new TreeAnnotatorAndBinarizer.TreeNullAnnotator(annotationHF); } binarizer = new TreeBinarizer(binarizationHF, tlpParams.TreebankLanguagePack(), insideFactor, trainOptions.markovFactor, trainOptions.markovOrder, trainOptions.CompactGrammar() > 0, trainOptions.CompactGrammar() > 1, trainOptions.HselCut, trainOptions .markFinalStates, trainOptions.simpleBinarizedLabels, trainOptions.noRebinarization); if (trainOptions.selectivePostSplit) { postSplitter = new PostSplitter(tlpParams, op); } else { postSplitter = null; } this.tf = new LabeledScoredTreeFactory(new CategoryWordTagFactory()); this.tlp = tlpParams.TreebankLanguagePack(); this.forceCNF = forceCNF; if (trainOptions.printAnnotatedRuleCounts) { annotatedRuleCounts = new ClassicCounter <Tree>(); } else { annotatedRuleCounts = null; } if (trainOptions.printAnnotatedStateCounts) { annotatedStateCounts = new ClassicCounter <string>(); } else { annotatedStateCounts = null; } }
public MentionContext(Util.Span span, Util.Span headSpan, int entityId, IParse parse, string extentType, string nameType, int mentionIndex, int mentionsInSentence, int mentionIndexInDocument, int sentenceIndex, IHeadFinder headFinder) : base(span, headSpan, entityId, parse, extentType, nameType, headFinder) { NounPhraseSentenceIndex = mentionIndex; MaxNounPhraseSentenceIndex = mentionsInSentence; NounPhraseDocumentIndex = mentionIndexInDocument; SentenceNumber = sentenceIndex; IndexSpan = parse.Span; PreviousToken = parse.PreviousToken; NextToken = parse.NextToken; Head = headFinder.GetLastHead(parse); List<IParse> headTokens = Head.Tokens; Tokens = headTokens.ToArray(); NextTokenBasal = Head.NextToken; //System.err.println("MentionContext.init: "+ent+" "+ent.getEntityId()+" head="+head); //mNonDescriptorStart = 0; InitializeHeads(headFinder.GetHeadIndex(Head)); mGender = Similarity.GenderEnum.Unknown; GenderProbability = 0d; _number = Similarity.NumberEnum.Unknown; NumberProbability = 0d; }
/// <summary> /// Returns the maximal projection of <code>head</code> in /// <code>root</code> given a {@link HeadFinder} /// </summary> public static Tree MaximalProjection(Tree head, Tree root, IHeadFinder hf) { Tree projection = head; if (projection == root) { return root; } Tree parent = projection.Parent(root); while (hf.DetermineHead(parent) == projection) { projection = parent; if (projection == root) { return root; } parent = projection.Parent(root); } return projection; }
public abstract TregexMatcher Matcher(Tree root, Tree tree, IdentityDictionary<Tree, Tree> nodesToParents, Dictionary<string, Tree> namesToNodes, VariableStrings variableStrings, IHeadFinder headFinder);
/// <summary> /// Get a {@link TregexMatcher} for this pattern on this tree. /// Any Relations which use heads of trees should use the provided HeadFinder. /// </summary> /// <param name="t">a tree to match on</param> /// <param name="headFinder">a HeadFinder to use when matching</param> /// <returns>a TregexMatcher</returns> public TregexMatcher Matcher(Tree t, IHeadFinder headFinder) { return Matcher(t, t, null, new Dictionary<string, Tree>(), new VariableStrings(), headFinder); }
/// <summary> /// Return a GrammaticalStructureFactory suitable for this language/treebank. /// (To be overridden in subclasses.) /// </summary> /// <returns>A GrammaticalStructureFactory suitable for this language/treebank</returns> public IGrammaticalStructureFactory GrammaticalStructureFactory(Predicate<string> puncFilt, IHeadFinder typedDependencyHf) { return GrammaticalStructureFactory(); }
// do all con/dis-juncts have to be considered to determine a match? // i.e. true if conj and not negated or disj and negated public CoordinationMatcher(CoordinationPattern n, Tree root, Tree tree, IdentityDictionary<Tree, Tree> nodesToParents, Dictionary<string, Tree> namesToNodes, VariableStrings variableStrings, IHeadFinder headFinder) : base(root, tree, nodesToParents, namesToNodes, variableStrings, headFinder) { myNode = n; children = new TregexMatcher[myNode.children.Count]; // lazy initialize the children... don't set children[i] yet //for (int i = 0; i < children.length; i++) { // TregexPattern node = myNode.children.get(i); // children[i] = node.matcher(root, tree, nodesToParents, // namesToNodes, variableStrings); //} currChild = 0; considerAll = myNode.isConj ^ myNode.IsNegated(); }
private ShallowParseMentionFinder(IHeadFinder headFinder) { HeadFinder = headFinder; PrenominalNamedEntitiesCollection = true; CoordinatedNounPhrasesCollection = true; }
/// <summary> /// A compiler that uses this HeadFinder and the default basicCategoryFunction /// </summary> /// <param name="headFinder">the HeadFinder</param> public TregexPatternCompiler(IHeadFinder headFinder) : this(headFinder, DEFAULT_BASIC_CAT_FUNCTION) { }
/// <summary> /// Constructs context information for the specified mention. /// </summary> /// <param name="mention"> /// The mention object on which this object is based. /// </param> /// <param name="mentionIndexInSentence"> /// The mention's position in the sentence. /// </param> /// <param name="mentionsInSentence"> /// The number of mentions in the sentence. /// </param> /// <param name="mentionIndexInDocument"> /// The index of this mention with respect to the document. /// </param> /// <param name="sentenceIndex"> /// The index of the sentence which contains this mention. /// </param> /// <param name="headFinder"> /// An object which provides head information. /// </param> public MentionContext(Mention mention, int mentionIndexInSentence, int mentionsInSentence, int mentionIndexInDocument, int sentenceIndex, IHeadFinder headFinder) : this(mention.Span, mention.HeadSpan, mention.Id, mention.Parse, mention.Type, mention.NameType, mentionIndexInSentence, mentionsInSentence, mentionIndexInDocument, sentenceIndex, headFinder) { }
/// <summary> /// Creates a new mention finder with the specified head finder. /// </summary> /// <param name="headFinder"> /// The head finder. /// </param> private PennTreebankMentionFinder(IHeadFinder headFinder) { PrenominalNamedEntitiesCollection = false; CoordinatedNounPhrasesCollection = true; HeadFinder = headFinder; }
/// <summary> /// default constructor /// </summary> public CoordinationTransformer(IHeadFinder hf) { this.headFinder = hf; }
public DescriptionMatcher(DescriptionPattern n, Tree root, Tree tree, IdentityDictionary<Tree, Tree> nodesToParents, Dictionary<string, Tree> namesToNodes, VariableStrings variableStrings, IHeadFinder headFinder) : base(root, tree, nodesToParents, namesToNodes, variableStrings, headFinder) { myNode = n; // no need to reset anything - everything starts out as null or false. // lazy initialization of children to save time. // resetChildIter(); }
/// <summary> /// This gets used by GrammaticalStructureFactory (by reflection). DON'T DELETE. /// </summary> /// <param name="t">Parse tree to make grammatical structure from</param> /// <param name="puncFilter">Filter to remove punctuation dependencies</param> /// <param name="hf">HeadFinder to use when building it</param> public EnglishGrammaticalStructure(Tree t, Predicate<string> puncFilter, IHeadFinder hf) : this(t, puncFilter, hf, true) { }
/// <summary> /// A compiler that uses this HeadFinder and this basicCategoryFunction /// </summary> /// <param name="headFinder">the HeadFinder</param> /// <param name="basicCatFunction">The function mapping strings to strings</param> public TregexPatternCompiler(IHeadFinder headFinder, AbstractTreebankLanguagePack.BasicCategoryStringFunction basicCatFunction) { this.headFinder = headFinder; this.basicCatFunction = basicCatFunction; }