Skip to content

Commit

Permalink
AcceptabilityChecker min words adjustable (facebookresearch#3846)
Browse files Browse the repository at this point in the history
* min words as a param

* min words as input param

* pr comment
  • Loading branch information
mojtaba-komeili authored Jul 23, 2021
1 parent 70969fc commit 53cfdc6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions parlai/crowdsourcing/utils/acceptability.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ class AcceptabilityChecker:
'exact_match',
'safety',
]
DEFAULT_MIN_WORDS_THRESHOLD = 3

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

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

0 comments on commit 53cfdc6

Please sign in to comment.