Beispiel #1
0
        public async Task GetWikipediaResources(string topic)
        {
            var res            = new ResourceFinder();
            var rawResultsPath = DirectoryManager.GetRawResultsPath(topic);

            DirectoryManager.CreateDirectoryForTopic(topic);
            await res.GetWikipediaRawText(topic, rawResultsPath);
        }
Beispiel #2
0
        public void GenerateQuestions(string topic)
        {
            topic = topic.Replace(" ", "_");
            var outputJsonPath = DirectoryManager.GetOutputJsonPath(topic);

            var tpr        = new TextProcessing();
            var resultList = tpr.GetSentencesInformationFromJson(outputJsonPath);

            var questionList = new List <TopicQuestion>();

            foreach (var sentence in resultList)
            {
                var dependencies = GetSentenceDependency(sentence);

                var words = GetSentenceWords(sentence);

                var sentenceInfo = new SentenceInformationDto(sentence.SentenceText, dependencies, words);
                if (MustContinue(sentence, sentenceInfo))
                {
                    continue;
                }
                GeneratedQuestion generatedQuestion;
                try
                {
                    generatedQuestion = QuestionGenerator.Generate(sentenceInfo);
                }
                catch
                {
                    continue;
                }
                if (string.IsNullOrEmpty(generatedQuestion?.Question))
                {
                    continue;
                }
                var cleanQuestion = QuestionCleaner.RemovePunctuationFromEnd(generatedQuestion.Question);

                cleanQuestion = $"{cleanQuestion}?";
                var question = new TopicQuestion
                {
                    Topic           = topic,
                    InitialSentence = sentence.SentenceText,
                    Question        = cleanQuestion,
                    Answer          = generatedQuestion.Answer
                };
                questionList.Add(question);
            }
            DirectoryManager.WriteQuestionsToFile(questionList, topic);
        }
Beispiel #3
0
        public async Task ProcessWikipediaText(string topic)
        {
            var rawResultsPath = DirectoryManager.GetRawResultsPath(topic);
            var cleanTextPath  = DirectoryManager.GetCleanResultsPath(topic);
            var outputJsonPath = DirectoryManager.GetOutputJsonPath(topic);
            var referencesPath = DirectoryManager.GetReferencesPath(topic);

            var text = File.ReadAllText(rawResultsPath);

            text = StringUtils.CleanText(text, referencesPath);

            await DirectoryManager.WriteTextToFile(text, cleanTextPath);

            var tpr = new TextProcessing();

            tpr.ProcessText(text, outputJsonPath);
        }