def _download_and_prepare(self, dl_manager): import nltk nltk.download("wordnet") if NLTK_VERSION >= version.Version("3.6.5"): nltk.download("punkt") if NLTK_VERSION >= version.Version("3.6.6"): nltk.download("omw-1.4")
def _compute(self, predictions, references, alpha=0.9, beta=3, gamma=0.5): if NLTK_VERSION >= version.Version("3.6.5"): scores = [ meteor_score.single_meteor_score(word_tokenize(ref), word_tokenize(pred), alpha=alpha, beta=beta, gamma=gamma) for ref, pred in zip(references, predictions) ] else: scores = [ meteor_score.single_meteor_score(ref, pred, alpha=alpha, beta=beta, gamma=gamma) for ref, pred in zip(references, predictions) ] return {"meteor": np.mean(scores)}
# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ METEOR metric. """ import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version NLTK_VERSION = version.parse(importlib_metadata.version("nltk")) if NLTK_VERSION >= version.Version("3.6.4"): from nltk import word_tokenize _CITATION = """\ @inproceedings{banarjee2005, title = {{METEOR}: An Automatic Metric for {MT} Evaluation with Improved Correlation with Human Judgments}, author = {Banerjee, Satanjeev and Lavie, Alon}, booktitle = {Proceedings of the {ACL} Workshop on Intrinsic and Extrinsic Evaluation Measures for Machine Translation and/or Summarization}, month = jun, year = {2005}, address = {Ann Arbor, Michigan}, publisher = {Association for Computational Linguistics}, url = {https://www.aclweb.org/anthology/W05-0909}, pages = {65--72}, } """