using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace BotSharp.NLP.Corpus
{
///
/// It used to read labeled data which is seperated by file.
/// The same category data is in one file.
/// File name is the label.
///
public class LabeledPerFileNameReader
{
public List Read(ReaderOptions options)
{
string label = options.FileName.Split('.')[0];
var sentences = new List();
using (StreamReader reader = new StreamReader(Path.Combine(options.DataDir, options.FileName)))
{
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
if (!String.IsNullOrEmpty(line))
{
sentences.Add(new Sentence
{
Label = label,
Text = line
});
}
}
}
return sentences;
}
}
}