bleuEvaluationScore Argument 1 must be a tokenizedDocument scalar.
57 views (last 30 days)
Show older comments
Hi
I am trying to use the bleuEvaluationScore example and it works ok wit the simple.
When I try to use my own text I get an error with "Argument 1 must be a tokenizedDocument scalar."
Any idea as why I get such error ? I use version 2023b under Win11
Brahim
0 Comments
Answers (3)
Sahas
on 5 Sep 2024 at 14:05
Edited: Sahas
on 5 Sep 2024 at 14:50
Hi,
As per my understanding, you are calculating the BLEU Score with the “bleuEvaluationScore” function. The example provided in the MathWorks documentation page runs smoothly but gives an error when you are using custom text.
The error “Argument 1 must be a tokenizedDocument scalar” refers to incorrect data type of the “candidate” input argument while calculating the BLEU Score. Make sure that the data type of “tokenizedDocument” is correct. Refrain from using the "strsplit" function as it results in incompatible data types.
The documentation of “bleuEvaluationScore” function states that, “If candidate is not a tokenizedDocument scalar, then it must be a row vector representing a single document, where each element is a word.”
Refer to the following MathWorks documentation link for more information: https://www.mathworks.com/help/textanalytics/ref/bleuevaluationscore.html
Here is the sample code snippet I used to reproduce the error:
% Example text
referenceText = "The quick brown fox jumps over the lazy dog.";
candidateText = "The fast brown fox leaps over the lazy dog.";
%If you use "strsplit", it will give the same error
%See the datatype in MATLAB's Workspace
% referenceText = strsplit(referenceText)
% candidateText = strsplit(candidateText)
referenceDoc = tokenizedDocument(referenceText)
candidateDoc = tokenizedDocument(candidateText)
% Calculate BLEU score
score = bleuEvaluationScore(candidateDoc, referenceDoc);
% Display the BLEU score
disp(score);
Hope this is beneficial!
0 Comments
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!