示例#1
0
        private async Task SearchForPlagiarismLocally(string fileName)
        {
            richTextBox1.Text = string.Empty;
            textBox2.Text     = string.Empty;

            var simplifiedText = TextDocumentManager.SimplifiedTextFromFile(fileName);

            var plagiarismInLocalDB = await PlagiarismInLocalDBFinder.Find(simplifiedText);

            richTextBox1.Text += simplifiedText + Environment.NewLine;
            richTextBox1.Text += $"Words count: {plagiarismInLocalDB.WordCount}" + Environment.NewLine;

            textBox2.Text += "Водность текста: " + plagiarismInLocalDB.Vodnost + " % " + Environment.NewLine;
            textBox2.Text += "Тошнотность текста: " + plagiarismInLocalDB.Toshnotnost + " % " + Environment.NewLine;

            foreach (var kvp in plagiarismInLocalDB.PlagiarismResult)
            {
                textBox2.Text += "DocumentID: " + kvp.Key + "\tWord Indexes: ";
                foreach (var item in kvp.Value)
                {
                    textBox2.Text += item + ", ";
                }
                textBox2.Text += Environment.NewLine;
            }
        }
示例#2
0
        private async Task SearchForPlagiarismInWeb(string fileName)
        {
            richTextBox1.Text = string.Empty;
            textBox2.Text     = string.Empty;

            var simplifiedText = TextDocumentManager.SimplifiedTextFromFile(fileName);

            var plagiarismInWeb = await PlagiarismInWebFinder.Find(simplifiedText);

            richTextBox1.Text += simplifiedText + Environment.NewLine;
            richTextBox1.Text += $"Words count: {plagiarismInWeb.WordCount}" + Environment.NewLine;
            ShowUrlToWordIndexes(plagiarismInWeb.OrderedUrls, plagiarismInWeb.OrderedUrlToWordsIndexes);

            _webResults = plagiarismInWeb.OrderedWebResults;
            for (int i = 0; i < _webResults.Count; i++)
            {
                textBox2.Text += _webResults[i].Url;
                textBox2.Text += Environment.NewLine;

                textBox2.Text += String.Format("{0:P2} text found", _webResults[i].CharactersPercentage);
                textBox2.Text += Environment.NewLine;

                foreach (var commonTextPart in _webResults[i].CommonTextParts)
                {
                    textBox2.Text += commonTextPart;
                    textBox2.Text += Environment.NewLine;
                }

                textBox2.Text += Environment.NewLine;
            }
        }
示例#3
0
 /// <summary>
 /// The given workspace represents the original workspace. A callback is invoked every time this provider decides to recompute the workspace.
 /// </summary>
 public IncrementalWorkspaceProvider(FrontEndHostController controller, PathTable pathTable, Workspace workspace, TextDocumentManager documentManager, TestContext?testContext)
 {
     m_controller             = controller;
     m_workspace              = workspace;
     m_documentManager        = documentManager;
     m_testContext            = testContext;
     documentManager.Changed += DocumentChanged;
     m_pathTable              = pathTable;
     m_timer = new Timer(_ => RecomputeWorkspaceForLatestChangedDocuments(), state: null, dueTime: Timeout.Infinite, period: Timeout.Infinite);
 }
示例#4
0
        public async Task <ActionResult> Main(HttpPostedFileBase file)
        {
            if (file?.ContentLength > 0 && (Path.GetFileName(file.FileName).Split('.')[1] == "doc" || Path.GetFileName(file.FileName).Split('.')[1] == "docx"))
            {
                var types    = file.ContentType;
                var fileName = Path.GetFileName(file.FileName);
                var path     = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
                file.SaveAs(path);

                var initialText = TextDocumentManager.TextFromFile(path);
                TextManager.PrepareText(initialText, out string[] initialWords, out Dictionary <int, string> initialDocIndexToSimplifiedWord, out int[] initialDocIndexes, out string[] simplifiedWords, out int wordCount);

                var plagiarismInWebSearch     = PlagiarismInWebFinder.FindAsync(initialWords, initialDocIndexToSimplifiedWord, initialDocIndexes, simplifiedWords, Server.MapPath("~/App_Data/uploads"));
                var plagiarismInLocalDBSearch = PlagiarismInLocalDBFinder.FindAsync(initialWords, initialDocIndexToSimplifiedWord, initialDocIndexes, simplifiedWords);

                await Task.WhenAll(plagiarismInWebSearch, plagiarismInLocalDBSearch);

                var plagiarismInWeb     = plagiarismInWebSearch.Result;
                var plagiarismInLocalDB = plagiarismInLocalDBSearch.Result;

                var DBPlagiarizedIndexes = plagiarismInLocalDB.InitialWordIndexToSourceIds.Keys.ToList();
                DBPlagiarizedIndexes.AddRange(plagiarismInWeb.InitialWordIndexToSourceIds.Keys.ToList());
                var allPlagiarismHtmlText = TextManager.ComposeHtmlText(initialWords, DBPlagiarizedIndexes);

                var(vodnost, toshnotnost) = TextAnalyzer.Analyze(simplifiedWords);
                PlagiarismResult plagiarism = new PlagiarismResult
                {
                    InitialWords          = initialWords,
                    SimplifiedWords       = simplifiedWords,
                    WordCount             = wordCount,
                    Vodnost               = vodnost,
                    Toshnotnost           = toshnotnost,
                    PlagiarismWeb         = plagiarismInWeb,
                    PlagiarismDB          = plagiarismInLocalDB,
                    AllPlagiarismHtmlText = allPlagiarismHtmlText,
                    DebugLogs             = plagiarismInWeb.DebugLogs + plagiarismInLocalDB.DebugLogs
                };
                ViewBag.DebugLogs = plagiarism.DebugLogs;
                foreach (KeyValuePair <int, HashSet <int> > lists in plagiarismInLocalDB.SourceIdToSourceWordsIndexes)
                {
                    Session["Doc" + lists.Key] = lists.Value;
                }
                foreach (KeyValuePair <string, HashSet <int> > lists in plagiarismInWeb.SourceIdToSourceWordsIndexes)
                {
                    Session[lists.Key] = lists.Value;
                }

                return(View("Main", plagiarism));
            }

            return(RedirectToAction("Main"));
        }
示例#5
0
文件: Program.cs 项目: qmark/AntiPFIT
        static void Main(string[] args)
        {
            //string nameFile = "Пар 3-01 Інтеграл Ньютона-Лейбніца";
            //string test = TextDocumentManager.TextFromFile(@"C:\Users\alex1\Desktop\" + nameFile + ".doc");
            //AddDocument(nameFile, test);
            //test = TextManager.SimplifyText(test).Replace("\r\n", " ");
            //AddWords(Logic.IndexingForDB(TextManager.WordsFromText(test).ToArray()), nameFile);

            string[] files = new string[5];
            files[0] = "Пар 3-01 Інтеграл Ньютона-Лейбніца.doc";
            files[1] = "LOL.docx";
            files[2] = "GPK.docx";
            files[3] = "Середа оцінювання адаптивних інтерфейсів користувачів.docx";
            files[4] = "Документ для теста.docx";
            // string fileName = "Пар 3-01 Інтеграл Ньютона-Лейбніца";
            for (int i = 0; i < 5; i++)
            {
                string initialText = TextDocumentManager.TextFromFile(@"C:\Users\alex1\Desktop\" + files[i]);
                AddDocument(files[i], initialText);
                TextManager.PrepareText(initialText, out string[] initialWords, out Dictionary <int, string> initialDocIndexToSimplifiedWord, out int[] initialDocIndexes, out string[] simplifiedWords, out int wordCount);
                AddWords(Logic.IndexingForDB(initialDocIndexes, simplifiedWords), files[i]);
            }



            //string str = "";
            //List<String> example = new List<string> { "index", "data", "are", "the", "of" };
            //foreach (KeyValuePair<int, List<List<int>>> pair in GetDocuments(example))
            //{

            //    Console.WriteLine("Документ - " + pair.Key);
            //    foreach (List<int> positions in pair.Value)
            //    {
            //        foreach (int pos in positions)
            //        {
            //            str += Convert.ToString(pos) + " ";
            //        }
            //        Console.WriteLine("  Позицiї - " + str);
            //        str = "";
            //    }
            //}
            Console.WriteLine("Ready");
            Console.ReadKey();
        }
示例#6
0
        private void CompareTextButton_Click(object sender, EventArgs e)
        {
            Stopwatch s = new Stopwatch();

            s.Start();

            var oldText = TextDocumentManager.SimplifiedTextFromFile(oldTextFile);
            var newText = TextDocumentManager.SimplifiedTextFromFile(newTextFile);

            s.Stop();
            textBox2.Text += $"\tReading: {s.Elapsed}" + Environment.NewLine;
            s.Restart();

            var diffResuls = TextComparer.CompareByWords(oldText, newText);

            //CompareLines(oldText, newText);

            richTextBox1.ShowDifferences(diffResuls);

            s.Stop();
            textBox2.Text += $"\tComparing: {s.Elapsed}" + Environment.NewLine;
        }