Class AbstractContextGenerator
Abstract class containing many of the methods used to generate contexts for parsing.
public abstract class AbstractContextGenerator
- Inheritance
-
AbstractContextGenerator
- Derived
- Inherited Members
Fields
EOS
protected const string EOS = "eos"
Field Value
punctSet
Set of punctuation to be used in generating features.
protected ISet<string>? punctSet
Field Value
useLabel
protected bool useLabel
Field Value
zeroBackOff
protected bool zeroBackOff
Field Value
Methods
Checkcons(Parse, Parse, string, IList<string>)
protected virtual void Checkcons(Parse p1, Parse p2, string type, IList<string> features)
Parameters
Checkcons(Parse, string, string, IList<string>)
Produces features to determine whether the specified child node is part of a complete constituent of the specified type and adds those features to the specfied list.
protected virtual void Checkcons(Parse child, string i, string type, IList<string> features)
Parameters
childParseThe parse node to consider.
istringA string indicating the position of the child node.
typestringThe type of constituent being built.
featuresIList<string>List to add features to.
Cons(Parse?, int)
protected virtual string Cons(Parse? p, int i)
Parameters
Returns
Cons2(IList<string>, Cons, Cons, ICollection<Parse>?, bool)
protected virtual void Cons2(IList<string> features, Cons c0, Cons c1, ICollection<Parse>? punct1s, bool bigram)
Parameters
Cons3(IList<string>, Cons, Cons, Cons, ICollection<Parse>?, ICollection<Parse>?, bool, bool, bool)
Creates cons features involving the 3 specified nodes and adds them to the specified feature list.
protected virtual void Cons3(IList<string> features, Cons c0, Cons c1, Cons c2, ICollection<Parse>? punct1s, ICollection<Parse>? punct2s, bool trigram, bool bigram1, bool bigram2)
Parameters
featuresIList<string>The list of features.
c0ConsThe first node.
c1ConsThe second node.
c2ConsThe third node.
punct1sICollection<Parse>The punctuation between the first and second node.
punct2sICollection<Parse>The punctuation between the second and third node.
trigramboolSpecifies whether lexical tri-gram features between these nodes should be generated.
bigram1boolSpecifies whether lexical bi-gram features between the first and second node should be generated.
bigram2boolSpecifies whether lexical bi-gram features between the second and third node should be generated.
Consbo(Parse?, int)
protected virtual string Consbo(Parse? p, int i)
Parameters
Returns
GetFrontierNodes(IList<Parse>, Parse?[])
Populates specified nodes array with left-most right frontier node with a unique head. If the right frontier doesn't contain enough nodes, then nulls are placed in the array elements.
protected virtual void GetFrontierNodes(IList<Parse> rf, Parse?[] nodes)
Parameters
Production(Parse, bool)
Generates a string representing the grammar rule production that the specified parse is starting. The rule is of the form p.type -> c.children[0..n].type.
protected virtual string Production(Parse p, bool includePunctuation)
Parameters
pParseThe parse which stats teh production.
includePunctuationboolWhether punctuation should be included in the production.
Returns
- string
a string representing the grammar rule production that the specified parse is starting.
Punct(Parse, int)
Creates punctuation feature for the specified punctuation at the specified index based on the punctuation mark.
protected virtual string Punct(Parse punct, int i)
Parameters
punctParseThe punctuation which is in context.
iintThe index of the punctuation with relative to the parse.
Returns
- string
Punctuation feature for the specified parse and the specified punctuation at the specfied index.
Punctbo(Parse, int)
Creates punctuation feature for the specified punctuation at the specfied index based on the punctuation's tag.
protected virtual string Punctbo(Parse punct, int i)
Parameters
punctParseThe punctuation which is in context.
iintThe index of the punctuation relative to the parse.
Returns
- string
Punctuation feature for the specified parse and the specified punctuation at the specfied index.
Surround(Parse?, int, string, ICollection<Parse>?, IList<string>)
Generates features for nodes surrounding a completed node of the specified type.
protected virtual void Surround(Parse? node, int i, string type, ICollection<Parse>? punctuation, IList<string> features)
Parameters
nodeParseA surrounding node.
iintThe index of the surrounding node with respect to the completed node.
typestringThe type of the completed node.
punctuationICollection<Parse>The punctuation adjacent and between the specified surrounding node.
featuresIList<string>A list to which features are added.