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

Circular origin reference #20

Closed
alxwrd opened this Issue Jun 10, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@alxwrd
Copy link
Collaborator

alxwrd commented Jun 10, 2018

There's currently at least one circular reference in etymwn-relety.json.

ety.origins("software", recursive=True)

will eventually fail with a recursion error because software -> soft, -ware and -ware -> software.

@alxwrd

This comment has been minimized.

Copy link
Collaborator Author

alxwrd commented Jun 12, 2018

I'm going to run a job to try and discover all these problems with the data.

Hidden as no longer relevant

import sys
import ety

sys.setrecursionlimit(20)

total = len(ety.data.etyms)

def find():
    results = []
    errors = []
    for count, word in enumerate(ety.data.etyms):
        try:
            _ = ety.Word(word["a_word"], word["a_lang"]).origins()
            print("{}/{}".format(count, total), end="\r")
        except RecursionError:
            results.append(_)
        except Exception as e:
            errors.append({
                "error": e,
                "word": _
                })

    return results, errors
>>> import find_circulars
>>> results, errors = find_circulars.find()
4094/473433


I'll update here once it's done.

@alxwrd

This comment has been minimized.

Copy link
Collaborator Author

alxwrd commented Jun 12, 2018

I've just realised this isn't actually recursion because it's the child's .origins() that's being called.

The issue is because the results are appended to the result list, and the chain "software" -> "-ware" -> "software" will just keep growing the result list.

I have a fix in mind, I'll submit a PR later.

@jmsv

This comment has been minimized.

Copy link
Owner

jmsv commented Jun 12, 2018

Hmm, could the solution be as simple as only adding a Word to a branch if it hasn't already appeared in that branch?

@jmsv jmsv closed this in #28 Jun 12, 2018

jmsv added a commit that referenced this issue Jun 12, 2018

@jmsv jmsv reopened this Jun 12, 2018

@jmsv jmsv closed this in fef1573 Jun 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment