Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public static string Serialize(Thesaurus thesaurus)
        {
            var settings = new JsonSerializerSettings {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            return(JsonConvert.SerializeObject(thesaurus, Formatting.Indented, settings));
        }
Esempio n. 3
0
 public void TestSetup()
 {
     _thesaurus = Thesaurus.Deserialize(File.ReadAllText(@"..\..\Dictionary.json"));
     _parser    = new Parser(_thesaurus);
 }
Esempio n. 4
0
 public void Setup()
 {
     _thesaurus = Thesaurus.Deserialize(File.ReadAllText(@"..\..\Dictionary.json"));
 }
Esempio n. 5
0
        public void Load_SmokeTest()
        {
            var thesaurus = Thesaurus.Deserialize(File.ReadAllText(@"..\..\Dictionary.json"));

            thesaurus.MorphTypes.Should().HaveCount(8);
        }