Example #1
0
        private void readTrans(EdictEntryBuilder entry, XmlReader xml)
        {
            DictionarySense sense = new DictionarySense();

            while (xml.Read())
            {
                if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "trans")
                {
                    break;
                }
                if (xml.NodeType == XmlNodeType.Element)
                {
                    if (xml.Name == "trans_det")
                    {
                        string lang = xml.GetAttribute("xml:lang");
                        if (lang == "eng")
                        {
                            lang = null;
                        }
                        string value = xml.ReadString();
                        sense.addGloss(lang, value);
                    }
                    else
                    {
                        switch (xml.Name)
                        {
                        case "name_type":
                            entry.nameType = fromEntity(xml);
                            break;
                        }
                    }
                }
            }
            entry.addSense(sense, 1.0, 1.0);
        }
Example #2
0
        private void readSense(EdictEntryBuilder entry, XmlReader xml)
        {
            DictionarySense sense      = new DictionarySense();
            double          globalMult = 1.0;
            double          kanaMult   = 0.8;

            while (xml.Read())
            {
                if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "sense")
                {
                    break;
                }
                if (xml.NodeType == XmlNodeType.Element)
                {
                    if (xml.Name == "gloss")
                    {
                        string lang = xml.GetAttribute("xml:lang");
                        if (lang == "eng")
                        {
                            lang = null;
                        }
                        string value = xml.ReadString();
                        sense.addGloss(lang, value);
                    }
                    else
                    {
                        switch (xml.Name)
                        {
                        case "pos":
                            entry.addPOS(fromEntity(xml));
                            break;

                        case "field":
                        case "misc":
                        case "dial":
                            string v = fromEntity(xml);
                            adjustMultipliers(v, ref globalMult, ref kanaMult);
                            sense.addMisc(v);
                            break;
                        }
                    }
                }
            }
            entry.addSense(sense, globalMult, kanaMult);
        }