本文整理汇总了Python中cider_scorer.CiderScorer方法的典型用法代码示例。如果您正苦于以下问题:Python cider_scorer.CiderScorer方法的具体用法?Python cider_scorer.CiderScorer怎么用?Python cider_scorer.CiderScorer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cider_scorer
的用法示例。
在下文中一共展示了cider_scorer.CiderScorer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import cider_scorer [as 别名]
# 或者: from cider_scorer import CiderScorer [as 别名]
def __init__(self, n=4, df="corpus"):
"""
Initialize the CIDEr scoring function
: param n (int): n-gram size
: param df (string): specifies where to get the IDF values from
takes values 'corpus', 'coco-train'
: return: None
"""
# set cider to sum over 1 to 4-grams
self._n = n
self._df = df
self.cider_scorer = CiderScorer(n=self._n, df_mode=self._df)
示例2: compute_score
# 需要导入模块: import cider_scorer [as 别名]
# 或者: from cider_scorer import CiderScorer [as 别名]
def compute_score(self, gts, res):
"""
Main function to compute CIDEr score
:param hypo_for_image (dict) : dictionary with key <image> and value <tokenized hypothesis / candidate sentence>
ref_for_image (dict) : dictionary with key <image> and value <tokenized reference sentence>
:return: cider (float) : computed CIDEr score for the corpus
"""
assert(gts.keys() == res.keys())
imgIds = gts.keys()
cider_scorer = CiderScorer(n=self._n, sigma=self._sigma)
for id in imgIds:
hypo = res[id]
ref = gts[id]
# Sanity check.
assert(type(hypo) is list)
assert(len(hypo) == 1)
assert(type(ref) is list)
assert(len(ref) > 0)
cider_scorer += (hypo[0], ref)
(score, scores) = cider_scorer.compute_score()
return score, scores
示例3: compute_score
# 需要导入模块: import cider_scorer [as 别名]
# 或者: from cider_scorer import CiderScorer [as 别名]
def compute_score(self, gts, res):
"""
Main function to compute CIDEr score
:param hypo_for_image (dict) : dictionary with key <image> and value <tokenized hypothesis / candidate sentence>
ref_for_image (dict) : dictionary with key <image> and value <tokenized reference sentence>
:return: cider (float) : computed CIDEr score for the corpus
"""
assert(set(gts.keys()) == set(res.keys()))
imgIds = gts.keys()
cider_scorer = CiderScorer(n=self._n, sigma=self._sigma)
for id in imgIds:
hypo = res[id]
ref = gts[id]
# Sanity check.
assert(type(hypo) is list)
assert(len(hypo) == 1)
assert(type(ref) is list)
assert(len(ref) > 0)
cider_scorer += (hypo[0], ref)
(score, scores) = cider_scorer.compute_score()
return score, scores
示例4: compute_score
# 需要导入模块: import cider_scorer [as 别名]
# 或者: from cider_scorer import CiderScorer [as 别名]
def compute_score(self, gts, res):
"""
Main function to compute CIDEr score
:param hypo_for_image (dict) : dictionary with key <image> and value <tokenized hypothesis / candidate sentence>
ref_for_image (dict) : dictionary with key <image> and value <tokenized reference sentence>
:return: cider (float) : computed CIDEr score for the corpus
"""
# assert(gts.keys() == res.keys())
assert(sorted(gts.keys()) == sorted(res.keys()))
imgIds = gts.keys()
cider_scorer = CiderScorer(df=self.df, n=self._n, sigma=self._sigma)
for id in imgIds:
hypo = res[id]
ref = gts[id]
# Sanity check.
assert(type(hypo) is list)
assert(len(hypo) == 1)
assert(type(ref) is list)
assert(len(ref) > 0)
cider_scorer += (hypo[0], ref)
(score, scores) = cider_scorer.compute_score()
return score, scores
示例5: compute_score
# 需要导入模块: import cider_scorer [as 别名]
# 或者: from cider_scorer import CiderScorer [as 别名]
def compute_score(self, gts, res):
"""
Main function to compute CIDEr score
:param hypo_for_image (dict) : dictionary with img_id <image> and value <tokenized hypothesis / candidate sentence>
ref_for_image (dict) : dictionary with img_id <image> and value <tokenized reference sentence>
:return: cider (float) : computed CIDEr score for the corpus
"""
assert (gts.keys() == res.keys())
imgIds = gts.keys()
cider_scorer = CiderScorer(n=self._n, sigma=self._sigma)
for id in imgIds:
hypo = res[id]
ref = gts[id]
# Sanity check.
assert (type(hypo) is list)
assert (len(hypo) == 1)
assert (type(ref) is list)
assert (len(ref) > 0)
cider_scorer += (hypo[0], ref)
(score, scores) = cider_scorer.compute_score()
return score, scores
示例6: compute_score
# 需要导入模块: import cider_scorer [as 别名]
# 或者: from cider_scorer import CiderScorer [as 别名]
def compute_score(self, gts, res):
"""
Main function to compute CIDEr score
:param hypo_for_image (dict) : dictionary with key <image> and value <tokenized hypothesis / candidate sentence>
ref_for_image (dict) : dictionary with key <image> and value <tokenized reference sentence>
:return: cider (float) : computed CIDEr score for the corpus
"""
#assert(gts.keys() == res.keys())
assert(set(gts.keys()) == set(res.keys()))
imgIds = gts.keys()
cider_scorer = CiderScorer(n=self._n, sigma=self._sigma)
for id in imgIds:
hypo = res[id]
ref = gts[id]
# Sanity check.
assert(type(hypo) is list)
assert(len(hypo) == 1)
assert(type(ref) is list)
assert(len(ref) > 0)
cider_scorer += (hypo[0], ref)
(score, scores) = cider_scorer.compute_score()
return score, scores
示例7: compute_score
# 需要导入模块: import cider_scorer [as 别名]
# 或者: from cider_scorer import CiderScorer [as 别名]
def compute_score(self, gts, res):
"""
Main function to compute CIDEr score
:param hypo_for_image (dict) : dictionary with key <image> and value <tokenized hypothesis / candidate sentence>
ref_for_image (dict) : dictionary with key <image> and value <tokenized reference sentence>
:return: cider (float) : computed CIDEr score for the corpus
"""
assert(sorted(gts.keys()) == sorted(res.keys()))
imgIds = gts.keys()
cider_scorer = CiderScorer(n=self._n, sigma=self._sigma)
for id in imgIds:
hypo = res[id]
ref = gts[id]
# Sanity check.
assert(type(hypo) is list)
assert(len(hypo) == 1)
assert(type(ref) is list)
assert(len(ref) > 0)
cider_scorer += (hypo[0], ref)
(score, scores) = cider_scorer.compute_score()
return score, scores