public nGram(string s) { this.s = s; c = 1; n = null; amunt++; }
static void Main(string[] args) { Console.OutputEncoding = Encoding.Unicode; // Program.preparefile(); StreamReader sr = File.OpenText("out2.txt"); string text = ""; while (!sr.EndOfStream) { text = text + " " + sr.ReadLine(); } sr.Dispose(); //WriteLine(text); nGram[] ht = new nGram[4567]; // nGram tmpNG = null; WriteLine(ht[1]); string tmpSt; int tmp; for (int i = 0; i < text.Length - 2; i++) { tmpSt = "" + text[i] + text[i + 1] + text[i + 2]; tmp = hashValue(tmpSt, 0); nGram tmpNG; //= ht[tmp]; //tmpNG = &ht[tmp]; update(out tmpNG, ref ht[tmp]); //<<=== while (tmpNG != null && !(tmpNG.text.Equals(tmpSt))) { tmpNG = tmpNG.next; } if (tmpNG == null) { tmpNG = new nGram(tmpSt); } else { tmpNG.inc(); } } Read(); }
public static void update(out nGram a, ref nGram b) { a = b; }
public nGram operator =(nGram ng) { this.c = ng.c; this.n = ng.n; this.t = ng.s; }