Beispiel #1
0
 public override void EnterExample(VowpalWabbitParser.ExampleContext context)
 {
     this.example = new Test1()
     {
         Features = new List<KeyValuePair<string, float>>()
     };
 }
Beispiel #2
0
 public override void ExitLabel_simple(VowpalWabbitParser.Label_simpleContext context)
 {
     this.example.Label = new SimpleLabel()
     {
         Label = context.value.value
     };
 }
Beispiel #3
0
        public override void ExitFeatureSparse(VowpalWabbitParser.FeatureSparseContext context)
        {
            var index = context.index.Text;
            var x = context.x.value;

            if (index == "const")
            {
                this.example.Constant = x;
            }
            else
            {
                this.example.Features.Add(new KeyValuePair<string, float>(index, x));
            }
        }
        internal static void ParseInput(ICharStream stream, IParseTreeListener listener)
        {
            // optimized for memory consumption
            var lexer = new VowpalWabbitLexer(stream)
            {
                TokenFactory = new CommonTokenFactory(copyText: true)
            };

            var tokens = new UnbufferedTokenStream(lexer);
            var parser = new VowpalWabbitParser(tokens)
            {
                // Note; don't disable, as it is required to access the line
                // BuildParseTree = false,
            };

            // fast than LL(*)
            parser.Interpreter.PredictionMode = PredictionMode.Sll;

            parser.AddParseListener(listener);
            parser.AddErrorListener(new TestErrorListener());
            parser.start();
        }
Beispiel #5
0
 public override void ExitNumber(VowpalWabbitParser.NumberContext context)
 {
     context.value = float.Parse(context.GetText(), CultureInfo.InvariantCulture);
 }
Beispiel #6
0
 public override void ExitExample(VowpalWabbitParser.ExampleContext context)
 {
     this.example.Line = context.GetText();
     this.action(this.example);
 }
 public override void ExitExample(VowpalWabbitParser.ExampleContext context)
 {
     this.stopwatch.Start();
     this.vw.Learn(this.example, this.label);
     this.stopwatch.Stop();
 }
 public override void EnterExample(VowpalWabbitParser.ExampleContext context)
 {
     this.label = null;
     this.example.Features.Clear();
 }
 public override void ExitFeatureSparse(VowpalWabbitParser.FeatureSparseContext context)
 {
     this.example.Features.Add(
         new KeyValuePair<string, float>(
             context.index.Text,
             context.x.value));
 }
Beispiel #10
0
 public override void ExitExample(VowpalWabbitParser.ExampleContext context)
 {
     this.stopwatch.Start();
     using (var vwExample = this.vw.ReadExample(this.example))
     {
         vwExample.Learn();
     }
     this.stopwatch.Stop();
 }