I have an indexing of terms in my system, which word is being used among users' messages, so I created a Termos
class and made a loop to generate a new object for each word, I will know in which Flow (User's Page) and Information (Flow Message) that Term was used.
My doubts are as follows: If the user types something like "Hi, how are you?" it will save "Hello!" is well?" along with some elements that I do not want, commas, exclamations and special characters. Is it possible to set exceptions for this? "Say" to Split () not pick up these characters?
Here's the snippet of code I'm using:
Termos.cs
namespace ProjetoASPNETMVC.Models
{
public class Termos
{
[Key]
public int TermoID { get; set; }
public String Palavra { get; set; }
public Fluxo Fluxo { get; set; }
public Informacao Informacao { get; set; }
}
}
InformationController.cs
for (int x = 0; x < i.Mensagem.Split(' ').Length; x++)
{
Termos termo = new Termos();
termo.Palavra = i.Mensagem.Split(' ')[x].ToUpper();
termo.Fluxo = db.Fluxo.ToList().Where(j => j.Informacoes.Contains(i)).FirstOrDefault();
termo.Informacao = i;
db.Termos.Add(termo);
}
I suppose it's possible to do this if I count character to character, I would like another alternative, I guess if you check letter by letter, it will kill system performance.