コード例 #1
0
    def test_Parser(self):
        """test the functioning of the parser"""
        parser = XMLParser()
        if parser.isAvailable():
            source = open(setup.MEDLINE_TEST_XML, 'r').read()
            self.failUnless(source)
            
            entries = TestEntries(parser.getEntries(source))
            
            # are there enough entries?
            self.failUnless(len(entries) == 4)
            # are there the right number of authors?
            self.failUnless(len(entries.author_last_names()) == 13)
            # test individual name parsings:
            #  lastname, one initial
            this_entry = entries.entryByTitle("Molecular genetic evidence for parthenogenesis in the Burmese python, Python molurus bivittatus.")
            expected_author = {"firstname": "E.", "middlename": "","lastname": "Bruins"}
            self.failUnless(this_entry.authorIsPresent(expected_author), "author: %s is not listed" % expected_author)
            # lastname, more than one initial
            expected_author = {"firstname": "T.", "middlename": "V. M.","lastname": "Groot"}
            self.failUnless(this_entry.authorIsPresent(expected_author), "author: %s is not listed" % expected_author)
            # lastname, firstname, middle initial
            this_entry = entries.entryByTitle("Pharmacokinetics and tissue concentrations of azithromycin in ball pythons (Python regius).")
            expected_author = {"firstname": "Robert", "middlename": "P.","lastname": "Hunter"}
            self.failUnless(this_entry.authorIsPresent(expected_author), "author: %s is not listed" % expected_author)
            
                                
        else:
            print """\nOne or more transformationtool was not found!
please make sure bibutils is installed to run all tests. """
            print ("-" * 20) + "\n"
コード例 #2
0
    def test_Parser(self):
        """test the functioning of the parser"""
        parser = XMLParser()
        if parser.isAvailable():
            source = open(setup.MEDLINE_TEST_XML, 'r').read()
            self.failUnless(source)

            entries = TestEntries(parser.getEntries(source))

            # are there enough entries?
            self.failUnless(len(entries) == 4)
            # are there the right number of authors?
            self.failUnless(len(entries.author_last_names()) == 13)
            # test individual name parsings:
            #  lastname, one initial
            this_entry = entries.entryByTitle(
                "Molecular genetic evidence for parthenogenesis in the Burmese python, Python molurus bivittatus."
            )
            expected_author = {
                "firstname": "E.",
                "middlename": "",
                "lastname": "Bruins"
            }
            self.failUnless(this_entry.authorIsPresent(expected_author),
                            "author: %s is not listed" % expected_author)
            # lastname, more than one initial
            expected_author = {
                "firstname": "T.",
                "middlename": "V. M.",
                "lastname": "Groot"
            }
            self.failUnless(this_entry.authorIsPresent(expected_author),
                            "author: %s is not listed" % expected_author)
            # lastname, firstname, middle initial
            this_entry = entries.entryByTitle(
                "Pharmacokinetics and tissue concentrations of azithromycin in ball pythons (Python regius)."
            )
            expected_author = {
                "firstname": "Robert",
                "middlename": "P.",
                "lastname": "Hunter"
            }
            self.failUnless(this_entry.authorIsPresent(expected_author),
                            "author: %s is not listed" % expected_author)

        else:
            print """\nOne or more transformationtool was not found!
please make sure bibutils is installed to run all tests. """
            print("-" * 20) + "\n"
コード例 #3
0
    def test_import(self):
        source = open(setup.MEDLINE_TEST_MED, 'r').read()
        self.failUnless(source)

        parser = MedlineParser()
        entries = TestEntries(parser.getEntries(source))
        self.failUnless(len(entries) == 4)
        expected_author_last_names = ("Groot","Bruins","Breeuwer","Alibardi",\
                                          "Thompson","Coke","Hunter","Isaza",\
                                          "Koch","Goatley","Carpenter",\
                                          "Trape","Mane",)

        parsed_author_last_names = entries.author_last_names()
        for name in expected_author_last_names:
            self.failUnless(name in parsed_author_last_names,
                            'Parse failed - missing author %s' % name)
コード例 #4
0
    def test_import(self):
        source = open(setup.MEDLINE_TEST_MED, 'r').read()
        self.failUnless(source)

        parser = MedlineParser()
        entries = TestEntries(parser.getEntries(source))
        self.failUnless(len(entries) == 4)
        expected_author_last_names = ("Groot","Bruins","Breeuwer","Alibardi",\
                                          "Thompson","Coke","Hunter","Isaza",\
                                          "Koch","Goatley","Carpenter",\
                                          "Trape","Mane",)

        parsed_author_last_names = entries.author_last_names()
        for name in expected_author_last_names:
            self.failUnless(name in parsed_author_last_names,
                            'Parse failed - missing author %s' % name)
