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
 public MorphoFeatures(MorphoFeatures other) : this()
 {
     foreach (var entry in other.fSpec)
     {
         this.fSpec.Add(entry.Key, entry.Value);
     }
     this.altTag = other.altTag;
 }
Exemple #3
0
        public int NumFeatureMatches(MorphoFeatures other)
        {
            int nMatches = 0;
            foreach (var fPair in fSpec)
            {
                if (other.HasFeature(fPair.Key) && other.GetValue(fPair.Key).Equals(fPair.Value))
                    nMatches++;
            }

            return nMatches;
        }
Exemple #4
0
        public int NumFeatureMatches(MorphoFeatures other)
        {
            int nMatches = 0;

            foreach (var fPair in fSpec)
            {
                if (other.HasFeature(fPair.Key) && other.GetValue(fPair.Key).Equals(fPair.Value))
                {
                    nMatches++;
                }
            }

            return(nMatches);
        }
Exemple #5
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 #6
0
 public MorphoFeatures(MorphoFeatures other) : this()
 {
     foreach (var entry in other.fSpec)
         this.fSpec.Add(entry.Key, entry.Value);
     this.altTag = other.altTag;
 }