giulio98 commited on
Commit
adca7d2
1 Parent(s): c615e1f

Update codebleu.py

Browse files
Files changed (1) hide show
  1. codebleu.py +3 -1
codebleu.py CHANGED
@@ -20,6 +20,7 @@ from .weighted_ngram_match import *
20
  from .syntax_match import *
21
  from .dataflow_match import *
22
  from tree_sitter import Language, Parser
 
23
 
24
 
25
  # TODO: Add BibTeX citation
@@ -138,7 +139,8 @@ class CodeBLEU(evaluate.Metric):
138
  # from os.path import isfile, join
139
  # onlyfiles = [f for f in listdir("./keywords") if isfile(join("keywords", f))]
140
  # print(onlyfiles)
141
- keywords = [x.strip() for x in open('./keywords/'+ language +'.txt', 'r', encoding='utf-8').readlines()]
 
142
  def make_weights(reference_tokens, key_word_list):
143
  return {token:1 if token in key_word_list else 0.2 \
144
  for token in reference_tokens}
 
20
  from .syntax_match import *
21
  from .dataflow_match import *
22
  from tree_sitter import Language, Parser
23
+ import os
24
 
25
 
26
  # TODO: Add BibTeX citation
 
139
  # from os.path import isfile, join
140
  # onlyfiles = [f for f in listdir("./keywords") if isfile(join("keywords", f))]
141
  # print(onlyfiles)
142
+ curr_path = os.path.dirname(os.path.abspath(__file__))
143
+ keywords = [x.strip() for x in open(curr_path + language +'.txt', 'r', encoding='utf-8').readlines()]
144
  def make_weights(reference_tokens, key_word_list):
145
  return {token:1 if token in key_word_list else 0.2 \
146
  for token in reference_tokens}