コード例 #1
0
 public static void AddBinaryFeatures(IList <string> features, string name1, CoreLabel label1, FeatureFactory.FeatureComponent feature11, FeatureFactory.FeatureComponent feature12, string name2, CoreLabel label2, FeatureFactory.FeatureComponent
                                      feature21, FeatureFactory.FeatureComponent feature22)
 {
     if (label1 == null)
     {
         if (label2 == null)
         {
             features.Add(name1 + "n" + name2 + "n");
         }
         else
         {
             AddUnaryFeature(features, name1 + "n" + name2 + feature21.ShortName() + "-", label2, feature21);
             AddUnaryFeature(features, name1 + "n" + name2 + feature22.ShortName() + "-", label2, feature22);
         }
     }
     else
     {
         if (label2 == null)
         {
             AddUnaryFeature(features, name1 + feature11.ShortName() + name2 + "n-", label1, feature11);
             AddUnaryFeature(features, name1 + feature12.ShortName() + name2 + "n-", label1, feature12);
         }
         else
         {
             AddBinaryFeature(features, name1 + feature11.ShortName() + name2 + feature21.ShortName() + "-", label1, feature11, label2, feature21);
             AddBinaryFeature(features, name1 + feature11.ShortName() + name2 + feature22.ShortName() + "-", label1, feature11, label2, feature22);
             AddBinaryFeature(features, name1 + feature12.ShortName() + name2 + feature21.ShortName() + "-", label1, feature12, label2, feature21);
             AddBinaryFeature(features, name1 + feature12.ShortName() + name2 + feature22.ShortName() + "-", label1, feature12, label2, feature22);
         }
     }
 }
コード例 #2
0
        public static string GetFeatureFromCoreLabel(CoreLabel label, FeatureFactory.FeatureComponent feature)
        {
            string value = null;

            switch (feature)
            {
            case FeatureFactory.FeatureComponent.Headword:
            {
                value = (label == null) ? Null : label.Get(typeof(TreeCoreAnnotations.HeadWordLabelAnnotation)).Value();
                break;
            }

            case FeatureFactory.FeatureComponent.Headtag:
            {
                value = (label == null) ? Null : label.Get(typeof(TreeCoreAnnotations.HeadTagLabelAnnotation)).Value();
                break;
            }

            case FeatureFactory.FeatureComponent.Value:
            {
                value = (label == null) ? Null : label.Value();
                break;
            }

            default:
            {
                throw new ArgumentException("Unexpected feature type: " + feature);
            }
            }
            return(value);
        }
コード例 #3
0
        public static void AddTrigramFeature(IList <string> features, string featureType, CoreLabel label1, FeatureFactory.FeatureComponent feature1, CoreLabel label2, FeatureFactory.FeatureComponent feature2, CoreLabel label3, FeatureFactory.FeatureComponent
                                             feature3)
        {
            string value1 = GetFeatureFromCoreLabel(label1, feature1);
            string value2 = GetFeatureFromCoreLabel(label2, feature2);
            string value3 = GetFeatureFromCoreLabel(label3, feature3);

            features.Add(featureType + value1 + "-" + value2 + "-" + value3);
        }
コード例 #4
0
        public static void AddUnaryFeature(IList <string> features, string featureType, CoreLabel label, FeatureFactory.FeatureComponent feature)
        {
            string value = GetFeatureFromCoreLabel(label, feature);

            features.Add(featureType + value);
        }
コード例 #5
0
        public static void AddSeparatorFeature(IList <string> features, string featureType, CoreLabel label1, FeatureFactory.FeatureComponent feature1, CoreLabel label2, FeatureFactory.FeatureComponent feature2, bool between)
        {
            string value1 = GetFeatureFromCoreLabel(label1, feature1);
            string value2 = GetFeatureFromCoreLabel(label2, feature2);

            features.Add(featureType + value1 + "-" + value2 + "-" + between);
        }
コード例 #6
0
        public static void AddSeparatorFeature(IList <string> features, string featureType, CoreLabel label, FeatureFactory.FeatureComponent feature, bool between)
        {
            string value = GetFeatureFromCoreLabel(label, feature);

            features.Add(featureType + value + "-" + between);
        }
コード例 #7
0
        public static void AddSeparatorFeature(IList <string> features, string featureType, CoreLabel label, FeatureFactory.FeatureComponent feature, State.HeadPosition separator)
        {
            if (separator == null)
            {
                return;
            }
            string value = GetFeatureFromCoreLabel(label, feature);

            features.Add(featureType + value + "-" + separator);
        }