/// <summary>
        /// 识别
        /// </summary>
        /// <param name="strokes">笔迹集合</param>
        /// <returns>候选词数组</returns>
        public string[] Recognize(StrokeCollection strokes)
        {
            if (strokes == null || strokes.Count == 0)
            {
                return(Params.EmptyAlternates);
            }

            var stroke = GetCombinedStore(strokes);

            var analyzer = new InkAnalyzer();

            analyzer.AddStroke(stroke, Params.SimplifiedChineseLanguageId);
            analyzer.SetStrokeType(stroke, StrokeType.Writing);

            var status = analyzer.Analyze();

            if (status.Successful)
            {
                var result = analyzer.GetAlternates()
                             .OfType <AnalysisAlternate>()
                             .Select(x => x.RecognizedString)
                             .ToArray();
                analyzer.Dispose();
                return(result);
            }

            analyzer.Dispose();

            return(Params.EmptyAlternates);
        }
        /// <summary>
        /// 识别
        /// </summary>
        /// <param name="strokes">笔迹集合</param>
        /// <returns>候选词数组</returns>
        public string[] Recognize(StrokeCollection strokes)
        {
            if (strokes == null || strokes.Count == 0)
            {
                return(Constants.EmptyAlternates);
            }

            var analyzer = new InkAnalyzer();

            analyzer.AddStrokes(strokes, Constants.ChsLanguageId);
            analyzer.SetStrokesType(strokes, StrokeType.Writing);

            var status = analyzer.Analyze();

            if (status.Successful)
            {
                return(analyzer.GetAlternates()
                       .OfType <AnalysisAlternate>()
                       .Select(x => x.RecognizedString)
                       .ToArray());
            }

            analyzer.Dispose();

            return(Constants.EmptyAlternates);
        }
Exemple #3
0
        /// <summary>
        /// 识别(将多个笔画集合成一起识别,提高单字的识别率)
        /// </summary>
        /// <param name="strokes">笔迹集合</param>
        /// <returns>候选词数组</returns>
        public string[] Recognize(StrokeCollection strokes)
        {
            if (strokes == null || strokes.Count == 0)
            {
                return(null);
            }

            var stroke = GetCombinedStore(strokes);

            var analyzer = new InkAnalyzer();

            analyzer.AddStroke(stroke, 0x0804);
            analyzer.SetStrokeType(stroke, StrokeType.Writing);

            var status = analyzer.Analyze();

            if (status.Successful)
            {
                return(analyzer.GetAlternates()
                       .OfType <AnalysisAlternate>()
                       .Select(x => x.RecognizedString)
                       .ToArray());
            }

            analyzer.Dispose();

            return(null);
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            // You must call analyzer.Dispose() to clean up
            // resources (both managed and unmanaged).
            analyzer.Dispose();

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }