#NEWLINE# def corpus_ribes( list_of_references , hypotheses , alpha = 0.25 , beta = 0.1 ) : #NEWLINE# #INDENT# '\n    This function "calculates RIBES for a system output (hypothesis) with \n    multiple references, and returns "best" score among multi-references and \n    individual scores. The scores are corpus-wise, i.e., averaged by the number \n    of sentences." (c.f. RIBES version 1.03.1 code).\n    \n    Different from BLEU\'s micro-average precision, RIBES calculates the \n    macro-average precision by averaging the best RIBES score for each pair of \n    hypothesis and its corresponding references \n\n    >>> hyp1 = [\'It\', \'is\', \'a\', \'guide\', \'to\', \'action\', \'which\',\n    ...         \'ensures\', \'that\', \'the\', \'military\', \'always\',\n    ...         \'obeys\', \'the\', \'commands\', \'of\', \'the\', \'party\']\n    >>> ref1a = [\'It\', \'is\', \'a\', \'guide\', \'to\', \'action\', \'that\',\n    ...          \'ensures\', \'that\', \'the\', \'military\', \'will\', \'forever\',\n    ...          \'heed\', \'Party\', \'commands\']\n    >>> ref1b = [\'It\', \'is\', \'the\', \'guiding\', \'principle\', \'which\',\n    ...          \'guarantees\', \'the\', \'military\', \'forces\', \'always\',\n    ...          \'being\', \'under\', \'the\', \'command\', \'of\', \'the\', \'Party\']\n    >>> ref1c = [\'It\', \'is\', \'the\', \'practical\', \'guide\', \'for\', \'the\',\n    ...          \'army\', \'always\', \'to\', \'heed\', \'the\', \'directions\',\n    ...          \'of\', \'the\', \'party\']\n    \n    >>> hyp2 = [\'he\', \'read\', \'the\', \'book\', \'because\', \'he\', \'was\', \n    ...         \'interested\', \'in\', \'world\', \'history\']\n    >>> ref2a = [\'he\', \'was\', \'interested\', \'in\', \'world\', \'history\', \n    ...          \'because\', \'he\', \'read\', \'the\', \'book\']\n    \n    >>> list_of_references = [[ref1a, ref1b, ref1c], [ref2a]]\n    >>> hypotheses = [hyp1, hyp2]\n    >>> round(corpus_ribes(list_of_references, hypotheses),4)\n    0.3597\n    \n    :param references: a corpus of lists of reference sentences, w.r.t. hypotheses\n    :type references: list(list(list(str)))\n    :param hypotheses: a list of hypothesis sentences\n    :type hypotheses: list(list(str))\n    :param alpha: hyperparameter used as a prior for the unigram precision.\n    :type alpha: float\n    :param beta: hyperparameter used as a prior for the brevity penalty.\n    :type beta: float\n    :return: The best ribes score from one of the references.\n    :rtype: float\n    ' #NEWLINE# corpus_best_ribes = 0.0 #NEWLINE# for ( references , hypothesis ) in zip ( list_of_references , hypotheses ) : #NEWLINE# #INDENT# corpus_best_ribes += sentence_ribes ( references , hypothesis , alpha , beta ) #NEWLINE# #UNINDENT# return ( corpus_best_ribes / len ( hypotheses ) )