当前位置: 首页>>代码示例>>Python>>正文


Python log.get_global_console_logger方法代码示例

本文整理汇总了Python中pyrouge.utils.log.get_global_console_logger方法的典型用法代码示例。如果您正苦于以下问题:Python log.get_global_console_logger方法的具体用法?Python log.get_global_console_logger怎么用?Python log.get_global_console_logger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyrouge.utils.log的用法示例。


在下文中一共展示了log.get_global_console_logger方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process

# 需要导入模块: from pyrouge.utils import log [as 别名]
# 或者: from pyrouge.utils.log import get_global_console_logger [as 别名]
def process(input_dir, output_dir, function):
        """
        Apply function to all files in input_dir and save the resulting ouput
        files in output_dir.

        """
        if not os.path.exists(output_dir):
            os.makedirs(output_dir)
        logger = log.get_global_console_logger()
        logger.info("Processing files in {}.".format(input_dir))
        input_file_names = os.listdir(input_dir)
        for input_file_name in input_file_names:
            input_file = os.path.join(input_dir, input_file_name)
            with codecs.open(input_file, "r", encoding="UTF-8") as f:
                input_string = f.read()
            output_string = function(input_string)
            output_file = os.path.join(output_dir, input_file_name)
            with codecs.open(output_file, "w", encoding="UTF-8") as f:
                f.write(clean(output_string.lower()))
        logger.info("Saved processed files to {}.".format(output_dir)) 
开发者ID:microsoft,项目名称:unilm,代码行数:22,代码来源:bs_pyrouge.py

示例2: __init__

# 需要导入模块: from pyrouge.utils import log [as 别名]
# 或者: from pyrouge.utils.log import get_global_console_logger [as 别名]
def __init__(self, rouge_dir=None, rouge_args=None, temp_dir=None):
        """
        Create a Rouge155 object.

            rouge_dir:  Directory containing Rouge-1.5.5.pl
            rouge_args: Arguments to pass through to ROUGE if you
                        don't want to use the default pyrouge
                        arguments.

        """
        self.temp_dir = temp_dir
        self.log = log.get_global_console_logger()
        self.__set_dir_properties()
        self._config_file = None
        self._settings_file = self.__get_config_path()
        self.__set_rouge_dir(rouge_dir)
        self.args = self.__clean_rouge_args(rouge_args)
        self._system_filename_pattern = None
        self._model_filename_pattern = None 
开发者ID:microsoft,项目名称:unilm,代码行数:21,代码来源:bs_pyrouge.py

示例3: __init__

# 需要导入模块: from pyrouge.utils import log [as 别名]
# 或者: from pyrouge.utils.log import get_global_console_logger [as 别名]
def __init__(self, rouge_dir=None, rouge_args=None, temp_dir = None):
        """
        Create a Rouge155 object.

            rouge_dir:  Directory containing Rouge-1.5.5.pl
            rouge_args: Arguments to pass through to ROUGE if you
                        don't want to use the default pyrouge
                        arguments.

        """
        self.temp_dir=temp_dir
        self.log = log.get_global_console_logger()
        self.__set_dir_properties()
        self._config_file = None
        self._settings_file = self.__get_config_path()
        self.__set_rouge_dir(rouge_dir)
        self.args = self.__clean_rouge_args(rouge_args)
        self._system_filename_pattern = None
        self._model_filename_pattern = None 
开发者ID:nlpyang,项目名称:PreSumm,代码行数:21,代码来源:pyrouge.py

示例4: eval_rouge

# 需要导入模块: from pyrouge.utils import log [as 别名]
# 或者: from pyrouge.utils.log import get_global_console_logger [as 别名]
def eval_rouge(dec_pattern, dec_dir, ref_pattern, ref_dir,
               cmd='-c 95 -r 1000 -n 2 -m', system_id=1):
    """ evaluate by original Perl implementation"""
    # silence pyrouge logging
    assert _ROUGE_PATH is not None
    log.get_global_console_logger().setLevel(logging.WARNING)
    with tempfile.TemporaryDirectory() as tmp_dir:
        Rouge155.convert_summaries_to_rouge_format(
            dec_dir, join(tmp_dir, 'dec'))
        Rouge155.convert_summaries_to_rouge_format(
            ref_dir, join(tmp_dir, 'ref'))
        Rouge155.write_config_static(
            join(tmp_dir, 'dec'), dec_pattern,
            join(tmp_dir, 'ref'), ref_pattern,
            join(tmp_dir, 'settings.xml'), system_id
        )
        cmd = (join(_ROUGE_PATH, 'ROUGE-1.5.5.pl')
               + ' -e {} '.format(join(_ROUGE_PATH, 'data'))
               + cmd
               + ' -a {}'.format(join(tmp_dir, 'settings.xml')))
        output = sp.check_output(cmd.split(' '), universal_newlines=True)
    return output 
开发者ID:ChenRocks,项目名称:fast_abs_rl,代码行数:24,代码来源:evaluate.py

示例5: process

# 需要导入模块: from pyrouge.utils import log [as 别名]
# 或者: from pyrouge.utils.log import get_global_console_logger [as 别名]
def process(input_dir, output_dir, function):
        """
        Apply function to all files in input_dir and save the resulting ouput
        files in output_dir.

        """
        if not os.path.exists(output_dir):
            os.makedirs(output_dir)
        logger = log.get_global_console_logger()
        logger.info("Processing files in {}.".format(input_dir))
        input_file_names = os.listdir(input_dir)
        for input_file_name in input_file_names:
            input_file = os.path.join(input_dir, input_file_name)
            with codecs.open(input_file, "r", encoding="UTF-8") as f:
                input_string = f.read()
            output_string = function(input_string)
            output_file = os.path.join(output_dir, input_file_name)
            with codecs.open(output_file, "w", encoding="UTF-8") as f:
                f.write(output_string.lower())
        logger.info("Saved processed files to {}.".format(output_dir)) 
开发者ID:nlpyang,项目名称:hiersumm,代码行数:22,代码来源:my_pyrouge.py

示例6: __init__

# 需要导入模块: from pyrouge.utils import log [as 别名]
# 或者: from pyrouge.utils.log import get_global_console_logger [as 别名]
def __init__(self, rouge_dir=None, rouge_args=None):
        """
        Create a Rouge155 object.

            rouge_dir:  Directory containing Rouge-1.5.5.pl
            rouge_args: Arguments to pass through to ROUGE if you
                        don't want to use the default pyrouge
                        arguments.

        """
        self.log = log.get_global_console_logger()
        self.__set_dir_properties()
        self._config_file = None
        self._settings_file = self.__get_config_path()
        self.__set_rouge_dir(rouge_dir)
        self.args = self.__clean_rouge_args(rouge_args)
        self._system_filename_pattern = None
        self._model_filename_pattern = None 
开发者ID:nlpyang,项目名称:hiersumm,代码行数:20,代码来源:my_pyrouge.py

示例7: process

# 需要导入模块: from pyrouge.utils import log [as 别名]
# 或者: from pyrouge.utils.log import get_global_console_logger [as 别名]
def process(input_dir, output_dir, function):
        """
        Apply function to all files in input_dir and save the resulting ouput
        files in output_dir.

        """
        if not os.path.exists(output_dir):
            os.makedirs(output_dir)
        logger = log.get_global_console_logger()
        logger.info("Processing files in {}.".format(input_dir))
        input_file_names = os.listdir(input_dir)
        for input_file_name in input_file_names:
            logger.info("Processing {}.".format(input_file_name))
            input_file = os.path.join(input_dir, input_file_name)
            with codecs.open(input_file, "r", encoding="UTF-8") as f:
                input_string = f.read()
            output_string = function(input_string)
            output_file = os.path.join(output_dir, input_file_name)
            with codecs.open(output_file, "w", encoding="UTF-8") as f:
                f.write(output_string)
        logger.info("Saved processed files to {}.".format(output_dir)) 
