示例#1
0
        //3 多目标单地名模式

        public static List <sentenceAnalysis.to.qua_Combination> multiShip_SinglePlace(string str, string place)
        {
            string result = null;

            string[] stringForResult = str.Split(',');
            //  List<string> sentence = new List<string>();

            List <sentenceAnalysis.to.qua_Combination> list = new List <qua_Combination>();

            //   sentenceAnalysis.to.qua_Combination com = new qua_Combination();
            List <word> anchorList = new List <word>();

            for (int j = 0; j < stringForResult.Length && (stringForResult[j] != ""); j++)
            {
                //    sentence.Add(stringForResult[j]);

                string parseResult = function.toParse(stringForResult[j]);
                List <sentenceAnalysis.to.word> singlePart = function.toList(parseResult);
                function.place_phrase_recog(singlePart);// 地名词组识别 方便之后将这个识别为整个词组 放在一起

                // 由于是单地名 对应多个目标 所以所有的四元组的地点标全是一致的,目标、行为则每个句子各有不同
                List <sentenceAnalysis.to.word> place_Qua = new List <sentenceAnalysis.to.word>();
                List <sentenceAnalysis.to.word> ship_Qua  = new List <sentenceAnalysis.to.word>();
                List <sentenceAnalysis.to.word> event_Qua = new List <sentenceAnalysis.to.word>();
                List <sentenceAnalysis.to.word> time_Qua  = new List <sentenceAnalysis.to.word>();
                //entity_recog(list, place_Qua, ship_Qua, event_Qua, time_Qua);
                function.entity_recog(singlePart, place_Qua, ship_Qua, event_Qua, time_Qua);
                place_Qua  = function.isPlace(place_Qua);
                singlePart = function.move_Place(singlePart);

                for (int i = 0; i < singlePart.Count; i++)
                {
                    if (singlePart[i].speech == "anchor")
                    {
                        anchorList.Add(singlePart[i]);
                    }
                }
                // 可知地名应该是可能为空的 但是目标不为空

                if (ship_Qua.Count != 0 && anchorList.Count != 0)
                {
                    // 此单句中存在四元组

                    result += ship_Qua[0].character + "||";
                    result += place + "||";
                    //   com.ship = ship_Qua[0].character;

                    int i_ship = 0;
                    while (i_ship < ship_Qua.Count)
                    {
                        sentenceAnalysis.to.qua_Combination com = new qua_Combination();
                        result  += ship_Qua[i_ship].character + "||";
                        com.ship = ship_Qua[i_ship].character;

                        List <sentenceAnalysis.to.word> temp_list = new List <word>();
                        com.place = function.anchor_split(anchorList[0].character, com.place, temp_list);
                        for (int i = 0; i < temp_list.Count; i++)
                        {
                            com.move     = temp_list[i].character;
                            com.moveType = temp_list[i].speech;
                        }

                        if (event_Qua.Count != 0)
                        {
                            int i_event = 0;
                            while (i_event < event_Qua.Count)
                            {
                                result     += event_Qua[i_event].character + "||";
                                com.action += event_Qua[i_event].character;
                                i_event++;
                            }
                        }
                        if (time_Qua.Count != 0)
                        {
                            int i_time = 0;
                            while (i_time < time_Qua.Count)
                            {
                                result   += time_Qua[i_time].character + "||";
                                com.time += time_Qua[i_time].character;
                                i_time++;
                            }
                        }
                        list.Add(com);



                        i_ship++;
                    }
                }
            }

            return(list);
        }
        public static List <sentenceAnalysis.to.qua_Combination> isQuadruple(List <sentenceAnalysis.to.word> list, string str)
        {
            //   string result = null;
            List <sentenceAnalysis.to.qua_Combination> result = new List <qua_Combination>();

            sentenceAnalysis.to.qua_Combination com       = new qua_Combination();
            List <sentenceAnalysis.to.word>     place_Qua = new List <sentenceAnalysis.to.word>();
            List <sentenceAnalysis.to.word>     ship_Qua  = new List <sentenceAnalysis.to.word>();
            List <sentenceAnalysis.to.word>     event_Qua = new List <sentenceAnalysis.to.word>();
            List <sentenceAnalysis.to.word>     time_Qua  = new List <sentenceAnalysis.to.word>();

            seaArea(list);
            entity_recog(list, place_Qua, ship_Qua, event_Qua, time_Qua);
            place_Qua = isPlace(place_Qua);
            list      = move_Place(list);
            List <word> anchorList = new List <word>();

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].speech == "anchor")
                {
                    anchorList.Add(list[i]);
                }
            }
            //  sentenceAnalysis.to.qua_Combination com = new sentenceAnalysis.to.qua_Combination();
            // 存在锚点和航母号
            if (anchorList.Count != 0 && ship_Qua.Count != 0)
            {
                // 表示该句中四元组存在
                //判断模式
                if (anchorList.Count == 1 && ship_Qua.Count == 1)
                {
                    //  result += ship_Qua[0].character + "||";
                    com.ship = ship_Qua[0].character;
                    if (time_Qua.Count != 0)
                    {
                        for (int i = 0; i < time_Qua.Count; i++)
                        {
                            //result += time_Qua[i].character + "||";
                            com.time = time_Qua[i].character;
                        }
                    }
                    if (event_Qua.Count != 0)
                    {
                        for (int i = 0; i < event_Qua.Count; i++)
                        {
                            // result += event_Qua[i].character + "||";
                            com.action = event_Qua[i].character; // 修改 因为不一定只有一个事件
                        }
                    }

                    //   result += place_Qua[0].character + "||";
                    List <sentenceAnalysis.to.word> temp_list = new List <word>();
                    com.place = anchor_split(anchorList[0].character, com.place, temp_list);
                    for (int i = 0; i < temp_list.Count; i++)
                    {
                        com.move     = temp_list[i].character;
                        com.moveType = temp_list[i].speech;
                    }
                    //    com.place = place_Qua[0].character;
                    result.Add(com);
                }
                else if (anchorList.Count > 1 && ship_Qua.Count == 1)
                {
                    result = sentenceAnalysis.to.match_models.singleShip_MultiPlaces(str, ship_Qua[0].character);
                }
                else if (anchorList.Count == 1 && ship_Qua.Count > 1)
                {
                    List <sentenceAnalysis.to.word> temp_list = new List <word>();
                    string place = anchor_split(anchorList[0].character, com.place, temp_list);
                    result = sentenceAnalysis.to.match_models.multiShip_SinglePlace(str, place);
                }
                else
                {
                    result = sentenceAnalysis.to.match_models.multiShips_multiPlaces(str);
                }
            }

            return(result);
            //  return com;
        }