public double[] transform(string sentence, string type) { sentence = RemoveSpecialCharacters(sentence);//.Replace("*", "").Replace(",", "").Replace("(", "").Replace(")", ""); sentence = String.Join(" ", sentence.Split(' ').Where(x => !StopWords.IsMatch(x.ToLower().Trim()))); if (type == "3-grams") { return(GetNGramsVector(sentence)); } else if (type == "words") { return(GetWordsVector(sentence)); } else { return(GetLettersVector(sentence)); } }
public void addSentence(string sentence) { sentence = RemoveSpecialCharacters(sentence); var sentenceWithoutStopWords = String.Join(" ", sentence.Split(' ').Where(x => !StopWords.IsMatch(x.ToLower().Trim()))); string[] result = sentenceWithoutStopWords.Trim().Split(' '); // string sentenceWithoutStopWords = ""; foreach (var r in result) { if (r.Length > 1) { words.Add(r); } //sentenceWithoutStopWords += r; } createNGrams(sentenceWithoutStopWords.Replace(" ", "")); }