コード例 #5
0
    def test_Parser(self):
        """test the functioning of the parser"""
        parser = RISParser()
        if parser.isAvailable():
            source = open(setup.RIS_SOURCE, 'r').read()
            self.failUnless(source)

            entries = TestEntries(parser.getEntries(source))
            self.failUnless(len(entries) == 7)
            self.failUnless(
                'Markets and Municipalities: A Study of the Behavior of the Danish Municipalities'
                in entries.titles())

            entry = entries.entries[0]
            self.failUnless(entry.pages == '79--102')
            self.failUnless(entry.volume == '114')
            self.failUnless(entry.number == '1 - 2')
            self.failUnless(entry.publication_year == '2003')
            self.failUnless(entry.journal == 'Public Choice')
            # XXX This test could be adjusted if the parser got smarter about
            #     about converting 'Mar.' into 'March'
            ## rr: which it did inbetween it seems because I had to add
            ## the fully spelled out month names to the 'month_mapper' dict.
            self.failUnless(entry.publication_month == '01')

            entry_authors = entries.entries[0].authors
            self.failUnless(len(entry_authors) == 2)
            self.failUnless(entry_authors[0]['lastname'] == 'Christoffersen')
            self.failUnless(entry_authors[0]['firstname'] == 'Henrik')
            self.failUnless(entry_authors[0]['middlename'] == '')
            self.failUnless(entry_authors[1]['lastname'] == 'Paldam')
            self.failUnless(entry_authors[1]['firstname'] == 'Martin')
            self.failUnless(entry_authors[1]['middlename'] == '')

            last_entry = entries.entries[-1]
            self.assertEqual(last_entry.authors[1]['lastname'],
                             u'M\xfcller'.encode('utf-8'))

        else:
            print """\nOne or more transformationtool was not found!
please make sure bibutils is installed to run all tests. """
            print("-" * 20) + "\n"
コード例 #6
0
    def test_parser_with_umlauts(self):
        parser = XMLParser()
        if parser.isAvailable():
            source = open(setup.UMLAUTS_TEST_XML, 'r').read()
            self.failUnless(source)

            entries = TestEntries(parser.getEntries(source))
            self.failUnless(len(entries) == 1)
            entry = entries.entries[0]
            self.assertEqual(entry.publisher,
                             u'Übersöpf Verlag'.encode('utf-8'))
コード例 #7
0
    def test_import(self):

        if self.parser.isAvailable():
            source = open(setup.ENDNOTE_TEST_SOURCE, 'r').read()
            self.failUnless(source)
            entries = TestEntries(self.parser.getEntries(source))
            self.failUnless(len(entries) == 2)
            expected_author_last_names = ('Dufour', 'Fieschi', 'Hergon',
                                          'Joubert', 'Raps', 'Staccini',)

            parsed_author_last_names = entries.author_last_names()
            for name in expected_author_last_names:
                self.failUnless(name in parsed_author_last_names,
                                'Parse failed - missing author %s' % name)

            expected_titles = ('Combining advanced networked technology and pedagogical methods to improve collaborative distance learning',
                               'Collaborative and workflow-oriented digital portfolio: Creating a web-based tool to support a nationwide program of practices evaluation in the blood transfusion area',)
                               
            parsed_titles = [e.title for e in entries.entries]
            for title in expected_titles:
                self.failUnless(title in parsed_titles,
                                'Parse failed - missing expected title "%s"' %
                                title)
            # Keywords - first entry in sample file has none, second has 9
            self.failIf(hasattr(entries.entries[0],'keywords')
                        and entries.entries[0].keywords,
                        'Parsed non existing keywords')
            self.failUnless(len(entries.entries[1].keywords) == 9)
            # Confirm a few w/ tricky characters survived the parse
            kwds = ["Health Services Research/ organization & administration",
                    "Primary Health Care/ standards",
                    "Program Evaluation",
                    "Quality Assurance, Health Care"]
            for keyword in kwds:
                self.failUnless(keyword in entries.entries[1].keywords,
                                "Failed to correctly parse keyword: '%s'" % keyword)
        else:
            print """\nOne or more transformationtool was not found!
please make sure bibutils is installed to run all tests. """
            print ("-" * 20) + "\n"
コード例 #8
0
    def test_Parser(self):
        """test the functioning of the parser"""
        parser = RISParser()
        if parser.isAvailable():
            source = open(setup.RIS_SOURCE, 'r').read()
            self.failUnless(source)

            entries = TestEntries(parser.getEntries(source))
            self.failUnless( len(entries) == 7 )
            self.failUnless( 'Markets and Municipalities: A Study of the Behavior of the Danish Municipalities' in entries.titles())

            entry = entries.entries[0]
            self.failUnless( entry.pages == '79--102' )
            self.failUnless( entry.volume == '114' )
            self.failUnless( entry.number == '1 - 2' )
            self.failUnless( entry.publication_year == '2003' )
            self.failUnless( entry.journal == 'Public Choice' )
            # XXX This test could be adjusted if the parser got smarter about
            #     about converting 'Mar.' into 'March'
            ## rr: which it did inbetween it seems because I had to add
            ## the fully spelled out month names to the 'month_mapper' dict.
            self.failUnless( entry.publication_month == '01' )

            entry_authors = entries.entries[0].authors
            self.failUnless( len( entry_authors ) == 2 )
            self.failUnless( entry_authors[0]['lastname'] == 'Christoffersen' )
            self.failUnless( entry_authors[0]['firstname'] == 'Henrik' )
            self.failUnless( entry_authors[0]['middlename'] == '' )
            self.failUnless( entry_authors[1]['lastname'] == 'Paldam' )
            self.failUnless( entry_authors[1]['firstname'] == 'Martin' )
            self.failUnless( entry_authors[1]['middlename'] == '' )

            last_entry = entries.entries[-1]
            self.assertEqual(last_entry.authors[1]['lastname'], u'M\xfcller'.encode('utf-8'))

        else:
            print """\nOne or more transformationtool was not found!
please make sure bibutils is installed to run all tests. """
            print ("-" * 20) + "\n"