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

Handling sentences without place names #5

Open
ahalterman opened this issue Oct 16, 2018 · 1 comment
Open

Handling sentences without place names #5

ahalterman opened this issue Oct 16, 2018 · 1 comment

Comments

@ahalterman
Copy link
Member

What's the expected behavior when Profile does not find a place name (perhaps because there is none)? Right now it gives an IndexError, which is really easy to catch and replace with maybe "", but this is making me wonder if this is the version of the code that was run on XCEDE, since this issue surely would have come up. Do you suggest I just put an exception around it and return ""? And is there another version of the code somewhere?

In [23]: TextTest = "The president gave a speech from nowhere."

In [24]: print( Profile.main(lang, NER, TextTest, word2vec_Dictionary, loaded_model) )
loading NER model...
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-24-3a6e4b6f68c5> in <module>()
----> 1 print( Profile.main(lang, NER, TextTest, word2vec_Dictionary, loaded_model) )

/home/ahalt/Focus_Locality_Extraction/Focus_Locality/Sentence_Embedding_Approach/Testing/Profile.pyc in main(lang, NER, TextTest, word2vec_Dictionary, loaded_model)
     38         sorted_loc = sorted(locDic, key=locDic.__getitem__, reverse=True)
     39
---> 40     return sorted_loc[0]
     41
     42

IndexError: list index out of range
ahalterman added a commit to ahalterman/Focus_Locality_Extraction that referenced this issue Oct 16, 2018
@Maryam-Imani
Copy link
Member

I tested it with some text. It seems my test cases were not complete. I will add the exception to it. Thanks

What's the expected behavior when Profile does not find a place name (perhaps because there is none)? Right now it gives an IndexError, which is really easy to catch and replace with maybe "", but this is making me wonder if this is the version of the code that was run on XCEDE, since this issue surely would have come up. Do you suggest I just put an exception around it and return ""? And is there another version of the code somewhere?

In [23]: TextTest = "The president gave a speech from nowhere."

In [24]: print( Profile.main(lang, NER, TextTest, word2vec_Dictionary, loaded_model) )
loading NER model...
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-24-3a6e4b6f68c5> in <module>()
----> 1 print( Profile.main(lang, NER, TextTest, word2vec_Dictionary, loaded_model) )

/home/ahalt/Focus_Locality_Extraction/Focus_Locality/Sentence_Embedding_Approach/Testing/Profile.pyc in main(lang, NER, TextTest, word2vec_Dictionary, loaded_model)
     38         sorted_loc = sorted(locDic, key=locDic.__getitem__, reverse=True)
     39
---> 40     return sorted_loc[0]
     41
     42

IndexError: list index out of range

I tested it with some text. It seems my test cases were not complete. I will add the exception to it. Thanks

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

No branches or pull requests

2 participants