Beispiel #1
0
 internal ArgumentData(string name, IReadOnlyType type, IReadOnlyFunction owner, Preposition prep)
 {
     this.Name = name;
     this.Type = type;
     this.Owner = owner;
     this.AlternateAccess = prep;
 }
Beispiel #2
0
        /// <summary>
        /// 设置单据导入状态
        /// </summary>
        void SetDocumentImportStatus(string statusName, DataSources.EnumImportStaus importStaus, List <SysSQLString> listSql, string order_id, string order_type)
        {
            DataTable dt = DBHelper.GetTable("", "tb_balance_documents", "documents_id,documents_name", string.Format("order_id='{0}'", order_id), "", "");

            if (dt == null || dt.Rows.Count == 0)
            {
                return;
            }
            Preposition pre = new Preposition();

            foreach (DataRow dr in dt.Rows)
            {
                pre.AddID(dr["documents_id"], dr["documents_name"]);
            }
            listSql.AddRange(pre.GetSql(statusName, importStaus));
        }
Beispiel #3
0
 /// <summary>
 /// Resaves BuNaMo entries (for example to update their file names).
 /// </summary>
 public static void Resave()
 {
     foreach (string file in Directory.GetFiles(@"C:\MBM\Gramadan\BuNaMo\noun"))
     {
         XmlDocument  doc    = new XmlDocument(); doc.Load(file);
         Noun         noun   = new Noun(doc);
         StreamWriter writer = new StreamWriter(@"C:\MBM\Gramadan\BuNaMo\noun\" + noun.getNickname() + ".xml");
         writer.Write(PrettyPrintXml(noun.printXml().DocumentElement.OuterXml));
         writer.Close();
     }
     foreach (string file in Directory.GetFiles(@"C:\MBM\Gramadan\BuNaMo\adjective"))
     {
         XmlDocument  doc       = new XmlDocument(); doc.Load(file);
         Adjective    adjective = new Adjective(doc);
         StreamWriter writer    = new StreamWriter(@"C:\MBM\Gramadan\BuNaMo\adjective\" + adjective.getNickname() + ".xml");
         writer.Write(PrettyPrintXml(adjective.printXml().DocumentElement.OuterXml));
         writer.Close();
     }
     foreach (string file in Directory.GetFiles(@"C:\MBM\Gramadan\BuNaMo\nounPhrase"))
     {
         XmlDocument  doc    = new XmlDocument(); doc.Load(file);
         NP           np     = new NP(doc);
         StreamWriter writer = new StreamWriter(@"C:\MBM\Gramadan\BuNaMo2\nounPhrase\" + np.getNickname() + ".xml");
         writer.Write(PrettyPrintXml(np.printXml().DocumentElement.OuterXml));
         writer.Close();
     }
     foreach (string file in Directory.GetFiles(@"C:\MBM\Gramadan\BuNaMo\preposition"))
     {
         XmlDocument  doc         = new XmlDocument(); doc.Load(file);
         Preposition  preposition = new Preposition(doc);
         StreamWriter writer      = new StreamWriter(@"C:\MBM\Gramadan\BuNaMo2\preposition\" + preposition.getNickname() + ".xml");
         writer.Write(PrettyPrintXml(preposition.printXml().DocumentElement.OuterXml));
         writer.Close();
     }
     foreach (string file in Directory.GetFiles(@"C:\MBM\Gramadan\BuNaMo\verb"))
     {
         XmlDocument  doc    = new XmlDocument(); doc.Load(file);
         Verb         verb   = new Verb(doc);
         StreamWriter writer = new StreamWriter(@"C:\MBM\Gramadan\BuNaMo2\verb\" + verb.getNickname() + ".xml");
         writer.Write(PrettyPrintXml(verb.printXml().DocumentElement.OuterXml));
         writer.Close();
     }
 }
Beispiel #4
0
        /// <summary>
        /// Lists all entries in BuNaMo.
        /// </summary>
        public static void ListAll()
        {
            StreamWriter writer = new StreamWriter(@"C:\MBM\Gramadan\listAll.txt");

            foreach (string file in Directory.GetFiles(@"C:\MBM\Gramadan\BuNaMo\noun"))
            {
                XmlDocument doc  = new XmlDocument(); doc.Load(file);
                Noun        item = new Noun(doc);
                writer.WriteLine("ainmfhocal\t" + item.getLemma() + "\t" + item.getNickname());
            }
            foreach (string file in Directory.GetFiles(@"C:\MBM\Gramadan\BuNaMo\nounPhrase"))
            {
                XmlDocument doc  = new XmlDocument(); doc.Load(file);
                NP          item = new NP(doc);
                writer.WriteLine("frása ainmfhoclach\t" + item.getLemma() + "\t" + item.getNickname());
            }
            foreach (string file in Directory.GetFiles(@"C:\MBM\Gramadan\BuNaMo\adjective"))
            {
                XmlDocument doc  = new XmlDocument(); doc.Load(file);
                Adjective   item = new Adjective(doc);
                writer.WriteLine("aidiacht\t" + item.getLemma() + "\t" + item.getNickname());
            }
            foreach (string file in Directory.GetFiles(@"C:\MBM\Gramadan\BuNaMo\verb"))
            {
                XmlDocument doc  = new XmlDocument(); doc.Load(file);
                Verb        item = new Verb(doc);
                writer.WriteLine("briathar\t" + item.getLemma() + "\t" + item.getNickname());
            }
            foreach (string file in Directory.GetFiles(@"C:\MBM\Gramadan\BuNaMo\preposition"))
            {
                XmlDocument doc  = new XmlDocument(); doc.Load(file);
                Preposition item = new Preposition(doc);
                writer.WriteLine("réamhfhocal\t" + item.getLemma() + "\t" + item.getNickname());
            }
            writer.Close();
        }
 /// <summary>
 /// 设置单据导入状态
 /// </summary>
 void SetDocumentImportStatus(string statusName, DataSources.EnumImportStaus importStaus, List<SysSQLString> listSql, bool isSelected)
 {
     if (dgvDocuments.RowCount == 0 && dgvDocuments2.RowCount == 0)
     {
         return;
     }
     Preposition pre = new Preposition();
     foreach (DataGridViewRow dgvr in dgvDocuments.Rows)
     {
         if (isSelected)
         {
             object check = dgvr.Cells[colChk.Name].EditedFormattedValue;
             if (check != null && (bool)check)
             {
                 pre.AddID(dgvr.Cells[colOrderID.Name].Value, dgvr.Cells[colOrderName.Name].Value);
             }
         }
         else
         {
             pre.AddID(dgvr.Cells[colOrderID.Name].Value, dgvr.Cells[colOrderName.Name].Value);
         }
     }
     if (dgvDocuments2.Visible)
     {
         foreach (DataGridViewRow dgvr in dgvDocuments2.Rows)
         {
             if (isSelected)
             {
                 object check = dgvr.Cells[colChk2.Name].EditedFormattedValue;
                 if (check != null && (bool)check)
                 {
                     pre.AddID(dgvr.Cells[colOrderID2.Name].Value, dgvr.Cells[colOrderName2.Name].Value);
                 }
             }
             else
             {
                 pre.AddID(dgvr.Cells[colOrderID2.Name].Value, dgvr.Cells[colOrderName2.Name].Value);
             }
         }
     }
     listSql.AddRange(pre.GetSql(statusName, importStaus));
 }
 /// <summary>
 /// 设置单据导入状态
 /// </summary>
 void SetDocumentImportStatus(string statusName, DataSources.EnumImportStaus importStaus, List<SysSQLString> listSql, string order_id, string order_type)
 {
     DataTable dt = DBHelper.GetTable("", "tb_balance_documents", "documents_id,documents_name", string.Format("order_id='{0}'", order_id), "", "");
     if (dt == null || dt.Rows.Count == 0)
     {
         return;
     }
     Preposition pre = new Preposition();
     foreach (DataRow dr in dt.Rows)
     {
         pre.AddID(dr["documents_id"], dr["documents_name"]);
     }
     listSql.AddRange(pre.GetSql(statusName, importStaus));
 }
        //TODO add optional second preposition, i.e. make this bidirectional

        public SpatialLocation(PhysicalEntity c, Preposition p1, PhysicalEntity a)
        {
            child       = c;
            preposition = p1;
            adult       = a;
        }
Beispiel #8
0
        private static IEnumerable <Word> Parse(HtmlDocument html, string wordName)
        {
            var centerDiv = html.GetElementbyId("center");
            var nodes     = centerDiv.ChildNodes
                            .Where(x => x.Name == "span")
                            .Where(x => x.Attributes.Any(a => a.Name == "style" && a.Value == "color:black;background-color:#FFCCCC"))
                            .ToList();

            var words = new List <Word>();

            foreach (var item in nodes)
            {
                var      type = item.InnerText;
                Word     word;
                string[] forms;
                #region switch
                switch (type)
                {
                case "(Article)":
                    forms = ParseSimple(item, html);
                    word  = new Article(forms[0]);
                    word.AddForms(forms);
                    break;

                case "(Verb)":
                case "(Defective verb)":
                    string[] v1, v2, v3, v4;
                    var      name = ParseVerb(item, html, out v1, out v2, out v3, out v4);
                    var      verb = new Verb(name);
                    verb.AddForms(v1, VerbType.Infinitive);
                    verb.AddForms(v2, VerbType.Past);
                    verb.AddForms(v3, VerbType.PastParticiple);
                    verb.AddForms(v4, VerbType.PresentParticiple);
                    word = verb;
                    break;

                case "(Modal verb)":
                    forms = ParseSimple(item, html);
                    word  = new ModalVerb(forms[0]);
                    word.AddForms(forms);
                    break;

                case "(Noun)":
                case "(Feminine noun)":
                case "(Masculine noun)":
                    forms = ParseNoun(item, html);
                    word  = new Noun(forms[0]);
                    word.AddForms(forms);
                    break;

                case "(Plural noun)":
                    forms = ParseSimple(item, html);
                    word  = new Noun(forms[0]);
                    word.AddForms(forms);
                    break;

                case "(Adjective)":
                case "(Uninflected adjective)":
                    forms = ParseSimple(item, html);
                    word  = new Adjective(forms[0]);
                    word.AddForms(forms);
                    break;

                case "(Preposition)":
                    forms = ParseSimple(item, html);
                    word  = new Preposition(forms[0]);
                    word.AddForms(forms);
                    break;

                case "(Adverb)":
                case "(Uninflected adverb)":
                    forms = ParseSimple(item, html);
                    word  = new Adverb(forms[0]);
                    word.AddForms(forms);
                    break;

                case "(Conjunction)":
                    forms = ParseSimple(item, html);
                    word  = new Conjunction(forms[0]);
                    word.AddForms(forms);
                    break;

                case "(Interjection)":
                    forms = ParseSimple(item, html);
                    word  = new Interjection(forms[0]);
                    word.AddForm(forms[0]);
                    break;

                case "(Pronoun)":
                case "(Quantitative plural pronoun)":
                case "(Uninflected interrogative pronoun)":
                case "(Demonstrative pronoun)":
                case "(Plural pronoun)":
                    forms = ParseSimple(item, html);
                    word  = new Pronoun(forms[0], WordType.Pronoun);
                    word.AddForms(forms);
                    break;

                case "(Quantitative pronoun)":
                    forms = ParseSimple(item, html);
                    word  = new Pronoun(forms[0], WordType.QuantitativePronoun);
                    word.AddForms(forms);
                    break;

                case "(Indefinite pronoun)":
                    forms = ParseSimple(item, html);
                    word  = new Pronoun(forms[0], WordType.PronounIndefinite);
                    word.AddForms(forms);
                    break;

                case "(Uninflected pronoun)":
                    forms = ParseSimple(item, html);
                    word  = new Pronoun(forms[0], WordType.PronounUninflected);
                    word.AddForms(forms);
                    break;

                case "(Relative pronoun)":
                case "(Relative pronoun 2)":
                    forms = ParseSimple(item, html);
                    word  = new Pronoun(forms[0], WordType.PronounRelative);
                    word.AddForms(forms);
                    break;

                case "(1st person singular pronoun)":
                case "()":      // (1st person plural pronoun )
                    forms = ParseSimple(item, html);
                    word  = new Pronoun(forms[0], WordType.PronounPerson1);
                    word.AddForms(forms);
                    break;

                case "(2nd person singular pronoun)":
                case "(2nd person plural pronoun )":
                    forms = ParseSimple(item, html);
                    word  = new Pronoun(forms[0], WordType.PronounPerson2);
                    word.AddForms(forms);
                    break;

                case "(3rd person masculine singular pronoun)":
                case "(3rd person feminine singular pronoun )":
                case "(3rd person plural pronoun)":
                case "(3rd person neuter singular pronoun)":
                    forms = ParseSimple(item, html);
                    word  = new Pronoun(forms[0], WordType.PronounPerson2);
                    word.AddForms(forms);
                    break;

                default:
                    throw new NotSupportedException(string.Format("The type {0} is not defined", type));
                }
                #endregion
                words.Add(word);
            }
            return(words);
        }
Beispiel #9
0
        public IReadOnlyArgument CreateAlternateArgument(string name, IReadOnlyType type, Preposition alternateAccess)
        {
            if (this.argumentNames.Contains(name))
                throw new InvalidOperationException("An argument with the given name already exists.");

            if (this.prepArgMap.ContainsKey(alternateAccess))
                throw new InvalidOperationException("An argument already exists with the given alternate access.");

            ArgumentData arg = new ArgumentData(name, type, this, alternateAccess);
            this.arguments.Add(arg);
            this.argumentNames.Add(name);
            this.prepArgMap[alternateAccess] = arg;
            return arg;
        }
Beispiel #10
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();
                }
            }
        }
Beispiel #11
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();
        }