Skip to content

Instantly share code, notes, and snippets.

@sbrl
Created September 9, 2015 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbrl/459826d8f30ba6a60cae to your computer and use it in GitHub Desktop.
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.
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