Esempio n. 1
0
        public static string correference(Entity entity, int i)
        {
            string        entity_wiki = "";
            string        file        = @".\correference\" + (i + 1).ToString() + ".xml.txt.cor";
            List <string> lines       = new List <string>();

            lines = IO.Read(file);
            string s = "c=" + "\"" + entity.name + "\"" + " " + entity.line + ":" + entity.colum_start + " " + entity.line + ":" + entity.colum_end;

            foreach (string line in lines)
            {
                bool     flag = false;
                string[] cor  = line.Split(new string[] { "||" }, StringSplitOptions.RemoveEmptyEntries);

                List <string> corr = new List <string>();
                foreach (string ss in cor)
                {
                    Regex  reg   = new Regex(@"^c=(?<name>.+)\s(?<line>[0-9]+):(?<col_start>[0-9]+)\s(?<line>[0-9]+):(?<col_end>[0-9]+)$");
                    Match  match = reg.Match(ss);
                    string name  = match.Groups["name"].Value.Replace("\"", "");
                    corr.Add(name);
                }

                if (cor.Contains(s))
                {
                    foreach (string name in corr)
                    {
                        string wiki = Concept.GetWikiAna(name);
                        if (wiki != "")
                        {
                            entity_wiki = wiki;
                            flag        = true;
                            break;
                        }
                    }
                }

                if (flag)
                {
                    break;
                }
            }

            return(entity_wiki);
        }