Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new <see cref="VowpalWabbitInterfaceVisitor"/> instance.
 /// </summary>
 /// <param name="vw">The associated vowpal wabbit instance.</param>
 public VowpalWabbitInterfaceVisitor(VowpalWabbit vw)
 {
     this.vw               = vw;
     this.builder          = null;
     this.namespaceBuilder = null;
     this.featureGroup     = '\0';
     this.namespaceHash    = 0;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="VowpalWabbitMarshalContext"/> class.
        /// </summary>
        /// <param name="vw">The VW instance the example will be imported to.</param>
        /// <param name="exampleBuilder">A shared example builder.</param>
        /// <param name="dictionary">Dictionary used for dictify operation.</param>
        /// <param name="fastDictionary">Dictionary used for dictify operation.</param>
        public VowpalWabbitMarshalContext(VowpalWabbit vw, VowpalWabbitExampleBuilder exampleBuilder, Dictionary<string, string> dictionary = null, Dictionary<object, string> fastDictionary = null)
        {
            this.VW = vw;
            this.ExampleBuilder = exampleBuilder;

            if (vw.Settings.EnableStringExampleGeneration)
            {
                this.StringExample = new StringBuilder();
                this.Dictionary = dictionary;
                this.FastDictionary = fastDictionary;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VowpalWabbitMarshalContext"/> class.
        /// </summary>
        /// <param name="vw">The VW instance the example will be imported to.</param>
        /// <param name="exampleBuilder">A shared example builder.</param>
        /// <param name="dictionary">Dictionary used for dictify operation.</param>
        /// <param name="fastDictionary">Dictionary used for dictify operation.</param>
        public VowpalWabbitMarshalContext(VowpalWabbit vw, VowpalWabbitExampleBuilder exampleBuilder, Dictionary <string, string> dictionary = null, Dictionary <object, string> fastDictionary = null)
        {
            this.VW             = vw;
            this.ExampleBuilder = exampleBuilder;

            if (vw.Settings.EnableStringExampleGeneration)
            {
                this.StringExample  = new StringBuilder();
                this.Dictionary     = dictionary;
                this.FastDictionary = fastDictionary;
            }
        }
Exemplo n.º 4
0
        public VowpalWabbitExample Visit(string label, IVisitableNamespace[] namespaces)
        {
            using (this.builder = new VowpalWabbitExampleBuilder(this.vw))
            {
                this.builder.Label = label;

                foreach (var n in namespaces)
                {
                    n.Visit();
                }

                return(this.builder.CreateExample());
            }
        }
Exemplo n.º 5
0
        private void Initialize(VowpalWabbitSerializerSettings settings)
        {
            var visitor = new VowpalWabbitInterfaceVisitor(this);

            this.actionDependentFeatureSerializer = VowpalWabbitSerializerFactory.CreateSerializer <TActionDependentFeature>(visitor, settings);

            if (this.actionDependentFeatureSerializer == null)
            {
                throw new ArgumentException(typeof(TActionDependentFeature) + " must have a least a single [Feature] defined.");
            }

            using (var exBuilder = new VowpalWabbitExampleBuilder(this))
            {
                this.emptyExample = exBuilder.CreateExample();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Transfers namespace data to native space.
        /// </summary>
        /// <param name="label">The label.</param>
        /// <param name="namespaces">The namespaces.</param>
        /// <returns>The populated vowpal wabbit example.</returns>
        public VowpalWabbitExample Visit(ILabel label, IVisitableNamespace[] namespaces)
        {
            Contract.Requires(namespaces != null);

            using (this.builder = new VowpalWabbitExampleBuilder(this.vw))
            {
                if (label != null)
                {
                    this.builder.ParseLabel(label.ToVowpalWabbitFormat());
                }

                foreach (var n in namespaces)
                {
                    n.Visit();
                }

                return(this.builder.CreateExample());
            }
        }