I have a collection of IEnumerable<sentence> (sentence = string)
I want to split all sentences to words (ex: .Select(t => t.Split(' ')), and after this I need to group this query by words to get a list of unique words.
Please, Help
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First guess:
However, you probably want to remove punctuation and go to lowercase as well; you can do that by passing more characters to Split and asking it to remove empty strings, and then calling
ToLowerInvarianton the result.If the input sentences are from SQL, it will be
IQueryableinstead ofIEnumerable, so Linq will attempt to execute the query in the database, which limits what you are able to do.To make Linq execute in memory, giving you the full power of the BCL, use:
The extra call to
AsEnumerable()gets the raw results from the database into memory, so you can then proceed as normal.