开发者ID:bheinzerling,项目名称:pyrouge,代码行数:23,代码来源:file_utils.py

示例8: __init__

# 需要导入模块: from pyrouge.utils import log [as 别名]
# 或者: from pyrouge.utils.log import get_global_console_logger [as 别名]
def __init__(self, language="en", punkt_data_path=None):
        self.lang2datapath = {"en": "tokenizers/punkt/english.pickle"}
        self.log = log.get_global_console_logger()
        try:
            import nltk.data
        except ImportError:
            self.log.error(
                "Cannot import NLTK data for the sentence splitter. Please "
                "check if the 'punkt' NLTK-package is installed correctly.")
        try:
            if not punkt_data_path:
                punkt_data_path = self.lang2datapath[language]
            self.sent_detector = nltk.data.load(punkt_data_path)
        except KeyError:
            self.log.error(
                "No sentence splitter data for language {}.".format(language))
        except:
            self.log.error(
                "Could not load sentence splitter data: {}".format(
                    self.lang2datapath[language])) 
开发者ID:bheinzerling,项目名称:pyrouge,代码行数:22,代码来源:sentence_splitter.py

示例9: __init__

# 需要导入模块: from pyrouge.utils import log [as 别名]
# 或者: from pyrouge.utils.log import get_global_console_logger [as 别名]
def __init__(self, rouge_dir=None, rouge_args=None, log_level=None):
        """
        Create a Rouge155 object.

            rouge_dir:  Directory containing Rouge-1.5.5.pl
            rouge_args: Arguments to pass through to ROUGE if you
                        don't want to use the default pyrouge
                        arguments.

        """
        if log_level is None:
                self.log = log.get_global_console_logger()
        else:
                self.log = log.get_global_console_logger(log_level)		
        self.__set_dir_properties()
        self._config_file = None
        self._settings_file = self.__get_config_path()
        self.__set_rouge_dir(rouge_dir)
        self.args = self.__clean_rouge_args(rouge_args)
        self._system_filename_pattern = None
        self._model_filename_pattern = None 
开发者ID:bheinzerling,项目名称:pyrouge,代码行数:23,代码来源:Rouge155.py

示例10: eval_rouge

# 需要导入模块: from pyrouge.utils import log [as 别名]
# 或者: from pyrouge.utils.log import get_global_console_logger [as 别名]
def eval_rouge(dec_dir, ref_dir):
        assert _ROUGE_PATH is not None
        log.get_global_console_logger().setLevel(logging.WARNING)
        dec_pattern = '(\d+).dec'
        ref_pattern = '#ID#.ref'
        cmd = '-c 95 -r 1000 -n 2 -m'
        with tempfile.TemporaryDirectory() as tmp_dir:
            Rouge155.convert_summaries_to_rouge_format(
                dec_dir, join(tmp_dir, 'dec'))
            Rouge155.convert_summaries_to_rouge_format(
                ref_dir, join(tmp_dir, 'ref'))
            Rouge155.write_config_static(
                join(tmp_dir, 'dec'), dec_pattern,
                join(tmp_dir, 'ref'), ref_pattern,
                join(tmp_dir, 'settings.xml'), system_id=1
            )
            cmd = (join(_ROUGE_PATH, 'ROUGE-1.5.5.pl')
                + ' -e {} '.format(join(_ROUGE_PATH, 'data'))
                + cmd
                + ' -a {}'.format(join(tmp_dir, 'settings.xml')))
            output = sp.check_output(cmd.split(' '), universal_newlines=True)
            R_1 = float(output.split('\n')[3].split(' ')[3])
            R_2 = float(output.split('\n')[7].split(' ')[3])
            R_L = float(output.split('\n')[11].split(' ')[3])
            print(output)
        return R_1, R_2, R_L 
开发者ID:fastnlp,项目名称:fastNLP,代码行数:28,代码来源:metrics.py


注:本文中的pyrouge.utils.log.get_global_console_logger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。