Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@labeling_function(pre=[square])
def fp(x: DataPoint) -> int:
return 0 if x.num_squared > 42 else -1
@labeling_function()
def f_np(x: DataPoint) -> int:
return 0 if x[1] > 42 else -1
@labeling_function()
def lf(x: DataPoint) -> int:
return 0 if x.num > 42 else -1
@labeling_function(pre=[spacy])
def has_verb(x: DataPoint) -> int:
return 0 if sum(t.pos_ == "VERB" for t in x.doc) > 0 else -1
@labeling_function()
def lf_married(x):
return POSITIVE if "married" in x.between_tokens else ABSTAIN
@labeling_function()
def lf_regex_check_out(x):
"""Spam comments say 'check out my video', 'check it out', etc."""
return SPAM if re.search(r"check.*out", x.text, flags=re.I) else ABSTAIN
@labeling_function(resources=dict(other=other))
def lf_other_relationship(x, other):
return NEGATIVE if len(other.intersection(set(x.between_tokens))) > 0 else ABSTAIN
@labeling_function(pre=[textblob_polarity])
def polarity_positive(x):
return 1 if x.polarity > 0.3 else -1
@labeling_function()
def lf_carry_subject(x):
if x.object_category == "person":
if x.subject_category in ["chair", "bike", "snowboard", "motorcycle", "horse"]:
return CARRY
return ABSTAIN
@labeling_function()
def lf_dist(x):
if np.linalg.norm(np.array(x.subject_bbox) - np.array(x.object_bbox)) <= 1000:
return OTHER
return ABSTAIN