I am trying to make restraint I need to get the number of rows where the word came. To do this, I decided to read each line and then check if the word in the word is in this line, yes, remember the index of the line and pass this index to the list but if there are two words in a line Which are identical I need to show the index of this line twice, what is the best way to do this?
public static zero main (string [] args) {dictionary
And here is a problem
int m = IndexOf (line); NumberOfLine.Add (M);
How to get the number of lines for each word in the dictionary?
This is my last post: There is no way to solve this, but I am also a newbie C # and there are some things that I do not understand. If you can explain in more detail then I would be happy
This is an issue that is easy enough Given that instead of emphasizing the case of your use in the underlying object and / or trying to isolate individual collections, by creating your own class Keep indexing parity.
I will start by creating WordInfo objects:
public class WordInfo {public WordInfo (string word, int firstLineNumber) {this.Word = word; This.WordCount = 1; this. Linenbus = new list & lt; Int & gt; () {FirstLineNumber}; } Public string word {get} Set; } Public int WordCount {get; Set; } Public listing & lt; Int & gt; Line number {get; Set; }}
And then you can have your keyword-object object, one word of the string, WordInfo:
dictionary & lt; String, WordInfo & gt; ConcordanceDictionary = new dictionary & lt; String, WordInfo & gt; (); Int i = 1; Forward (File: Reed Lines ("C: \ TextType") (foreline (stripping word split word) (line). Olavar ()) (If (Concordance Dictionary. Continent that (word)) {concordanceDictionary.Add ( Word, new WordInfo (word, i));} Else {concordanceDictionary [word] .WordCount ++; if (! ConcordanceDictionary [word] .LineNumbers.Contains (i)) {concordanceDictionary [word] .LineNumbers.Add (i) ;}}} I ++;}
Then, if you still want to sort the WordInfo object:
list & lt; WordInfo & gt; ; Sorted WordInfos = concordanceDictionary.Values.OrderByDescending (a => a.WordCoun T) .Olist ();
Comments
Post a Comment