Data Programming
Label data with rules and heuristics.
Last updated
#Assign target label based on LABELS dictionary
@apply_label(label=LABELS['labelA'])## please check <link section 'text' in gitbook> for more info
text = list(sample.values())[0]text = sample[<COLUMN_NAME>]text = ' '.join([sample[<COLUMN_NAME_A>], sample[<COLUMN_NAME_B>]])>>> text = "Russian and American Alien Spaceship Claims Raise Eyebrows"
>>> target_token = ["Russian", "American"]
>>> match_list = [[0,7],[12,20]] # *TARGET could be **keyword** or **regex pattern.***
>>> match_list = [re.finditer(target, text) for target in TARGET_KEYWORDS]
or
>>> date = re.compile(r"(19|20)\\d\\d[- /.](0[1-9]|[012])[- /.](0[1-9]|[12][0-9]|3[01])")
>>> PATTERNS = [date]
>>> match_list = [re.finditer(pattern, text) for pattern in PATTERNS]def labeling_function(sample):
return Falsedef labeling_function(sample):
match_list = []
return match_list