Example #1
0
        public Marker(NLPProcessor processor, string modelPath)
        {
            _processor = processor;
            _modelPath = modelPath;

            Annotation sportSpecificWords = _processor.Annotate(File.ReadAllText(modelPath + "specificwords.txt"));

            _sportSpecificWords = NLPCoreHelper.GetLemmas(sportSpecificWords);
            File.Delete(modelPath + "specificwords.txt");
            StringBuilder builder = new StringBuilder();

            foreach (string word in _sportSpecificWords)
            {
                builder.AppendLine(word);
            }
            File.WriteAllText(modelPath + "specificwords.txt", builder.ToString());

            PersonOccurenceDatabase             = new WordOccurenceDatabase();
            OrganizationOccurenceDatabase       = new WordOccurenceDatabase();
            LocationsOccurenceDatabase          = new WordOccurenceDatabase();
            SportSpecificWordsOccurenceDatabase = new WordOccurenceDatabase();
            _categoriesCount = Enum.GetValues(typeof(SportCategory)).Length;
            int hiddenLayerCount = (10 * _categoriesCount) / 3;

            _classifier = new ActivationNetwork(new SigmoidFunction(), 4 * _categoriesCount, hiddenLayerCount, _categoriesCount);
            _teacher    = new BackPropagationLearning(_classifier);

            Array values = Enum.GetValues(typeof(SportCategory));

            _categoryIndex = new Dictionary <SportCategory, int>();
            _indexCategory = new Dictionary <int, SportCategory>();
            for (int index = 0; index < values.Length; index++)
            {
                SportCategory category = (SportCategory)values.GetValue(index);
                _categoryIndex.Add(category, index);
                _indexCategory.Add(index, category);
            }
        }