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

Exposing relations in Wordnet class #6

Closed
wants to merge 1 commit into from

Conversation

dchaplinsky
Copy link
Contributor

This might be a bit an overkill, but it has two advantages.

First is:
image

Another is that you can rewrite code like this:

def path_to_top(synset):
    spo = []
    for rel in [11, 107, 171, 172, 199, 212, 213]:

with meaningful names, not numbers

@maxadamski
Copy link
Owner

Autocompletion is definitely nice, but I think a simpler approach would be better.

Since autocompletion in Jupyter works for dict keys, this is enough:

image

Advantages:

  • deaccent and slugify are not needed
  • way less fields in Wordnet objects, so one can get a quick gist of what's inside with dir(wn) without looking at source code

Drawbacks:

  • a bit more verbose (can be remedied somewhat by making an alias wn.rel = wn.relation_by_name)

Do you have other suggestions? If not, I will add my approach soon.

@dchaplinsky
Copy link
Contributor Author

dchaplinsky commented Aug 25, 2021 via email

@maxadamski
Copy link
Owner

Sorry for being so pedantic in this pull request, but I like the simple dict approach too much.

With an alias, # 1 is the same length as # 2, although I admit that it's more visually cluttered. Too bad we can't index Python dicts with a dot :)

REL = wn.relation_by_name
[REL['hiperonimia'], REL['egzemplarz'], ...] # 1
[wn.REL_HIPERONIMIA, wn.REL_EGZEMPLARZ, ...] # 2

@maxadamski maxadamski closed this Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants