WikiCrawler/Utility/CategoryTranslation.cs
/// <summary>
/// Saves out any cached category data to files.
/// </summary>
Saves out any cached category data to files.
Saves out any cached category data to files .
public static void SaveOut()
		{
			string categoryMappingsFile = Path.Combine(Configuration.DataDirectory, "category_mappings.json");
			using (StreamWriter writer = new StreamWriter(new FileStream(categoryMappingsFile, FileMode.Create), Encoding.UTF8))
			{
				List<KeyValuePair<string, CategoryMappingData>> flatMap = s_categoryMap.ToList();
				writer.WriteLine("{");
				bool isFirst = true;
				foreach (KeyValuePair<string, CategoryMappingData> kv in flatMap.OrderByDescending(kv => kv.Value.Usage))
				{
					if (!isFirst)
					{
						writer.WriteLine(",");
					}
					writer.WriteLine("\t" + JsonConvert.ToString(kv.Key) + ": { \"Usage\":" + kv.Value.Usage.ToString() + ",");
					string cats = JsonConvert.SerializeObject(kv.Value.Cats);
					writer.Write("\t\t\"Cats\": " + cats + "}");
					isFirst = false;
				}
				writer.WriteLine("}");
			}
			CategoryTree.Save(Path.Combine(Configuration.DataDirectory, "category_tree.txt"));
		}
public static void SaveOut ( ) { string categoryMappingsFile = Path . Combine ( Configuration . DataDirectory , " " ) ; using ( StreamWriter writer = new StreamWriter ( new FileStream ( categoryMappingsFile , FileMode . Create ) , Encoding . UTF8 ) ) { List < KeyValuePair < string , CategoryMappingData > > flatMap = s_categoryMap . ToList ( ) ; writer . WriteLine ( " " ) ; bool isFirst = true ; foreach ( KeyValuePair < string , CategoryMappingData > kv in flatMap . OrderByDescending ( kv => kv . Value . Usage ) ) { if ( ! isFirst ) { writer . WriteLine ( " " ) ; } writer . WriteLine ( " \t " + JsonConvert . ToString ( kv . Key ) + " \" \" " + kv . Value . Usage . ToString ( ) + " " ) ; string cats = JsonConvert . SerializeObject ( kv . Value . Cats ) ; writer . Write ( " \t \t \" \" " + cats + " " ) ; isFirst = false ; } writer . WriteLine ( " " ) ; } CategoryTree . Save ( Path . Combine ( Configuration . DataDirectory , " " ) ) ; }
Saves out any cached category data to files.
Saves out any cached category data to files .
//write category map