Exemplo n.º 1
0
    def _removeInTextExpansions(self, article, acronyms):
        expander = Expander_fromText()

        for acronym in acronyms:
            for pattern in expander.definition_patterns(acronym):
                results = pattern.findall(article)
                for result in results:
                    article = article.replace(result, " ")

        self.__verifyRemovalOfInTextExpansions(article, acronyms)

        return article
Exemplo n.º 2
0
    def __verifyRemovalOfInTextExpansions(self, article_for_testing, acronyms):
        expander = Expander_fromText()

        for acronym in acronyms:
            for pattern in expander.definition_patterns(acronym):
                if(len(pattern.findall(article_for_testing)) > 0):
                    errorString = "Verification of text expansion removal failed:\nAcronym: " +\
                        acronym + "\nText:\n" + article_for_testing
                    common_logger.error(errorString)
                    raise RuntimeError(errorString)

            if acronym not in article_for_testing:
                errorMessage = "Acronym removed from text while cleaning:\nAcronym: " +\
                    acronym + "\nText:\n" + article_for_testing
                common_logger.error(errorMessage)
                raise RuntimeError(errorMessage)