コード例 #1
0
        public virtual List <string> GetInflVars()

        {
            List <string> inflVars = new List <string>();

            if (lexRecordObjs_ != null)

            {
                for (int i = 0; i < lexRecordObjs_.Count; i++)

                {
                    LexRecord temp = (LexRecord)lexRecordObjs_[i];

                    List <InflVar> inflValues = temp.GetInflVarsAndAgreements().GetInflValues();
                    for (int j = 0; j < inflValues.Count; j++)

                    {
                        InflVar inflVar = (InflVar)inflValues[j];
                        inflVars.Add(inflVar.GetVar());
                    }
                }
            }

            return(inflVars);
        }
コード例 #2
0
        public virtual List <string> GetInflVars(string separator)

        {
            List <string> inflVars = new List <string>();

            if (lexRecordObjs_ != null)

            {
                for (int i = 0; i < lexRecordObjs_.Count; i++)

                {
                    LexRecord temp = (LexRecord)lexRecordObjs_[i];

                    List <InflVar> inflValues = temp.GetInflVarsAndAgreements().GetInflValues();
                    for (int j = 0; j < inflValues.Count; j++)

                    {
                        InflVar inflVar = (InflVar)inflValues[j];


                        string inflVarDetail = inflVar.GetVar() + separator + inflVar.GetCat() + separator +
                                               inflVar.GetInflection() + separator + inflVar.GetEui() + separator +
                                               inflVar.GetUnInfl() + separator + inflVar.GetCit() + separator +
                                               inflVar.GetType();
                        inflVars.Add(inflVarDetail);
                    }
                }
            }

            return(inflVars);
        }
コード例 #3
0
        public static void Main(string[] args)

        {
            if ((args.Length == 0) || (args.Length > 2))

            {
                Console.Error.WriteLine("** Usage: java ToJavaObjectFromXmlFile <inFile(Xml)> <-i>");
                Console.Error.WriteLine("");
                Console.Error.WriteLine("Options:");
                Console.Error.WriteLine("  -i: generate inflection vars");
                Environment.Exit(1);
            }

            bool inflVarFlag = false;

            for (int i = 0; i < args.Length; i++)

            {
                if (args[i].Equals("-i"))

                {
                    inflVarFlag = true;
                    break;
                }
            }

            try

            {
                List <LexRecord> lexRecords = ToJavaObjApi.ToJavaObjsFromXmlFile(args[0]);
                if (lexRecords.Count <= 0)

                {
                    Environment.Exit(1);
                }
                else

                {
                    for (int i = 0; i < lexRecords.Count; i++)

                    {
                        LexRecord lexRecord = (LexRecord)lexRecords[i];
                        Console.Write(lexRecord.GetText());
                        if (inflVarFlag == true)

                        {
                            Console.WriteLine("---------- Inflection Vars ----------");

                            List <InflVar> inflVars = lexRecord.GetInflVarsAndAgreements().GetInflValues();
                            for (int j = 0; j < inflVars.Count; j++)

                            {
                                InflVar inflVar = (InflVar)inflVars[j];
                                Console.WriteLine(inflVar.GetVar() + "|" + Category.ToValue(inflVar.GetCat()) + "|" +
                                                  Inflection.ToValue(inflVar.GetInflection()) + "|" + inflVar.GetEui() +
                                                  "|" + inflVar.GetUnInfl() + "|" + inflVar.GetCit());
                            }
                        }
                    }
                }
            }
            catch (Exception e)

            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
        }
コード例 #4
0
        /**
         * make a WordElement from a lexical record. Currently just specifies basic
         * params and inflections Should do more in the future!
         *
         * @param record
         * @return
         */
        private WordElement makeWord(LexRecord record) // LexRecord
        {
            // get basic data
            String          baseForm = record.GetBase();
            LexicalCategory category = record.GetSimpleNLGCategory(record);
            String          id       = record.GetEui();

            // create word class
            WordElement wordElement = new WordElement(baseForm, category, id);

            // now add type information
            switch (category.GetLexicalCategory())
            {
            case LexicalCategory.LexicalCategoryEnum.ADJECTIVE:
                addAdjectiveInfo(wordElement, record.GetCatEntry().GetAdjEntry());
                break;

            case LexicalCategory.LexicalCategoryEnum.ADVERB:
                addAdverbInfo(wordElement, record.GetCatEntry().GetAdvEntry());
                break;

            case LexicalCategory.LexicalCategoryEnum.NOUN:
                addNounInfo(wordElement, record.GetCatEntry().GetNounEntry());
                break;

            case LexicalCategory.LexicalCategoryEnum.VERB:
                addVerbInfo(wordElement, record.GetCatEntry().GetVerbEntry());
                break;
                // ignore closed class words
            }

            Inflection?defaultInfl = wordElement.getDefaultInflectionalVariant();

            // now add inflected forms
            // if (keepStandardInflections || !standardInflections(record,
            // category)) {
            foreach (InflVar inflection in record.GetInflVarsAndAgreements().GetInflValues())
            {
                String simplenlgInflection = getSimplenlgInflection(inflection
                                                                    .GetInflection());

                if (simplenlgInflection != null)
                {
                    String     inflectedForm = inflection.GetVar();
                    Inflection?inflType      = Inflection.REGULAR.getInflCode(inflection.GetType());

                    // store all inflectional variants, except for regular ones
                    // unless explicitly set
                    if (inflType != null &&
                        !(Inflection.REGULAR == inflType && !keepStandardInflections))
                    {
                        wordElement.addInflectionalVariant((Inflection)inflType,
                                                           simplenlgInflection, inflectedForm);
                    }

                    // if the infl variant is the default, also set this feature on
                    // the word
                    if (defaultInfl == null ||
                        (defaultInfl.Equals(inflType) && !(Inflection.REGULAR.Equals(inflType) && !keepStandardInflections)))
                    {
                        wordElement.setFeature(simplenlgInflection, inflectedForm);
                    }

                    // wordElement
                    // .setFeature(simplenlgInflection, inflection.GetVar());
                }
            }
            // }

            // add acronym info
            addAcronymInfo(wordElement, record);

            // now add spelling variants
            addSpellingVariants(wordElement, record);

            return(wordElement);
        }