I have a class with two multi methods (multi submit
).
I call my multi like this:
$perspective.submit(:message($message.content));
Which gets shipped off to my class:
my $perspective-api = API::Perspective.new(:api-key(%*ENV<PERSPECTIVE_API_KEY>));
proto method submit (|) {*}
multi method submit(Str :$message!, MODEL :@models = TOXICITY) {
my $score = $perspective-api.analyze(:@models, :comment($message));
say @models Z=> $score<attributeScores>{@models}.map: *<summaryScore><value>;
multi method submit(Str :$name!, MODEL :@models = TOXICITY) {
my $score = $perspective-api.analyze(:@models, :comment($name));
say @models Z=> $score<attributeScores>{@models}.map: *<summaryScore><value>;
}
However I always get the following response:
Died because of the exception:
Cannot resolve caller AUTOGEN(Rose::ContentAnalysis::Perspective:D: :message(Str)); none of these signatures match:
(Rose::ContentAnalysis::Perspective: Str :$message!, MODEL :@models = MODEL::TOXICITY, *%_)
(Rose::ContentAnalysis::Perspective: Str :$name!, MODEL :@models = MODEL::TOXICITY, *%_)
Despite my named argument (:message
) being a Str
as required and @models
having a default declared.
TOXICITY
? I'm wondering if your default value is impossible to assign. – TyishatykeAPI::Perspective
module here, if that is what you are looking for. github.com/shuppet/p6-api-perspective/blob/master/lib/API/… – Rhythm