def prep_input(self, read_list):
        "Prepare the list of files or text content objects to be read."
        logger.info('Prepping input for sparser.')

        self.file_list = []

        for content in read_list:
            quality_issue = self._check_content(content.get_text())
            if quality_issue is not None:
                logger.warning("Skipping %d due to: %s"
                               % (content.get_id(), quality_issue))
                continue

            if content.is_format('nxml'):
                # If it is already an nxml, we just need to adjust the
                # name a bit, if anything.
                if not content.get_filename().startswith('PMC'):
                    content.change_id('PMC' + str(content.get_id()))
                fpath = content.copy_to(self.tmp_dir)
                self.file_list.append(fpath)
            elif content.is_format('txt', 'text'):
                # Otherwise we need to frame the content in xml and put it
                # in a new file with the appropriate name.
                nxml_str = sparser.make_nxml_from_text(content.get_text())
                new_content = Content.from_string('PMC' + str(content.get_id()),
                                                  'nxml', nxml_str)
                fpath = new_content.copy_to(self.tmp_dir)
                self.file_list.append(fpath)
            else:
                raise SparserError("Unrecognized format %s."
                                   % content.format)
        return
def prep_input ( self , read_list ) : logger . info ( 'Prepping input for sparser.' ) self . file_list = [ ] for content in read_list : quality_issue = self . _check_content ( content . get_text ( ) ) if quality_issue is not None : logger . warning ( "Skipping %d due to: %s" % ( content . get_id ( ) , quality_issue ) ) continue if content . is_format ( 'nxml' ) : if not content . get_filename ( ) . startswith ( 'PMC' ) : content . change_id ( 'PMC' + str ( content . get_id ( ) ) ) fpath = content . copy_to ( self . tmp_dir ) self . file_list . append ( fpath ) elif content . is_format ( 'txt' , 'text' ) : nxml_str = sparser . make_nxml_from_text ( content . get_text ( ) ) new_content = Content . from_string ( 'PMC' + str ( content . get_id ( ) ) , 'nxml' , nxml_str ) fpath = new_content . copy_to ( self . tmp_dir ) self . file_list . append ( fpath ) else : raise SparserError ( "Unrecognized format %s." % content . format ) return
Prepare the list of files or text content objects to be read.