public static Thesaurus Deserialize(string jsonText) { var thesaurus = new Thesaurus(); var jsonRoot = JObject.Parse(jsonText); var jsonMorphTypes = (JObject)jsonRoot["morphTypes"]; foreach (var jsonMorphType in jsonMorphTypes) { var morphType = GetMorphType(jsonMorphType.Key); var morphTokens = new List <Token>(); for (var i = 0; i < jsonMorphType.Value.Count(); i++) { morphTokens.Add(new Token { Index = i, Value = jsonMorphType.Value[i].Value <string>(), MorphType = morphType }); } thesaurus.MorphTypes.Add(morphType, morphTokens); } return(thesaurus); }
public static string Serialize(Thesaurus thesaurus) { var settings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; return(JsonConvert.SerializeObject(thesaurus, Formatting.Indented, settings)); }
public void TestSetup() { _thesaurus = Thesaurus.Deserialize(File.ReadAllText(@"..\..\Dictionary.json")); _parser = new Parser(_thesaurus); }
public void Setup() { _thesaurus = Thesaurus.Deserialize(File.ReadAllText(@"..\..\Dictionary.json")); }
public void Load_SmokeTest() { var thesaurus = Thesaurus.Deserialize(File.ReadAllText(@"..\..\Dictionary.json")); thesaurus.MorphTypes.Should().HaveCount(8); }