Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Combining both vadz's answer and im_a_noob's answer, you should be able to read your words.txt file and put it into a dictionary.</p> <pre><code> Dictionary&lt;string, double&gt; wordDictionary = new Dictionary&lt;string, double&gt;(); using (FileStream fileStream = new FileStream(FILENAME, FileMode.Open, FileAccess.Read)) { using (StreamReader reader = new StreamReader(fileStream)) { int lineCount = 0; int skippedLine = 0; while( !reader.EndOfStream) { string[] fields = reader.ReadLine().Split('\t'); string word = fields[0]; double value = 0; lineCount++; //this check verifies there are two elements, tries to parse the second value and checks that the word //is not already in the dictionary if (fields.Count() == 2 &amp;&amp; double.TryParse(fields[1], out value) &amp;&amp; !wordDictionary.ContainsKey(word)) { wordDictionary.Add(word, value); } else{ skippedLine++; } } Console.WriteLine(string.Format("Total Lines Read: {0}", lineCount)); Console.WriteLine(string.Format("Lines Skipped: {0}", skippedLine)); Console.WriteLine(string.Format("Expected Entries in Dictonary: {0}", lineCount - skippedLine)); Console.WriteLine(string.Format("Actual Entries in Dictionary: {0}", wordDictionary.Count())); reader.Close(); } fileStream.Close(); } </code></pre> <p>To score the sentences you could use something like the following.</p> <pre><code> string fileText = File.ReadAllText(COMMENTSTEXT); //COMMENTSTEXT = comments.txt // assumes sentences end with a period, won't take into account any other periods in sentence var sentences = fileText.Split('.'); foreach( string sentence in sentences ) { double sentenceScore = 0; foreach (KeyValuePair&lt;string, double&gt; word in wordDictionary) { sentenceScore += sentence.Split(' ').Count(w =&gt; w == word.Key) * word.Value; } Console.WriteLine(string.Format("Sentence Score = {0}", sentenceScore)); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload