Skip to content

Commit

Permalink
Merge pull request #13 from Anchaliya75/ISSUE-1076
Browse files Browse the repository at this point in the history
-adds dynamic metadata based filtering
  • Loading branch information
JosephCatrambone authored Oct 17, 2024
2 parents 775056b + c00cc7c commit e60e49a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions validator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ def validate(
Args:
value (str): The given string to classify
metadata (Optional[Dict[str, Any]], optional): _description_. Defaults to {}.
metadata (Optional[Dict[str, Any]], optional): Dictionary containing valid and invalid topics. Defaults to {}.
Raises:
ValueError: If a topic is invalid and valid
Expand All @@ -291,9 +292,9 @@ def validate(
ValidationResult: PassResult if a topic is restricted and valid,
FailResult otherwise
"""
valid_topics = set(self._valid_topics)
invalid_topics = set(self._invalid_topics)
all_topics = list(set(valid_topics) | set(invalid_topics))
valid_topics = set(metadata.get('valid_topics', self._valid_topics))
invalid_topics = set(metadata.get('invalid_topics', self._invalid_topics))
all_topics = list(valid_topics | invalid_topics)

# throw if valid and invalid topics are empty
if not valid_topics:
Expand All @@ -308,8 +309,8 @@ def validate(

model_input = {
"text": value,
"valid_topics": self._valid_topics,
"invalid_topics": self._invalid_topics
"valid_topics": valid_topics,
"invalid_topics": invalid_topics
}

# Ensemble method
Expand Down

0 comments on commit e60e49a

Please sign in to comment.