r4fun / hierplane

🌳 Hierplane for R
https://r4fun.github.io/hierplane/
Other
9 stars 0 forks source link

Unexport hierplane settings + resolve multi-sentence spacyr. #46

Closed mathidachuk closed 4 years ago

mathidachuk commented 4 years ago

This PR closes #43, #25, and #30.

For #43: hierplane_settings is now an internal function. All settings parameters will be passed as part of hp_ functions and structured and assigned with hierplane_settings within the hp_ functions.

Some checks were added to ensure the values passed as parameters are sound. All the checks will run before issuing the error message to prevent multiple reruns.

image

For #25 and #30: I took the opportunity to update spacyr for a little bit more flexibility. The hp_spacyr function now allows user to fetch more attributes from spacy_parse. spacyr_default_attributes` is now exported so user can tag on additional tags as they need.

# text with one sentence returns one hierplane tree object
hp_spacyr("I have a cat.") %>% hierplane()

# text with multiple sentences returns a list of hierplane tree objects
hp_spacyr("I have a cat. Her name is mocha. She has a round belly.") %>% lapply(hierplane)

# tag on an extra attribute
hp_spacyr("How are you doing?", attributes = c(spacyr_default_attributes(), "lemma")) %>% hierplane()

# tag an attribute that is not part of the default attributes:
hp_spacyr("Harry met Sally in 1989.", attributes = c("pos", "is_stop", "like_num")) %>% hierplane()

I may try to write something up to show how to wrap the list of hierplane tree objects up into some sort of slider.