Giter Club home page Giter Club logo

py_rouge_zh's Introduction

Py-rouge

A full Python implementation of the ROUGE metric, especially for Chinese texts processing. Mainly based on https://github.com/Diego999/py-rouge 中文文本Rouge值相关计算的python实现

欢迎Star 😁

Important remarks

  • Diego的实现主要适用于英文文本,主要调整的地方是其代码内的正则表达式部分以及针对英文处理的部分(如 .lower()等)
  • 输入分词后或按字隔开的中文文本
  • 注意输入输出的形式(hypothesis: hypothesis summary, string; references: reference summary/ies, either string or list of strings (if multiple))

Installation

git clone https://github.com/JialeGuo/py_rouge_zh
cd py-rouge-zh
python setup.py install

Example

import rouge_zh

evaluator = rouge_zh.Rouge(metrics=['rouge-n'],
                           max_n=4,
                           limit_length=True,
                           length_limit=100,
                           length_limit_type='words',
                           alpha=0.5, # Default F1_score
                           weight_factor=1.2,
                           stemming=True)

all_hypothesis = ["哈 尔 滨 是 黑 龙 江 的 省 会"]
all_references = [["哈 工 大 在 哈 尔 滨", "黑 龙 江 太 冷 了"]]

scores = evaluator.get_scores(all_hypothesis, all_references)
print(scores)

It produces the following output:

{'rouge-2': {'r': 0.1, 'p': 0.1, 'f': 0.10000000000000002}, 'rouge-3': {'r': 0.0, 'p': 0.0, 'f': 0.0}, 'rouge-4': {'r': 0.0, 'p': 0.0, 'f': 0.0}, 'rouge-1': {'r': 0.5, 'p': 0.5, 'f': 0.5}}

py_rouge_zh's People

Contributors

jialeguo avatar

Stargazers

shen chen avatar zhongtianHU avatar  avatar  avatar Yahiko avatar  avatar  avatar X1a0t avatar 科奇 avatar  avatar David Lee avatar Xueyao Zhang avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

py_rouge_zh's Issues

你好,我想應用您的代碼,請問怎樣修改

我有一段能只能評測英文的ROUGE,使用如下:

r = Rouge155()
r.system_dir = 'path/to/system_summaries'
r.model_dir = 'path/to/model_summaries'
r.system_filename_pattern = '(\d+)_decode.txt'
r.model_filename_pattern = '[A-Z].#ID#_reference.txt'
output = r.convert_and_evaluate()

我看了你的代碼,在傳入摘要和參考時和原代碼不同,請問怎樣能把您的代碼用在原來的ROUGE代碼裏?謝謝!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.