private static void AddPlural(string rule, string replacement) { Plurals.Add(new Rule(rule, replacement)); }
/// <summary> /// Call this method to get the singular /// version of a plural English word. /// </summary> /// <param name="word">The word to turn into a singular</param> /// <returns>The singular word</returns> static void Main() { int counter = 0; string line; // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader(@"/afs/inf.ed.ac.uk/user/a/agkaniat/Documents/Codetests/daisy-spsm/queryRespond/deplDatasetNames.txt"); while ((line = file.ReadLine()) != null) { Regex r = new Regex(" +"); //specify delimiter (spaces) string [] words = r.Split(line); //(convert string to array of words) List <string> newWords = new List <string>(); foreach (String word in words) { Plurals.ToSingular(word); //outputWriter.Write(Plurals.ToSingular(word)); newWords.Add(Plurals.ToSingular(word)); //.Replace(word,Plurals.ToSingular(word))); //System.Console.WriteLine (Plurals.ToSingular(word)); } using (StreamWriter outputWriter = File.AppendText(@"/afs/inf.ed.ac.uk/user/a/agkaniat/Documents/Codetests/daisy-spsm/queryRespond/newdeplDatasetNames.txt")) { foreach (String newWord in newWords) { System.Console.Write(newWords); outputWriter.Write(newWord); } outputWriter.WriteLine(" "); } counter++; } new System.IO.StreamReader(@"/afs/inf.ed.ac.uk/user/a/agkaniat/Documents/Codetests/daisy-spsm/queryRespond/deplQueryDatasets.txt"); while ((line = file.ReadLine()) != null) { Regex r = new Regex(" +"); //specify delimiter (spaces) string [] words = r.Split(line); //(convert string to array of words) List <string> newWords = new List <string>(); foreach (String word in words) { Plurals.ToSingular(word); //outputWriter.Write(Plurals.ToSingular(word)); newWords.Add(Plurals.ToSingular(word)); //.Replace(word,Plurals.ToSingular(word))); //System.Console.WriteLine (Plurals.ToSingular(word)); } using (StreamWriter outputWriter = File.AppendText(@"/afs/inf.ed.ac.uk/user/a/agkaniat/Documents/Codetests/daisy-spsm/queryRespond/newdeplQueryDatasets.txt")) { foreach (String newWord in newWords) { System.Console.Write(newWords); outputWriter.Write(newWord); } outputWriter.WriteLine(" "); } counter++; } file.Close(); System.Console.WriteLine("There were {0} lines.", counter); // Suspend the screen. System.Console.ReadLine(); //END }