Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

AcceptabilityChecker min words adjustable #3846

Merged
merged 3 commits into from
Jul 23, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions parlai/crowdsourcing/utils/acceptability.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from parlai.utils.safety import OffensiveStringMatcher


DEFAULT_MIN_WORDS_THRESHOLD = 3


class AcceptabilityChecker:

ALL_VIOLATION_TYPES = [
Expand All @@ -20,8 +23,9 @@ class AcceptabilityChecker:
'safety',
]

def __init__(self):
def __init__(self, min_words=DEFAULT_MIN_WORDS_THRESHOLD):
self.offensive_lang_detector = OffensiveStringMatcher()
self.min_words_violation_threshold = min_words

def check_messages(
self,
Expand Down Expand Up @@ -57,7 +61,7 @@ def check_messages(
# Do messages have the minimum acceptable average number of words?
if 'min_words' in violation_types:
total_num_words = sum([len(message.split()) for message in messages])
if total_num_words / len(messages) < 3:
if total_num_words / len(messages) < self.min_words_violation_threshold:
violations.append('under_min_length')

# Does the first message start with a greeting, indicating that the Turker
Expand Down