public GreekDictionary Parse()
        {
            GreekDictionary dictionary = new GreekDictionary();

            using (var stream = File.OpenRead("dodson.xml"))
            {
                var serializer = new XmlSerializer(typeof(TEI));
                var result = serializer.Deserialize(stream) as TEI;
                Console.WriteLine("parsed dictionary");

                foreach(var entry in result.entry)
                {
                    Console.WriteLine("##############");
                    Console.WriteLine(entry.n);

                    int strongNumber = 0;
                    string greek = string.Empty;

                    var splits = (entry.n ?? string.Empty).Split(' ');
                    if (splits != null && splits.Length == 3)
                    {
                        int.TryParse(splits[2], out strongNumber);
                        greek = splits[0].Trim();
                    }

                    if (strongNumber > 0)
                    {
                        var word = new WordDef();
                        word.StrongNumber = strongNumber;
                        word.Greek = greek;

                        foreach (var form in entry.GetformRows())
                        {
                            word.GreekOrth = form.orth;
                            foreach (var def in form.GetdefRows())
                            {
                                Console.WriteLine("def: " + def.role + " " + def.def_Text);
                                if (def.role == "brief")
                                    word.Definition = def.def_Text;
                                if (def.role == "full")
                                    word.LongDefinition = def.def_Text;
                            }
                        }

                        dictionary.AddWord(word);
                    }
                }
            }

            var egerthe = dictionary.FindWord(1453);
            var json = dictionary.ToJavaScript();

            return dictionary;
        }
示例#2
0
 public void AddWord(WordDef def)
 {
     _strongLookup.Add(def.StrongNumber, def);
 }
示例#3
0
 public void AddLookup(string greek, WordDef word)
 {
     if (!_wordLookup.ContainsKey(greek))
         _wordLookup.Add(greek, word);
 }