Commit f2b52d26 authored by lintangsutawika's avatar lintangsutawika
Browse files

doc_to_target should also be able to output str instead of solely int

parent e454df7f
...@@ -42,7 +42,10 @@ class Sampler: ...@@ -42,7 +42,10 @@ class Sampler:
+ self.target_delimiter + self.target_delimiter
+ ( + (
self.doc_to_target(doc) self.doc_to_target(doc)
if self.config.doc_to_choice is None if (
self.config.doc_to_choice is None
or type(self.doc_to_target(doc)) is str
)
else self.doc_to_choice(doc)[self.doc_to_target(doc)] else self.doc_to_choice(doc)[self.doc_to_target(doc)]
) )
for doc in selected_docs for doc in selected_docs
......
...@@ -946,6 +946,8 @@ class ConfigurableTask(Task): ...@@ -946,6 +946,8 @@ class ConfigurableTask(Task):
gold = self.doc_to_text(doc) gold = self.doc_to_text(doc)
else: else:
gold = self.doc_to_target(doc) gold = self.doc_to_target(doc)
if type(gold) is str:
gold = choices.index(gold)
if self.multiple_target: if self.multiple_target:
acc = 1.0 if pred in gold else 0.0 acc = 1.0 if pred in gold else 0.0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment