Exemplo n.º 1
0
        private static List <ModelResult <FoundChoice> > RecognizeOrdinal(string utterance, string culture)
        {
            var model  = new NumberRecognizer(culture).GetOrdinalModel(culture);
            var result = model.Parse(utterance);

            return(result.Select(r =>
                                 new ModelResult <FoundChoice>
            {
                Start = r.Start,
                End = r.End,
                Text = r.Text,
                Resolution = new FoundChoice
                {
                    Value = r.Resolution["value"].ToString(),
                },
            }).ToList());
        }
        private int?ParseFloorNumber(string utterance, string culture)
        {
            var model_ordinal = new NumberRecognizer(culture).GetOrdinalModel(culture);
            var result        = model_ordinal.Parse(utterance);

            if (result.Any())
            {
                return(int.Parse(result.First().Resolution["value"].ToString()));
            }
            else
            {
                var model_number = new NumberRecognizer(culture).GetNumberModel(culture);
                result = model_number.Parse(utterance);
                if (result.Any())
                {
                    return(int.Parse(result.First().Resolution["value"].ToString()));
                }
            }

            return(null);
        }