Пример #1
0
        /// <summary>
        /// Bulk-converts BuNaMo entries from minimal format into expanded format.
        /// Outputs each entry into an individual file.
        /// </summary>
        public static void Go()
        {
            bool          doFilter        = false;
            List <string> filterNicknames = new List <string>();
            //if(doFilter) filterNicknames=FilterFromNeidTrGrams();
            //if(doFilter) filterNicknames=FilterFromFile(filterNicknames);
            //NB: the nicknames returned by these have been lower-cased

            PrinterNeid printer = new PrinterNeid();

            foreach (string file in Directory.GetFiles(@"C:\MBM\michmech\BuNaMo\noun"))
            {
                XmlDocument doc  = new XmlDocument(); doc.Load(file);
                Noun        noun = new Noun(doc);
                if (!doFilter || filterNicknames.Contains(noun.getNickname().ToLower()))
                {
                    StreamWriter writer = new StreamWriter(@"C:\MBM\michmech\Gramadan\NeidOutput\" + noun.getNickname() + ".xml");
                    writer.Write(PrettyPrintXml(printer.printNounXml(noun)));
                    writer.Close();
                }
            }
            foreach (string file in Directory.GetFiles(@"C:\MBM\michmech\BuNaMo\adjective"))
            {
                XmlDocument doc       = new XmlDocument(); doc.Load(file);
                Adjective   adjective = new Adjective(doc);
                if (!doFilter || filterNicknames.Contains(adjective.getNickname().ToLower()))
                {
                    StreamWriter writer = new StreamWriter(@"C:\MBM\michmech\Gramadan\NeidOutput\" + adjective.getNickname() + ".xml");
                    writer.Write(PrettyPrintXml(printer.printAdjectiveXml(adjective)));
                    writer.Close();
                }
            }
            foreach (string file in Directory.GetFiles(@"C:\MBM\michmech\BuNaMo\nounPhrase"))
            {
                XmlDocument doc = new XmlDocument(); doc.Load(file);
                NP          np  = new NP(doc);
                if (!doFilter || filterNicknames.Contains(np.getNickname().ToLower()))
                {
                    StreamWriter writer = new StreamWriter(@"C:\MBM\michmech\Gramadan\NeidOutput\" + np.getNickname() + ".xml");
                    writer.Write(PrettyPrintXml(printer.printNPXml(np)));
                    writer.Close();
                }
            }
            foreach (string file in Directory.GetFiles(@"C:\MBM\michmech\BuNaMo\preposition"))
            {
                XmlDocument doc         = new XmlDocument(); doc.Load(file);
                Preposition preposition = new Preposition(doc);
                if (!doFilter || filterNicknames.Contains(preposition.getNickname().ToLower()))
                {
                    StreamWriter writer = new StreamWriter(@"C:\MBM\michmech\Gramadan\NeidOutput\" + preposition.getNickname() + ".xml");
                    writer.Write(PrettyPrintXml(printer.printPrepositionXml(preposition)));
                    writer.Close();
                }
            }
            foreach (string file in Directory.GetFiles(@"C:\MBM\michmech\BuNaMo\verb"))
            {
                XmlDocument doc  = new XmlDocument(); doc.Load(file);
                Verb        verb = new Verb(doc);
                if (!doFilter || filterNicknames.Contains(verb.getNickname().ToLower()))
                {
                    StreamWriter writer = new StreamWriter(@"C:\MBM\michmech\Gramadan\NeidOutput\" + verb.getNickname() + ".xml");
                    writer.Write(PrettyPrintXml(printer.printVerbXml(verb)));
                    writer.Close();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Bulk-converts BuNaMo entries from minimal format into expanded format.
        /// Combines all entries into a single large file.
        /// </summary>
        public static void GoBulk()
        {
            PrinterNeid  printer = new PrinterNeid(false);
            StreamWriter writer;

            writer = new StreamWriter(@"C:\MBM\Gramadan\NeidOutputBulk\nouns.xml");
            writer.WriteLine("<?xml version='1.0' encoding='utf-8'?>");
            writer.WriteLine("<?xml-stylesheet type='text/xsl' href='!lemmas.xsl'?>");
            writer.WriteLine("<lemmas>");
            foreach (string file in Directory.GetFiles(@"C:\MBM\Gramadan\BuNaMo\noun"))
            {
                XmlDocument doc  = new XmlDocument(); doc.Load(file);
                Noun        noun = new Noun(doc);
                writer.WriteLine(printer.printNounXml(noun));
            }
            writer.WriteLine("</lemmas>");
            writer.Close();

            writer = new StreamWriter(@"C:\MBM\Gramadan\NeidOutputBulk\nounPhrases.xml");
            writer.WriteLine("<?xml version='1.0' encoding='utf-8'?>");
            writer.WriteLine("<?xml-stylesheet type='text/xsl' href='!lemmas.xsl'?>");
            writer.WriteLine("<lemmas>");
            foreach (string file in Directory.GetFiles(@"C:\MBM\Gramadan\BuNaMo\nounPhrase"))
            {
                XmlDocument doc = new XmlDocument(); doc.Load(file);
                NP          np  = new NP(doc);
                writer.WriteLine(printer.printNPXml(np));
            }
            writer.WriteLine("</lemmas>");
            writer.Close();

            writer = new StreamWriter(@"C:\MBM\Gramadan\NeidOutputBulk\adjectives.xml");
            writer.WriteLine("<?xml version='1.0' encoding='utf-8'?>");
            writer.WriteLine("<?xml-stylesheet type='text/xsl' href='!lemmas.xsl'?>");
            writer.WriteLine("<lemmas>");
            foreach (string file in Directory.GetFiles(@"C:\MBM\Gramadan\BuNaMo\adjective"))
            {
                XmlDocument doc = new XmlDocument(); doc.Load(file);
                Adjective   a   = new Adjective(doc);
                writer.WriteLine(printer.printAdjectiveXml(a));
            }
            writer.WriteLine("</lemmas>");
            writer.Close();

            writer = new StreamWriter(@"C:\MBM\Gramadan\NeidOutputBulk\prepositions.xml");
            writer.WriteLine("<?xml version='1.0' encoding='utf-8'?>");
            writer.WriteLine("<?xml-stylesheet type='text/xsl' href='!lemmas.xsl'?>");
            writer.WriteLine("<lemmas>");
            foreach (string file in Directory.GetFiles(@"C:\MBM\Gramadan\BuNaMo\preposition"))
            {
                XmlDocument doc = new XmlDocument(); doc.Load(file);
                Preposition p   = new Preposition(doc);
                writer.WriteLine(printer.printPrepositionXml(p));
            }
            writer.WriteLine("</lemmas>");
            writer.Close();

            writer = new StreamWriter(@"C:\MBM\Gramadan\NeidOutputBulk\verbs.xml");
            writer.WriteLine("<?xml version='1.0' encoding='utf-8'?>");
            writer.WriteLine("<?xml-stylesheet type='text/xsl' href='!lemmas.xsl'?>");
            writer.WriteLine("<lemmas>");
            foreach (string file in Directory.GetFiles(@"C:\MBM\Gramadan\BuNaMo\verb"))
            {
                XmlDocument doc = new XmlDocument(); doc.Load(file);
                Verb        v   = new Verb(doc);
                writer.WriteLine(printer.printVerbXml(v));
            }
            writer.WriteLine("</lemmas>");
            writer.Close();
        }