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

Guarantee ordering of events and entitites #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

brandomr
Copy link
Collaborator

This pull request contains minor updates to Main.py intended to preserve ordering or critical dictionaries when sent for Causality Detection. Also, this includes sorting keys of dictionaries prior to iterating through them to preserve span ordering as it appears in the text submitted to SOFIA.

Until Python 3.6 there was no guarantee of ordering in dictionaries. Python 3.6 and beyond, insertion ordering is guaranteed. Take this example:

sample = {}
sample['susan'] = 1
sample['bob'] = 50
sample['jim'] = 100

In Python 2, if we ask for sample.keys() we will be returned keys in arbitrary order. For example this could return ['bob', 'susan', 'jim'].

In Python 3 sample.keys() will return the keys in insertion order which must be: ['susan', 'bob', 'jim']

Since the key order is relied on by CausalityDetection.py, it is preferable to use OrderedDict to ensure compatibility with Python 2 and Python 3.

…eserve ordering when sent for Causality Detection. Also sort `keys` prior to iterating through them to preserve `span` ordering as it appears in the text submitted to SOFIA.
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.

1 participant