giulio98 commited on
Commit
399f723
1 Parent(s): afabde5

Update codebleu.py

Browse files
Files changed (1) hide show
  1. codebleu.py +8 -8
codebleu.py CHANGED
@@ -15,10 +15,10 @@
15
 
16
  import evaluate
17
  import datasets
18
- from .bleu import *
19
- from .weighted_ngram_match import *
20
- from .syntax_match import *
21
- from .dataflow_match import *
22
  from tree_sitter import Language, Parser
23
 
24
 
@@ -131,7 +131,7 @@ class CodeBLEU(evaluate.Metric):
131
  tokenized_hyps = [x.split() for x in hypothesis]
132
  tokenized_refs = [[x.split() for x in reference] for reference in references]
133
 
134
- ngram_match_score = bleu.corpus_bleu(tokenized_refs,tokenized_hyps)
135
 
136
  # calculate weighted ngram match
137
  # from os import listdir
@@ -145,13 +145,13 @@ class CodeBLEU(evaluate.Metric):
145
  tokenized_refs_with_weights = [[[reference_tokens, make_weights(reference_tokens, keywords)]\
146
  for reference_tokens in reference] for reference in tokenized_refs]
147
 
148
- weighted_ngram_match_score = weighted_ngram_match.corpus_bleu(tokenized_refs_with_weights,tokenized_hyps)
149
 
150
  # calculate syntax match
151
- syntax_match_score = syntax_match.corpus_syntax_match(references, hypothesis, language)
152
 
153
  # calculate dataflow match
154
- dataflow_match_score = dataflow_match.corpus_dataflow_match(references, hypothesis, language)
155
 
156
 
157
 
 
15
 
16
  import evaluate
17
  import datasets
18
+ from .bleu import corpus_bleu
19
+ from .weighted_ngram_match import corpus_weighted_ngram_match
20
+ from .syntax_match import corpus_syntax_match
21
+ from .dataflow_match import corpus_dataflow_match
22
  from tree_sitter import Language, Parser
23
 
24
 
 
131
  tokenized_hyps = [x.split() for x in hypothesis]
132
  tokenized_refs = [[x.split() for x in reference] for reference in references]
133
 
134
+ ngram_match_score = corpus_bleu(tokenized_refs,tokenized_hyps)
135
 
136
  # calculate weighted ngram match
137
  # from os import listdir
 
145
  tokenized_refs_with_weights = [[[reference_tokens, make_weights(reference_tokens, keywords)]\
146
  for reference_tokens in reference] for reference in tokenized_refs]
147
 
148
+ weighted_ngram_match_score = corpus_weighted_ngram_match(tokenized_refs_with_weights,tokenized_hyps)
149
 
150
  # calculate syntax match
151
+ syntax_match_score = corpus_syntax_match(references, hypothesis, language)
152
 
153
  # calculate dataflow match
154
+ dataflow_match_score = corpus_dataflow_match(references, hypothesis, language)
155
 
156
 
157