Exemple #1
0
        /// <summary>
        /// Assumes that the tag string has been formed using a call to getTag().
        /// As such, it removes the basic category from the feature string.
        ///
        /// Note that this method returns a <b>new</b> MorphoFeatures object.
        /// As a result, it behaves like a static method, but is non-static so that subclasses can override
        /// this method.
        /// </summary>
        public MorphoFeatures FromTagString(string str)
        {
            //List<string> feats = str.Split(new string[]{"\\-"}, StringSplitOptions.None).ToList();
            List <string> feats  = str.Split('-').ToList();
            var           mFeats = new MorphoFeatures();

            foreach (string fPair in feats)
            {
                string[] keyValue = Regex.Split(fPair, KeyValDelim);
                if (keyValue.Length != 2) //Manual state split annotations
                {
                    continue;
                }
                MorphoFeatureSpecification.MorphoFeatureType fName;
                var success = MorphoFeatureSpecification.MorphoFeatureType.TryParse(keyValue[0].Trim(), out fName);
                if (success)
                {
                    mFeats.AddFeature(fName, keyValue[1].Trim());
                }
                else
                {
                    // TODO:add warning
                }
            }

            return(mFeats);
        }
Exemple #2
0
        /// <summary>
        /// Assumes that the tag string has been formed using a call to getTag().
        /// As such, it removes the basic category from the feature string.
        /// 
        /// Note that this method returns a <b>new</b> MorphoFeatures object.
        /// As a result, it behaves like a static method, but is non-static so that subclasses can override
        /// this method.
        /// </summary>
        public MorphoFeatures FromTagString(string str)
        {
            //List<string> feats = str.Split(new string[]{"\\-"}, StringSplitOptions.None).ToList();
            List<string> feats = str.Split('-').ToList();
            var mFeats = new MorphoFeatures();
            foreach (string fPair in feats)
            {
                string[] keyValue = Regex.Split(fPair, KeyValDelim);
                if (keyValue.Length != 2) //Manual state split annotations
                    continue;
                MorphoFeatureSpecification.MorphoFeatureType fName;
                var success = MorphoFeatureSpecification.MorphoFeatureType.TryParse(keyValue[0].Trim(), out fName);
                if (success)
                {
                    mFeats.AddFeature(fName, keyValue[1].Trim());
                }
                else
                {
                    // TODO:add warning
                }
            }

            return mFeats;
        }