/// <summary> /// 使用new以初始化句子模型 /// </summary> /// <param name="content">内容</param> /// <param name="author">作者</param> /// <param name="source">来源</param> /// <param name="ID">唯一ID</param> /// <param name="type">来源文件</param> public SModel(string content, string author, string source, string ID, SModelType type) { this.content = content; this.author = author; this.source = source; this.ID = ID; this.type = type; }
public SModel GetModel(SModelType type) { SModel temp; do { temp = GetModel(); }while (temp.type != type); return(temp); }
/// <summary> /// 获取单类型句子数量 /// </summary> /// <param name="type"></param> /// <returns></returns> public int GetCount(SModelType type) { switch (type) { case SModelType.Reading: return(reading.Count); case SModelType.Movies: return(movies.Count); default: return(songs.Count); } }
/// <summary> /// 从句子模型的 yml 字符串中提取句子模型对象 /// </summary> /// <param name="origin"></param> /// <param name="count"></param> /// <param name="type"></param> /// <returns></returns> static private SModel GetModel(string origin, int count, SModelType type) { List <string> Attributes = new List <string>(); for (int i = 0, len = SModel.Attributes.Length; i < len; i++) { Attributes.Add(RegexHelper.MatchEle(RegexHelper.elePattern, SModel.Attributes[i], origin)); } Attributes.Add(count.ToString()); string[] AttArr = Attributes.ToArray(); return(new SModel(AttArr[0], AttArr[1], AttArr[2], AttArr[3], type)); }
/// <summary> /// 从文件中读取句子模型字符串,并获取该文件中包含的模型列表 /// 获取的不同文件中的模型ID以不同的起点数量开始,电影10000,阅读20000,歌曲30000 /// </summary> /// <returns></returns> static private List <SModel> GetModels() { List <SModel> list = new List <SModel>(); int level = 1; foreach (var type in FileLists) { int i = level * 10000; string fileName = "resource/" + type.FileName; string origin = FileHelper.ReadFile(fileName); SModelType sType = type.Type; foreach (var item in RegexHelper.MatchObj(RegexHelper.objPattern, origin)) { list.Add(GetModel(item, i, sType)); i++; } level++; } return(list); }
public SourceType(string fileName, SModelType type) { this.FileName = fileName; this.Type = type; }