Esempio n. 1
0
        /// <summary>
        /// 对一句话获取信息
        /// </summary>
        /// <param name="line"></param>
        /// <param name="isInChecking"></param>
        /// <returns></returns>
        public List <string[]> GetInforByPattern(string line, bool isInChecking)
        {
            List <string[]> allResults = new List <string[]>();

            Iveely.Framework.Text.Segment.IctclasSegment ictclasSegment = Text.Segment.IctclasSegment.GetInstance();
            Tuple <string[], string[]> tuple = ictclasSegment.SplitToArray(line);
            string nextSemantic = string.Empty;

            for (int i = 0; i < tuple.Item2.Length; i++)
            {
                if (i < tuple.Item2.Length - 1)
                {
                    nextSemantic = tuple.Item2[i + 1];
                }
                else
                {
                    nextSemantic = string.Empty;
                }
                foreach (var extractPattern in _extractPatterns)
                {
                    extractPattern.Check(tuple.Item2[i], tuple.Item1[i]);
                    if (nextSemantic != tuple.Item2[i] && extractPattern.IsMatch())
                    {
                        string[] results = extractPattern.GetResult();
                        if (!isInChecking)
                        {
#if DEBUG
                            File.AppendAllText("_InforExtracter_result.txt",
                                               string.Join("->", results) + "     " + extractPattern.GetPatternString() + "\r\n");
#endif
                            _entityManager.AddEntityRelation(results[0], results[1], results[2]);
                        }
                        extractPattern.Recover();
                        allResults.Add(results);
                    }
                }
            }

            foreach (var extractPattern in _extractPatterns)
            {
                string[] results = extractPattern.GetResult(true);
                if (results != null)
                {
                    _entityManager.AddEntityRelation(results[0], results[1], results[2]);
                    allResults.Add(results);
                }
                extractPattern.Recover();
            }
            return(allResults);
        }
Esempio n. 2
0
        public async Task <JsonResult> AddEntityRelation(AddEntityRelationModel addEntityRelationModel)
        {
            var response = await EntityManager.AddEntityRelation(addEntityRelationModel);

            return(Json(response));
        }