예제 #1
0
        private static async Task MainAsync()
        {
            //var res = new ResourceFinder();
            //await res.GetWikipediaRawText("Superman", wikipediaRawResultPath);
            //var text = File.ReadAllText(wikipediaRawResultPath);

            //text = StringUtils.CleanText(text);

            //using (var file = new StreamWriter(cleanTextPath))
            //{
            //    await file.WriteLineAsync(text);
            //}

            //tpr.ProcessText(text);

            //Console.WriteLine(text.Length);
            //Console.WriteLine("Process new data?");

            var          tagger = new Tagger();
            const string topic  = "Coca-Cola";

            //await tagger.GetWikipediaResources(topic);
            //await tagger.ProcessWikipediaText(topic);
            tagger.GenerateQuestions(topic);
            Console.ReadLine();
        }
예제 #2
0
        private async Task <object> ProcessTopic(string topicName)
        {
            var topic = await topicsManager.GetProposedTopic(topicName);

            if (topic == null)
            {
                return(HttpStatusCode.BadRequest);
            }
            var currentUser = Context.CurrentUser;

            var resourceFinder = new ResourceFinder();
            var topicImage     = resourceFinder.GetWikipediaImageForTopic(topicName);

            await topicsManager.AddNewTopicToDatabase(topicName, topicImage);

            topicName = topicName.Replace(" ", "_");
            await tagger.GetWikipediaResources(topicName);

            await tagger.ProcessWikipediaText(topicName);

            tagger.GenerateQuestions(topicName);

            await topicsManager.SaveQuestionsFromFile(topicName);


            await notificationCore.SendTopicProcessedNotification(currentUser.UserName, topicName);

            if (topic.User.UserName != currentUser.UserName)
            {
                await notificationCore.SendTopicProcessedNotification(topic.User.UserName, topicName);
            }

            await topicsManager.DeleteProposedTopic(topicName);

            return(HttpStatusCode.OK);
        }