// FUNGSI UTAMA // Mengklasifikasikan 'tweet' berdasarkan 'keyword' ke dalam dinas yang tepat pada dinasList public int classify(string tweet_initial) { int index = -1, iDinas = -1, i = 0; int min = -1; string str = null; string tweet = corrector.Corrected(tweet_initial); // Search keyword in tweet using KMP foreach (string[] dinas in keyword) { foreach (string key in dinas) { if (!useBm) { index = KnuthMorrisPratt.KMPSearch(tweet, key); } else { index = BoyerMoore.BMSearch(tweet, key); } if (index != -1) { if (min == -1) { min = index; str = key; iDinas = i; } else { if (index < min) { min = index; str = key; iDinas = i; } } } } i++; } Console.WriteLine(); if (min != -1) { Console.WriteLine("Found {0} in index {1}\nDisposisi \"{2}\" ke dinas {3}", str, min, tweet, this.dinasList [iDinas]); data.Add(iDinas); return(iDinas); } else { Console.WriteLine("Couldn't find any keyword in tweet\nDisposisi \"{0}\" ke dinas {1}", tweet, this.dinasList [dinasList.Count - 1]); data.Add(dinasList.Count - 1); return(dinasList.Count - 1); } }