Created
September 9, 2015 06:37
-
-
Save sbrl/459826d8f30ba6a60cae to your computer and use it in GitHub Desktop.
Code to parse wikipedia's list of spelling correction into a format that @TheTypoMaster's code can understand. The headers / footers must be removed manually.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
StreamReader source = new StreamReader("wikipedia-spelling-corrections.txt"); | |
StreamWriter dest = new StreamWriter("wikipedia-spelling-corrections-new.txt"); | |
while(!source.EndOfStream) | |
{ | |
string nextLine = source.ReadLine(); | |
string[] parts = nextLine.Split(' '); | |
if (parts.Length != 2) | |
{ | |
Console.WriteLine("Length was {0}, not 2.", parts.Length); | |
return; | |
} | |
dest.WriteLine("{0} - {1}", parts[1], parts[0]); | |
} | |
source.Close(); | |
dest.Close(); | |
Console.WriteLine("Done."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment