Exemplo n.º 1
0
        private void importBibTeXToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "BibTeX Files|*.bib";
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            BibtexParser parser = new BibtexParser(new StreamReader(new FileStream(openFileDialog1.FileName, FileMode.Open)));

            try
            {
                var result = parser.Parse();


                foreach (var entry in result.Database.getEntries())
                {
                    AddBibTeXEntry(entry);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("The following error occurred when parsing the BibTeX file: {0}", ex.Message));
            }
        }
Exemplo n.º 2
0
        public void MultipleEntriesTest()
        {
            Tokenizer    tokenizer = new Tokenizer(new ExpressionDictionary(), @"@book{ aaker:1912,
                                                                                author = {David A. Aaker},
                                                                                title = {Multivariate statistics}
                                                                            }
                                                                            @book{ baker:1912,
                                                                                author = {David A. Baker},
                                                                                title = {Multivariate statistics 2}
                                                                            }");
            BibtexParser parser    = new BibtexParser(tokenizer);
            BibtexFile   file      = parser.Parse();

            Assert.AreEqual(2, file.Entries.Count);
            Assert.AreEqual("aaker:1912", file.Entries.First().Key);
            Assert.AreEqual("book", file.Entries.First().Type);
            Assert.AreEqual(2, file.Entries.First().Tags.Count);
            Assert.AreEqual("author", file.Entries.First().Tags.First().Key);
            Assert.AreEqual("David A. Aaker", file.Entries.First().Tags.First().Value);
            Assert.AreEqual("title", file.Entries.First().Tags.ToList()[1].Key);
            Assert.AreEqual("Multivariate statistics", file.Entries.First().Tags.ToList()[1].Value);

            Assert.AreEqual("baker:1912", file.Entries.ToList()[1].Key);
            Assert.AreEqual("book", file.Entries.ToList()[1].Type);
            Assert.AreEqual(2, file.Entries.ToList()[1].Tags.Count);
            Assert.AreEqual("author", file.Entries.ToList()[1].Tags.First().Key);
            Assert.AreEqual("David A. Baker", file.Entries.ToList()[1].Tags.First().Value);
            Assert.AreEqual("title", file.Entries.ToList()[1].Tags.ToList()[1].Key);
            Assert.AreEqual("Multivariate statistics 2", file.Entries.ToList()[1].Tags.ToList()[1].Value);
        }
Exemplo n.º 3
0
 private void btnSearch_Click(object sender, RoutedEventArgs e)
 {
     //Downloader.AllocConsole();
     //var stopwatch = Stopwatch.StartNew();
     Task.Factory.StartNew(() => BibtexParser.LoadBibtexFile());
     //stopwatch.Stop();
     //Console.WriteLine("Processing time " + stopwatch.Elapsed.Minutes + ":" + stopwatch.Elapsed.Milliseconds);
     //Console.ReadKey();
 }
Exemplo n.º 4
0
        public void FuzzyMiningTestFileTest()
        {
            using (StreamReader reader = new StreamReader("Test Files\\Fuzzy Mining.bib"))
            {
                Tokenizer    tokenizer = new Tokenizer(new ExpressionDictionary(), reader.ReadToEnd());
                BibtexParser parser    = new BibtexParser(tokenizer);
                BibtexFile   file      = parser.Parse();

                Assert.AreEqual(3, file.Entries.Count);
            }
        }
Exemplo n.º 5
0
        private void importBibTexFromClipBoardToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
            {
                BibtexParser parser = new BibtexParser(new StringReader(Clipboard.GetDataObject().GetData(DataFormats.Text).ToString()));
                var          result = parser.Parse();
                db = result.Database;

                foreach (var entry in db.getEntries())
                {
                    AddBibTeXEntry(entry);
                }
            }
        }
Exemplo n.º 6
0
        Dictionary <string, BibtexEntry> GetBibtexEntries(StreamReader reader)
        {
            var parser = new BibtexParser(reader);
            var result = parser.Parse();
            var db     = result.Database;

            var entries = new Dictionary <string, BibtexEntry>();

            foreach (var entry in db.getEntries())
            {
                entries[entry.getCiteKey()] = entry;
            }

            return(entries);
        }
Exemplo n.º 7
0
        public void BracesInValueTest()
        {
            Tokenizer    tokenizer = new Tokenizer(new ExpressionDictionary(), @"@book{ aaker:1912,
                                                                                author = {David A. ()ker},
                                                                            }");
            BibtexParser parser    = new BibtexParser(tokenizer);
            BibtexFile   file      = parser.Parse();

            Assert.AreEqual(1, file.Entries.Count);
            Assert.AreEqual("aaker:1912", file.Entries.First().Key);
            Assert.AreEqual("book", file.Entries.First().Type);
            Assert.AreEqual(1, file.Entries.First().Tags.Count);
            Assert.AreEqual("author", file.Entries.First().Tags.First().Key);
            Assert.AreEqual("David A. ()ker", file.Entries.First().Tags.First().Value);
        }
Exemplo n.º 8
0
        public void SimpleParserWithDoubleQuoteTest()
        {
            Tokenizer    tokenizer = new Tokenizer(new ExpressionDictionary(), @"@book{ aaker:1912,
                                                                                author = ""David A. Aaker""
                                                                              }");
            BibtexParser parser    = new BibtexParser(tokenizer);
            BibtexFile   file      = parser.Parse();

            Assert.AreEqual(1, file.Entries.Count);
            Assert.AreEqual("aaker:1912", file.Entries.First().Key);
            Assert.AreEqual("book", file.Entries.First().Type);
            Assert.AreEqual(1, file.Entries.First().Tags.Count);
            Assert.AreEqual("author", file.Entries.First().Tags.First().Key);
            Assert.AreEqual("David A. Aaker", file.Entries.First().Tags.First().Value);
        }
Exemplo n.º 9
0
        public void CommaInTagValueParseTest()
        {
            Tokenizer tokenizer = new Tokenizer(new ExpressionDictionary(), @"@book{ aaker:1912,
                                                                                author = {Günther, C.W. and Van Der Aalst, W.M.P.}
                                                                            }");

            BibtexParser parser = new BibtexParser(tokenizer);
            BibtexFile   file   = parser.Parse();

            Assert.AreEqual(1, file.Entries.Count);
            Assert.AreEqual("aaker:1912", file.Entries.First().Key);
            Assert.AreEqual("book", file.Entries.First().Type);
            Assert.AreEqual(1, file.Entries.First().Tags.Count);
            Assert.AreEqual("author", file.Entries.First().Tags.First().Key);
            Assert.AreEqual("Günther, C.W. and Van Der Aalst, W.M.P.", file.Entries.First().Tags.First().Value);
        }
Exemplo n.º 10
0
        public void ParseStringDefinitionsTest()
        {
            Tokenizer    tokenizer = new Tokenizer(new ExpressionDictionary(), @"
                                                                            @String{pub-ACM = ""ACM Press""}
                                                                            @book{ aaker:1912,
                                                                                author = { tes(;)est }
                                                                            }");
            BibtexParser parser    = new BibtexParser(tokenizer);
            BibtexFile   file      = parser.Parse();

            Assert.IsTrue(file.StringDefinitions.ContainsKey("pub-ACM"));
            Assert.AreEqual("ACM Press", file.StringDefinitions["pub-ACM"]);

            Assert.AreEqual(1, file.Entries.Count);
            Assert.AreEqual("aaker:1912", file.Entries.First().Key);
            Assert.AreEqual("book", file.Entries.First().Type);
        }
Exemplo n.º 11
0
        public static BibtexFile FromString(string text)
        {
            BibtexParser file = new BibtexParser(new Tokenizer.Tokenizer(new ExpressionDictionary(), text));

            return(file.Parse());
        }