Skip to content

Instantly share code, notes, and snippets.

@khuyentran1401
Last active January 15, 2023 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khuyentran1401/7dda7f7ccc21c2e005190467a5ce4e6b to your computer and use it in GitHub Desktop.
Save khuyentran1401/7dda7f7ccc21c2e005190467a5ce4e6b to your computer and use it in GitHub Desktop.
from snorkel.labeling import labeling_function
# Give a meaningful name to each value
FAKE = 1
REAL = 0
ABSTAIN = -1
@labeling_function()
def no_requirements(x: pd.Series):
return FAKE if x.requirements == "" else ABSTAIN
@labeling_function()
def requirements_less_than_10(x: pd.Series):
num_words = len(x.requirements.split(" "))
return FAKE if num_words <= 10 else ABSTAIN
@labeling_function()
def requirements_less_than_20(x: pd.Series):
num_words = len(x.requirements.split(" "))
return FAKE if num_words <= 20 else ABSTAIN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment