Last active
February 2, 2021 04:44
-
-
Save sharvaridhote/82d21852de730495633a1f5211ced117 to your computer and use it in GitHub Desktop.
Data Label Creator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def label_creator(x): | |
| """ | |
| Find and remove citation from the text and creates labels | |
| parameters: | |
| x : str - charecters in the string | |
| returns : | |
| cleanx : str - cleaned text without citation | |
| label : int - sentence with citation: 1 else 0 | |
| """ | |
| infix = re.compile('\[(.+?)\]') | |
| clean_x = re.findall(infix, x) | |
| if len(clean_x): | |
| label = 1 | |
| else: | |
| label = 0 | |
| cleanx = re.sub(infix, '', x) | |
| return cleanx, label |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment