2018-06-13 22:17:35 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
2018-08-15 22:37:23 +00:00
|
|
|
|
namespace BotSharp.NLP.Tokenize
|
2018-06-13 22:17:35 +00:00
|
|
|
|
{
|
2018-08-15 22:37:23 +00:00
|
|
|
|
public class Token
|
2018-06-13 22:17:35 +00:00
|
|
|
|
{
|
2018-08-16 22:27:50 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The original word text.
|
|
|
|
|
|
/// </summary>
|
2018-06-13 22:17:35 +00:00
|
|
|
|
public string Text { get; set; }
|
2018-08-16 22:27:50 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The offset of word
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int Start { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The simple part-of-speech tag.
|
|
|
|
|
|
/// Not widely used, Tag is more general.
|
|
|
|
|
|
/// </summary>
|
2018-08-07 22:13:55 +00:00
|
|
|
|
public string Pos { get; set; }
|
2018-08-16 22:27:50 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The detailed part-of-speech tag.
|
|
|
|
|
|
/// https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html
|
|
|
|
|
|
/// </summary>
|
2018-08-07 22:13:55 +00:00
|
|
|
|
public string Tag { get; set; }
|
2018-08-16 22:27:50 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The base form of the word.
|
|
|
|
|
|
/// </summary>
|
2018-08-07 22:13:55 +00:00
|
|
|
|
public string Lemma { get; set; }
|
2018-08-16 22:27:50 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The word shape – capitalisation, punctuation, digits.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string Shape { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Is the token an alpha character?
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsAlpha { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Is the token part of a stop list, i.e. the most common words of the language?
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsStop { get; set; }
|
|
|
|
|
|
|
2018-06-13 22:17:35 +00:00
|
|
|
|
public int End
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2018-08-16 22:27:50 +00:00
|
|
|
|
return Start + Text.Length - 1;
|
2018-06-13 22:17:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-08-17 20:49:29 +00:00
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
|
{
|
|
|
|
|
|
return $"{Text} {Start} {Pos}";
|
|
|
|
|
|
}
|
2018-06-13 22:17:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|