Exemplo n.º 1
0
        private static void LoadCorpus(Corpus corpus, string source)
        {
            XmlDocument corpusXML = new XmlDocument();

            corpusXML.Load(@"res\corpus\" + source + ".xml");
            foreach (XmlNode textNode in corpusXML.DocumentElement.ChildNodes)
            {
                if (textNode.ChildNodes.Count == 1)
                {
                    //ProgressForm.Bug("Lonely node found in corpus :(");
                    continue;
                }
                else if (textNode.SelectSingleNode("ru") == null)
                {
                    //ProgressForm.Bug("Rus missing from node");
                    continue;
                }
                else
                {
                    string ru = HttpUtility.HtmlDecode(textNode.SelectSingleNode("ru").InnerText);
                    if (!corpus.ContainsKey(ru))
                    {
                        corpus[ru] = new ConcurrentDictionary <string, string>();
                    }
                    foreach (XmlNode langNode in textNode.ChildNodes)
                    {
                        if (langNode.Name != "ru")
                        {
                            corpus[ru][langNode.Name] = HttpUtility.HtmlDecode(langNode.InnerText);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 private static bool GetFromSpecificCorpus(Corpus corpus, string text, out string result)
 {
     if (corpus.ContainsKey(text) && corpus[text].ContainsKey(PDDLanguage.Current.GoogleCode))
     {
         result = corpus[text][PDDLanguage.Current.GoogleCode];
         return(true);
     }
     result = null;
     return(false);
 }