using System; using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; namespace BotSharp.NLP.Tokenize { public class Token { /// /// The original word text. /// public string Text { get; set; } /// /// The offset of word /// public int Start { get; set; } /// /// The simple part-of-speech tag. /// Not widely used, Tag is more general. /// public string Pos { get; set; } /// /// The detailed part-of-speech tag. /// https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html /// public string Tag { get; set; } /// /// The base form of the word. /// public string Lemma { get; set; } /// /// The word shape – capitalisation, punctuation, digits. /// public string Shape { get; set; } /// /// Is the token an alpha character? /// public bool IsAlpha { get { return Regex.IsMatch(Text, @"^[a-zA-Z]+$"); } } /// /// Is the token part of a stop list, i.e. the most common words of the language? /// public bool IsStop { get; set; } public int End { get { return Start + Text.Length; } } public override string ToString() { return $"{Text} {Start} {Pos}"; } public double Vector { get; set; } } }