BotSharp/BotSharp.NLP/Classify/WordFeatureExtractor.cs

24 lines
682 B
C#
Raw Normal View History

2018-09-10 03:56:32 +00:00
using System;
using System.Collections.Generic;
using System.Text;
using BotSharp.Algorithm.Features;
using BotSharp.NLP.Tokenize;
namespace BotSharp.NLP.Classify
{
public class WordFeatureExtractor : ITextFeatureExtractor
{
public List<Feature> GetFeatures(List<Token> words)
{
string text = words[0].Text;
var features = new List<Feature>();
features.Add(new Feature("alwayson", "True"));
features.Add(new Feature("startswith", text[0].ToString().ToLower()));
features.Add(new Feature("endswith", text[text.Length - 1].ToString().ToLower()));
return features;
}
}
}