Exemple #1
0
        public override Tree Parse <_T0>(IList <_T0> sentence)
        {
            ShiftReduceParserQuery pq = new ShiftReduceParserQuery(this);

            if (pq.Parse(sentence))
            {
                return(pq.GetBestParse());
            }
            return(ParserUtils.XTree(sentence));
        }
        public virtual void Evaluate(IParserQuery query, Tree gold, PrintWriter pw)
        {
            if (!(query is ShiftReduceParserQuery))
            {
                throw new ArgumentException("This evaluator only works for the ShiftReduceParser");
            }
            ShiftReduceParserQuery srquery = (ShiftReduceParserQuery)query;

            try
            {
                switch (mode)
                {
                case TreeRecorder.Mode.Binarized:
                {
                    @out.Write(srquery.GetBestBinarizedParse().ToString());
                    break;
                }

                case TreeRecorder.Mode.Debinarized:
                {
                    @out.Write(srquery.debinarized.ToString());
                    break;
                }

                default:
                {
                    throw new ArgumentException("Unknown mode " + mode);
                }
                }
                @out.NewLine();
            }
            catch (IOException e)
            {
                throw new RuntimeIOException(e);
            }
        }