def preprocess_plain_text_string(self, text, pmid, extra_annotations):
        """Preprocess plain text string for use by ISI reader.

        Preprocessing is done by tokenizing into sentences and writing
        each sentence on its own line in a plain text file. All other
        preprocessing functions ultimately call this one.

        Parameters
        ----------
        text : str
            The plain text of the article of abstract
        pmid : str
            The PMID from which it comes, or None if not specified
        extra_annotations : dict
            Extra annotations to be added to each statement, possibly including
            metadata about the source (annotations with the key "interaction"
            will be overridden)
        """
        output_file = '%s.txt' % self.next_file_id
        output_file = os.path.join(self.preprocessed_dir, output_file)

        # Tokenize sentence
        sentences = nltk.sent_tokenize(text)

        # Write sentences to text file
        first_sentence = True
        with codecs.open(output_file, 'w', encoding='utf-8') as f:
            for sentence in sentences:
                if not first_sentence:
                    f.write('\n')
                f.write(sentence.rstrip())
                first_sentence = False

        # Store annotations
        self.pmids[str(self.next_file_id)] = pmid
        self.extra_annotations[str(self.next_file_id)] = extra_annotations

        # Increment file id
        self.next_file_id += 1
def preprocess_plain_text_string ( self , text , pmid , extra_annotations ) : output_file = '%s.txt' % self . next_file_id output_file = os . path . join ( self . preprocessed_dir , output_file ) sentences = nltk . sent_tokenize ( text ) first_sentence = True with codecs . open ( output_file , 'w' , encoding = 'utf-8' ) as f : for sentence in sentences : if not first_sentence : f . write ( '\n' ) f . write ( sentence . rstrip ( ) ) first_sentence = False self . pmids [ str ( self . next_file_id ) ] = pmid self . extra_annotations [ str ( self . next_file_id ) ] = extra_annotations self . next_file_id += 1
Preprocess plain text string for use by ISI reader.

        Preprocessing is done by tokenizing into sentences and writing
        each sentence on its own line in a plain text file. All other
        preprocessing functions ultimately call this one.

        Parameters
        ----------
        text : str
            The plain text of the article of abstract
        pmid : str
            The PMID from which it comes, or None if not specified
        extra_annotations : dict
            Extra annotations to be added to each statement, possibly including
            metadata about the source (annotations with the key "interaction"
            will be overridden)