Beispiel #1
0
        public static string GetMeaning(string word)
        {
            word = word.ToLower();
            var ch = word[0];

            if (word.Length > 0 && ch >= 'a' && ch <= 'z')
            {
                var path = "dictionary//gcide//gcide_" + ch.ToString() + "-entries.json";
                var json = System.IO.File.ReadAllText(path);
                var rss  = JObject.Parse(json);
                if (rss[word] != null && rss[word]["definitions"] != null)
                {
                    var explanation = Phonetic.GetPhonetic(word) + System.Environment.NewLine;
                    var builder     = new StringBuilder();
                    builder.Append(explanation);
                    for (int i = 0; i < rss[word]["definitions"].Count(); i++)
                    {
                        var wd   = rss[word]["definitions"][i];
                        var defi = (string)wd["definition"];
                        var pos  = (string)wd["part_of_speech"];
                        if (String.IsNullOrEmpty(pos) == false)
                        {
                            builder.Append(Convert.ToString(i + 1) + "  " + pos + "  ");
                        }
                        if (String.IsNullOrEmpty(defi) == false)
                        {
                            builder.Append(defi + "  ");
                        }
                        if (String.IsNullOrEmpty(explanation) == false)
                        {
                            builder.Append(System.Environment.NewLine);
                        }
                        else
                        {
                            builder.Clear();
                        }
                    }
                    return(builder.ToString());
                }
                return("");
            }
            else
            {
                return("");
            }
        }
        public MonetPhoneticStore(string phoneListFile)
        {
            var phonesXml      = File.ReadAllText(phoneListFile);
            var phonesDocument = XDocument.Parse(phonesXml);

            PhoneticPostures = phonesDocument
                               .Element("Monet")
                               .Element("MainPhoneList")
                               .Elements("Phone")
                               .Select(phone => {
                var elements   = phone.Elements().Where(x => x.Name != "Category");
                var categories = phone.Elements().Where(x => x.Name == "Category");
                var phonetic   = new Phonetic()
                {
                    Name = phone.Attribute("name").Value.Contains("'")
              ? "'" + phone.Attribute("name").Value.Replace("'", "")
              : phone.Attribute("name").Value,
                    Categories = categories.Select(category =>
                                                   (Category)Enum.Parse(typeof(Category), category.Attribute("name").Value, true)),
                    AspVol         = GetDoubleByName(elements, "aspVol"),
                    GlotVol        = GetDoubleByName(elements, "glotVol"),
                    Duration       = GetDoubleByName(elements, "duration"),
                    FricBW         = GetDoubleByName(elements, "fricBW"),
                    FricCF         = GetDoubleByName(elements, "fricCF"),
                    FricPos        = GetDoubleByName(elements, "fricPos"),
                    FricVol        = GetDoubleByName(elements, "fricVol"),
                    MicroInt       = GetDoubleByName(elements, "microInt"),
                    Velum          = GetDoubleByName(elements, "velum"),
                    Qssa           = GetDoubleByName(elements, "qssa"),
                    Qssb           = GetDoubleByName(elements, "qssb"),
                    RadiusSegments = Enumerable.Range(1, 8).Select(x => GetDoubleByName(elements, $"r{x}")),
                };
                return(new KeyValuePair <string, Phonetic>(phonetic.Name, phonetic));
            })
                               .ToDictionary(x => x.Key, x => x.Value);
        }
Beispiel #3
0
 public static string GetPhoonetic(string word)
 {
     return(Phonetic.GetPhonetic(word));
 }