Example #1
0
        public void PredictOne(Sent sent)
        {
            G.Need = false;

            var c = new ArcStandardConfig(sent, false, null);

            GetTokenRepr(sent, false);
            while (!c.IsTerminal())
            {
                GetTrans(c, out Tensor op, out Tensor label);

                // in labelid 0 is root
                // in mapping 1 is root, 0 is always unk
                var labelid  = label.W.MaxIndex();
                var plabel   = _train.DepLabel[labelid + 1];
                var scores   = op.W.Storage;
                var optScore = float.NegativeInfinity;
                var optTrans = ArcStandardConfig.Op.shift;

                for (var j = 0; j < 3; ++j)
                {
                    if (scores[j] > optScore && c.CanApply((ArcStandardConfig.Op)j, plabel))
                    {
                        optScore = scores[j];
                        optTrans = (ArcStandardConfig.Op)j;
                    }
                }
                c.Apply(optTrans, plabel);
            }
        }