Class AbstractContextGenerator

Namespace
NOpenNLP.Tools.Parser
Assembly
NOpenNLP.Tools.dll

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

string

punctSet

Set of punctuation to be used in generating features.

protected ISet<string>? punctSet

Field Value

ISet<string>

useLabel

protected bool useLabel

Field Value

bool

zeroBackOff

protected bool zeroBackOff

Field Value

bool

Methods

Checkcons(Parse, Parse, string, IList<string>)

protected virtual void Checkcons(Parse p1, Parse p2, string type, IList<string> features)

Parameters

p1 Parse
p2 Parse
type string
features IList<string>

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

child Parse

The parse node to consider.

i string

A string indicating the position of the child node.

type string

The type of constituent being built.

features IList<string>

List to add features to.

Cons(Parse?, int)

protected virtual string Cons(Parse? p, int i)

Parameters

p Parse
i int

Returns

string

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

features IList<string>
c0 Cons
c1 Cons
punct1s ICollection<Parse>
bigram bool

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

features IList<string>

The list of features.

c0 Cons

The first node.

c1 Cons

The second node.

c2 Cons

The third node.

punct1s ICollection<Parse>

The punctuation between the first and second node.

punct2s ICollection<Parse>

The punctuation between the second and third node.

trigram bool

Specifies whether lexical tri-gram features between these nodes should be generated.

bigram1 bool

Specifies whether lexical bi-gram features between the first and second node should be generated.

bigram2 bool

Specifies 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

p Parse
i int

Returns

string

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

rf IList<Parse>

The current right frontier.

nodes Parse[]

The array to be populated.

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

p Parse

The parse which stats teh production.

includePunctuation bool

Whether 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

punct Parse

The punctuation which is in context.

i int

The 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

punct Parse

The punctuation which is in context.

i int

The 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

node Parse

A surrounding node.

i int

The index of the surrounding node with respect to the completed node.

type string

The type of the completed node.

punctuation ICollection<Parse>

The punctuation adjacent and between the specified surrounding node.

features IList<string>

A list to which features are added.