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

Commit

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

* min words as input param

* pr comment
mojtaba-komeili authored Jul 23, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
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
@@ -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,
@@ -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

0 comments on commit 53cfdc6

Please sign in to comment.