コード例 #1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     clearText();
     w = null;
     p = new Parser("Assets/" + ((MenuFlyoutItem)sender).Text + ".txt");
     ChapterDisplay.ItemsSource = p.chapters;
     TextStatsBlock.Text        = p.fullTextWordTracker.getStats();
 }
コード例 #2
0
ファイル: Parser.cs プロジェクト: NeonVanadium/BookParser
        public Parser(string textPath)
        {
            text = System.IO.File.ReadAllLines(textPath);
            fullTextWordTracker = new WordTracker(textPath.Substring(textPath.IndexOf('/') + 1, textPath.Length - 4 - "Assets/".Length));
            relatopedia         = new Dictionary <string, Dictionary <string, int> >();
            wordList            = new LinkedList <string>();

            foreach (String line in text)
            {
                if (line.StartsWith("//"))
                {
                    curChapter = new WordTracker(line.Substring(2));
                    chapters.Add(curChapter);
                }
                else if (curChapter != null)
                {
                    foreach (String word in line.Split(' '))
                    {
                        if (isValid(word))   //if this is an actual sequence of letters and not literal nothing

                        {
                            string formatted = format(word);

                            if (!isTrivialWord(formatted)) //we only care about the connotations of non-trivial words
                            {
                                int distance = 0;
                                foreach (string s in wordList)
                                {
                                    relatopediaAdd(formatted, s, listSize - distance);
                                    relatopediaAdd(s, formatted, listSize - distance);
                                    distance++;
                                }

                                enqueue(formatted);
                            }

                            fullTextWordTracker.addWord(formatted);
                            curChapter.addWord(formatted);
                        }
                    }
                }
            }


            //parse that boi
        }
コード例 #3
0
ファイル: Parser.cs プロジェクト: NeonVanadium/BookParser
        public void sortByPrevalence() //sorts the list of chapters by the frequency of the current search term, with chapters that have no occurences sorted to the bottom
        {
            int         length = chapters.Count;
            WordTracker temp   = null;

            for (int i = 0; i < length; i++)
            {
                for (int j = i; j < chapters.Count(); j++)
                {
                    if (chapters[j].sortValue() > chapters[i].sortValue())
                    {
                        temp        = chapters[i];
                        chapters[i] = chapters[j];
                        chapters[j] = temp;
                    }
                }
            }

            InterfacePage.updateCurParserChapters(chapters);
        }
コード例 #4
0
 private void ChapterDisplay_ItemClick(object sender, ItemClickEventArgs e)
 {
     w = ((WordTracker)e.ClickedItem);
     updateText();
 }