BotSharp/BotSharp.NLP/Stem/StemmerFactory.cs

36 lines
979 B
C#
Raw Normal View History

2018-08-16 04:17:42 +00:00
using BotSharp.NLP.Tokenize;
using System;
using System.Collections.Generic;
using System.Text;
namespace BotSharp.NLP.Stem
{
/// <summary>
/// BotSharp Stemmer Factory
/// In linguistic morphology and information retrieval,
/// stemming is the process of reducing inflected (or sometimes derived) words to their word stem,
/// base or root form—generally a written word form.
/// </summary>
/// <typeparam name="IStem"></typeparam>
public class StemmerFactory<IStem> where IStem : IStemmer, new()
{
2018-08-17 20:49:29 +00:00
private SupportedLanguage _lang { get; set; }
2018-08-16 04:17:42 +00:00
private IStem _stemmer;
2018-08-17 20:49:29 +00:00
private StemOptions _options;
public StemmerFactory(StemOptions options, SupportedLanguage lang)
2018-08-16 04:17:42 +00:00
{
2018-08-17 20:49:29 +00:00
_lang = lang;
_options = options;
2018-08-16 04:17:42 +00:00
_stemmer = new IStem();
}
2018-08-17 20:49:29 +00:00
public string Stem(string word)
2018-08-16 04:17:42 +00:00
{
2018-08-17 20:49:29 +00:00
return _stemmer.Stem(word, _options);
2018-08-16 04:17:42 +00:00
}
}
}