コード例 #1
0
        private string FindNames(string sentence)
        {
            if (_nameFinder == null)
            {
                _nameFinder = new EnglishNameFinder(_modelPath + "namefind\\");
            }

            var models = new[] { "date", "location", "money", "organization", "percentage", "person", "time" };

            return(_nameFinder.GetNames(models, sentence));
        }
コード例 #2
0
        /// <summary>
        /// Name entity recognition identifies specific entities in sentences. With the current models, you can detect persons, dates, locations, money, percentages and time
        /// </summary>
        /// <param name="txt">Texto de input</param>
        /// <param name="tags">string[] com a designação das tags possíveis de etiquetar: "date", "location", "money", "organization", "percentage", "person", "time"</param>
        /// <returns>retorna o texto etiquetado</returns>
        public static string NER(this string txt, string[] tags)
        {
            //Tive que fazer download da diretoria
            //Não esquecer de adicionar using OpenNLP.Tools.NameFind;
            var    modelPath3 = Path + @"NameFind\";
            var    nameFinder = new EnglishNameFinder(modelPath3);
            string ner        = nameFinder.GetNames(tags, txt);

            return(ner);
        }
コード例 #3
0
ファイル: OpenNLPForm.cs プロジェクト: MoawazAyub/CombinedNLP
        private string MyNer(string sentence)
        {
            var modelPath  = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\Models\NameFind\";
            var nameFinder = new EnglishNameFinder(modelPath);

            // specify which types of entities you want to detect
            string[] models = new string[7];//MySentenceDetector("date. location. money. organization. percentage. person. time");
            models[0] = "date";
            models[1] = "location";
            models[2] = "money";
            models[3] = "organization";
            models[4] = "percentage";
            models[5] = "person";
            models[6] = "time";

            var ner = nameFinder.GetNames(models, sentence);

            return(ner);
        }