Beispiel #1
0
class ReferenceEntryFormatter(object):
    def __init__(self, format=ReferenceFormat.BIBTEX):
        self.reference_gw = ReferenceGateway()
        self.format = format
        self.util_factory = UtilFactory()

    def format_reference(self, reference_id):
        log.debug(
            'Retrieving reference from the database')  #@UndefinedVariable
        reference = self.reference_gw.find_reference_by_id(reference_id)
        if not reference:
            log.error(
                'Reference with id %d could not be retrieved'  #@UndefinedVariable
                % reference_id)
            return None

        formatter = ReferenceFormatter()
        try:
            generator = self.util_factory.create_generator(self.format)
        except UtilCreationError as e:
            log.error('Could not create a formatter for %s: %s'
                      %  #@UndefinedVariable
                      (self.format, e.args))
            return None

        log.debug('Starting to format')  #@UndefinedVariable
        formatter.format_reference(reference, generator)

        return reference.entry
Beispiel #2
0
class ReferenceEntryFormatter(object):
    def __init__(self, format=ReferenceFormat.BIBTEX):
        self.reference_gw = ReferenceGateway()
        self.format = format
        self.util_factory = UtilFactory()
        
    def format_reference(self, reference_id):
        log.debug('Retrieving reference from the database') #@UndefinedVariable
        reference = self.reference_gw.find_reference_by_id(reference_id)
        if not reference:
            log.error('Reference with id %d could not be retrieved'  #@UndefinedVariable
                      % reference_id)
            return None
        
        formatter = ReferenceFormatter()
        try:
            generator = self.util_factory.create_generator(self.format)
        except UtilCreationError as e:
            log.error('Could not create a formatter for %s: %s' % #@UndefinedVariable
                      (self.format, e.args))
            return None
        
        log.debug('Starting to format') #@UndefinedVariable
        formatter.format_reference(reference, generator)
        
        return reference.entry
Beispiel #3
0
 def __init__(self, format=ReferenceFormat.BIBTEX):
     super(ReferenceImporter, self).__init__()
     self.name = 'Importer'
     self.format = format
     self.util_factory = UtilFactory()
     self.ref_controller = ReferencesController(self.util_factory,
                                                self.format)
     self.path = ''
 def __init__(self):
     self.factory = UtilFactory()
     self.rce = controllers.RCEController(self.factory, 10, 10)
     self.ir = controllers.IRController(self.factory)
     self.results_cache_filename = 'customHeaders_cache_file.txt'
     self.results_cache = {}
     self.browser = Browser()
     self.basepath = '/home/rxuriguera/benchmark/pdfsets/pageHeader/'
     self.basename = 'pageHeader'
     self.len_range = range(4, 15)
class TestUtilFactory(unittest.TestCase):

    def setUp(self):
        self.uf = UtilFactory()

    def tearDown(self):
        pass

    def test_create_extractor(self):
        extractor = self.uf.create_extractor(FileFormat.PDF, FileFormat.TXT) #@UnusedVariable
        self.assertRaises(UtilCreationError,
            self.uf.create_extractor, FileFormat.TXT, FileFormat.PDF)
Beispiel #6
0
    def __init__(self):

        self.info = {}
        
        self.nexamples = 4
        self.base_path = '/home/rxuriguera/benchmark/pages/'
        self.fields = ['addres', 'author', 'isbn', 'issn', 'journal', 'number', 'pages', 'publisher', 'title', 'volume', 'year']
        self.libraries = ['informaworld']#['acm', 'citeulike', 'computerorg', 'econpapers', 'ideas', 'informaworld', 'sciencedirect', 'scientificcommons', 'springer']
        
        self.factory = UtilFactory()
        self.iec = IEController(self.factory, secs_between_reqs=0,
                                wrapper_gen_examples=self.nexamples)
        self.rec = ReferencesController(self.factory)
Beispiel #7
0
 def setUp(self):
     factory = UtilFactory()
     self.iec = IEController(factory, ReferenceFormat.BIBTEX)
     self.top_results = [
         SearchResult(
             'result01',
             'http://portal.acm.org/citation.cfm?id=507338.507355'),
         SearchResult(
             'result01',
             'http://www.springerlink.com/index/D7X7KX6772HQ2135.pdf')
     ]
     self.empty_page = BeautifulSoup("<html><head/><body/></html>")
     self.page = self._get_soup('acm01.html')
     self.text = 'ss'
 def setUp(self):
     self.uf = UtilFactory()
 def setUp(self):
     factory = UtilFactory()
     self.rec = ReferencesController(factory, ReferenceFormat.BIBTEX)
     self.path = normpath(
         join(dirname(__file__), ('../../../../tests/'
                                  'fixtures/references/bibtex/import.bib')))
Beispiel #10
0
 def __init__(self, format=ReferenceFormat.BIBTEX):
     self.reference_gw = ReferenceGateway()
     self.format = format
     self.util_factory = UtilFactory()
Beispiel #11
0
 def __init__(self, url):
     super(WrapperGenerator, self).__init__()
     self.name = 'WrapTrainer'
     self.url = url
     self.factory = UtilFactory()
     self.ie_controller = IEController(self.factory)
Beispiel #12
0
 def __init__(self, format=ReferenceFormat.BIBTEX):
     self.reference_gw = ReferenceGateway()
     self.format = format
     self.util_factory = UtilFactory()
 def setUp(self):
     factory = UtilFactory()
     self.rcec = RCEController(factory)
     self.pdf = normpath(join(dirname(__file__), ('../../../../tests/'
                                  'fixtures/extraction/article.pdf')))
 def __init__(self):
     self.factory = UtilFactory()