-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add files via upload #48
base: master
Are you sure you want to change the base?
Conversation
Check out this pull request on Review Jupyter notebook visual diffs & provide feedback on notebooks. Powered by ReviewNB |
Is there any chance you can add some of the code in these notebooks as python modules that are imported in the notebooks? This has several benefits:
for example, the code block @preprocessor(pre=[spacy])
def get_source_target(cand: DataPoint) -> DataPoint:
"""
Returns the source and target mentioned in the sentence
"""
person_names = []
source = [token.text for token in cand.doc if token.text in example_sources]
target = [token.text for token in cand.doc if token.text in example_targets]
try:
cand.source_target = (source[0],target[0])
except:
cand.source_target = (np.nan,np.nan)
return cand would be much better if it were parametrized like this, and stored in a python module for reuse: def make_source_target_preprocessor(spacy, sources, targets):
@preprocessor(pre=[spacy])
def get_source_target(cand: DataPoint) -> DataPoint:
"""Returnsthe source and target mentioned in the sentence."""
person_names = []
source = [token.text for token in cand.doc if token.text in sources]
target = [token.text for token in cand.doc if token.text in targets]
try:
cand.source_target = (source[0], target[0])
except:
cand.source_target = (np.nan, np.nan)
return cand
return get_source_target Then in your notebook you can do something like: from coronawhy_vt.kriti import make_source_target_preprocessor
get_source_target = make_source_target_preprocessor(spacy, example_sources, example_targets)
... |
Sure, that's a great idea @cthoyt ! |
Please let me know if there’s something I can do to support you. I’ll definitely be able to give feedback as you add pieces as python modules |
Yes, sure, will do. Thanks! |
Snorkel RE example/EDA notebook