Class POSDictionary

Namespace
NOpenNLP.Tools.Postag
Assembly
NOpenNLP.Tools.dll

Provides a means of determining which tags are valid for a particular word based on a tag dictionary read from a file.

public class POSDictionary : IEnumerable<string>, IEnumerable, IMutableTagDictionary, ITagDictionary, ISerializableArtifact
Inheritance
POSDictionary
Implements
Inherited Members

Constructors

POSDictionary()

Initializes an empty case sensitive POSDictionary.

public POSDictionary()

POSDictionary(bool)

Initializes an empty POSDictionary.

public POSDictionary(bool caseSensitive)

Parameters

caseSensitive bool

the POSDictionary case sensitivity

Properties

ArtifactSerializerClass

Retrieves the class which can serialize and recreate this artifact.
Note: The serializer class must have a public zero argument constructor or an exception is thrown during model serialization/loading.

public virtual Type ArtifactSerializerClass { get; }

Property Value

Type

the corresponding IArtifactSerializer class.

IsCaseSensitive

Whether if the dictionary is case sensitive or not

public virtual bool IsCaseSensitive { get; }

Property Value

bool

true if the dictionary is case sensitive

Methods

Create(Stream)

Creates a new POSDictionary from a provided Stream.

After creation is finished the provided Stream is closed.

public static POSDictionary Create(Stream @in)

Parameters

in Stream

Returns

POSDictionary

the pos dictionary

Exceptions

IOException
InvalidFormatException

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetEnumerator()

Retrieves an iterator over all words in the dictionary.

public virtual IEnumerator<string> GetEnumerator()

Returns

IEnumerator<string>

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

GetTags(string)

Returns a list of valid tags for the specified word.

public virtual string[]? GetTags(string word)

Parameters

word string

The word.

Returns

string[]

A list of valid tags for the specified word or null if no information is available for that word.

Put(string, params string[])

Associates the specified tags with the specified word. If the dictionary previously contained keys for the word, the old tags are replaced by the specified tags.

public virtual string[]? Put(string word, params string[] tags)

Parameters

word string

word with which the specified tags is to be associated

tags string[]

tags to be associated with the specified word

Returns

string[]

the previous tags associated with the word, or null if there was no mapping for word.

Serialize(Stream)

Writes the POSDictionary to the given Stream;

After the serialization is finished the provided Stream remains open.

public virtual void Serialize(Stream @out)

Parameters

out Stream

the Stream to write the dictionary into.

Exceptions

IOException

if writing to the Stream fails

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.