Skip to content

Conversation

@moslemmj
Copy link
Collaborator

dear @HamedBabaei please check this merge request,sorry for delay.

from nltk.translate.bleu_score import sentence_bleu


def evaluation(translations, references):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just use, gold and prediction here instead of translations and references variables?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

translations refers to translated sentence and references refers to source sentences,can you more explain about gold and prediction?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so based on your message, prediction is translations and gold is references (for gold naming you can use truth) too

print('Individual 4-gram: %f' % sentence_bleu(refer_token, trans_token, weights=(0, 0, 0, 1)))


# reference = [['i love cats'], ['i love hats']]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can put this sample input and outputs inside of the evaluator function!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# reference = [['i love cats'], ['i love hats']] ..... which you are using, please put them inside of the evaluator function docstring.

from nltk.translate.bleu_score import sentence_bleu


def evaluation(translations, references):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the name of this evaluation, you can use its name here, for example, bleu_evaluation not only simple evaluation naming

Returns:
nothings for now, just print BLEU scores
"""
print('translations=[%s], references=%s' % (translations, references))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please put a verbose variable to whatever to do a print or not! printing all of those lists could be tricky
for example

def evaluation(...,..., verbose=False):
   if verbose:
         print("..............")
   ...
   ...

for sen in references:
refer_token.append(sen[0].split())

print('Individual 1-gram: %f' % sentence_bleu(refer_token, trans_token, weights=(1, 0, 0, 0)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Individual 1-gram what score??? is this BLEU so put its in print function!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 print('BLEU, Individual 1-gram: %f' % sentence_bleu(refer_token, trans_token, weights=(1, 0, 0, 0)))

from preprocessing import create_dataset
from sklearn.model_selection import train_test_split

path_to_file = '/media/moslem/Private/Project/MTP/Machine-Translation/dataset/manythings/pes.txt'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it a valid path to file in this repository? and is it required to pass here?

convert(targ_lang_tokenizer, target_tensor_train[0])


main_proccess()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line

@HamedBabaei
Copy link
Contributor

put documentation into all of your methods too! I saw a few of them don't have it!

@moslemmj moslemmj closed this Nov 26, 2020
@moslemmj moslemmj reopened this Nov 26, 2020
candidate = 'i love cat'
bleu_evaluation(candidate, truth)
"""
print('translations=[%s], references=%s' % (prediction, truth))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should add verbose to this print, not to the other ones, since the amount of prediction and truth variables could be more than just one sentence it can be annoying to print all of them

for sen in prediction:
truth_token.append(sen[0].split())

if verbose:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need verbose for this prints

@moslemmj moslemmj closed this Dec 1, 2020
@moslemmj moslemmj reopened this Dec 1, 2020
@moslemmj
Copy link
Collaborator Author

moslemmj commented Dec 1, 2020

dear @HamedBabaei i read your comments and push the new version, Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants