Beispiel #1
0
 public PerceptronModel(ShiftReduceOptions op, IIndex <ITransition> transitionIndex, ICollection <string> knownStates, ICollection <string> rootStates, ICollection <string> rootOnlyStates)
     : base(op, transitionIndex, knownStates, rootStates, rootOnlyStates)
 {
     // Serializable
     this.featureWeights = Generics.NewHashMap();
     string[] classes = op.featureFactoryClass.Split(";");
     if (classes.Length == 1)
     {
         this.featureFactory = ReflectionLoading.LoadByReflection(classes[0]);
     }
     else
     {
         FeatureFactory[] factories = new FeatureFactory[classes.Length];
         for (int i = 0; i < classes.Length; ++i)
         {
             int paren = classes[i].IndexOf('(');
             if (paren >= 0)
             {
                 string arg = Sharpen.Runtime.Substring(classes[i], paren + 1, classes[i].Length - 1);
                 factories[i] = ReflectionLoading.LoadByReflection(Sharpen.Runtime.Substring(classes[i], 0, paren), arg);
             }
             else
             {
                 factories[i] = ReflectionLoading.LoadByReflection(classes[i]);
             }
         }
         this.featureFactory = new CombinationFeatureFactory(factories);
     }
 }
Beispiel #2
0
 public PerceptronModel(Edu.Stanford.Nlp.Parser.Shiftreduce.PerceptronModel other)
     : base(other)
 {
     this.featureFactory = other.featureFactory;
     this.featureWeights = Generics.NewHashMap();
     foreach (string feature in other.featureWeights.Keys)
     {
         featureWeights[feature] = new Weight(other.featureWeights[feature]);
     }
 }