Skip to content
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

explore how to re-use code from functions that are very similar efficiently #9

Open
atn38 opened this issue Apr 7, 2022 · 1 comment

Comments

@atn38
Copy link
Owner

atn38 commented Apr 7, 2022

relates to #8.

for example, whatever functions I write to get annotations and get geographic coverage would be very similar at their core:

  • loop through each EML document in a corpus
  • if there's a X element at the dataset level, parse and record it
  • loop through each entity group and then each entity in a group, if there's a X element at the entity level,parse and record it
  • within each entity loop through each attribute, if there's a X element at the attribute level parse and record it

X can be:
methods
coverage
annotations
(any others)

I'd like to not write the same function over and over again, and not have to edit all these separate text files for any sort of editing or debugging. A possible solution is to have the shell function(s), e.g. get_annotations(), actually call or return a template function which takes a function from the parse_() family as an argument.

@atn38
Copy link
Owner Author

atn38 commented Apr 7, 2022

i know i've read about functions that take a function as argument before: those are called functionals: http://adv-r.had.co.nz/Functionals.html

@atn38 atn38 moved this to Todo in pkEML goal 1 Apr 7, 2022
atn38 added a commit that referenced this issue Apr 11, 2022
…eply nested elements (perhaps there's a better way to do this?) so that get_multiplevel_elements() can get elements that are not direct children of entities or attributes
atn38 added a commit that referenced this issue Apr 15, 2022
atn38 added a commit that referenced this issue Apr 27, 2022
atn38 added a commit that referenced this issue Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

1 participant