clulab / eidos

Machine reading system for World Modelers
Apache License 2.0
37 stars 24 forks source link

KeyError: 'duration' #686

Closed phosseini closed 5 years ago

phosseini commented 5 years ago

I'm trying to run the following example in my jupyter notebook:

from delphi.AnalysisGraph import AnalysisGraph
from delphi.visualization import visualize

text = "Significantly increased conflict seen in South Sudan forced many families to flee in 2017."
G = AnalysisGraph.from_text(text, webservice="http://localhost:9000")
visualize(G)

and I keep getting the following error which is apparently related to eidos's processor:

~/anaconda3/envs/delphi/lib/python3.7/site-packages/indra/sources/eidos/processor.py in time_context_from_timex(timex)
    417     start = _get_time_stamp(constraint.get('start'))
    418     end = _get_time_stamp(constraint.get('end'))
--> 419     duration = constraint['duration']
    420     tc = TimeContext(text=time_text, start=start, end=end,
    421                      duration=duration)

KeyError: 'duration'

And interestingly, when I remove 2017 from the input text, then it works! I wonder why this is happening?

Also when I run the very code using another input text which is a bit longer, I get the following error:

text = "How worried should Washington be that the two nations deemed to be most threatening to the United States’ future are getting close? Perhaps less than some fearmongers think. The truth is, neither Xi nor Putin is starry-eyed about their bromance—nor can they afford to be. Great powers do not mate for life, and that’s especially true of China. The biggest reason for Russia and China to bond now is that each has a tense, unpredictable, and potentially antagonistic relationship with the Trump administration. And ever since the birth of the People’s Republic of China 70 years ago, the triangular dynamic among China, the United States, and Russia (or the then-Soviet Union) has hugely influenced Chinese foreign policy. During the late ’50s and early ’60s, a rancorous Chinese-Soviet split and Moscow’s warming to Washington prompted Mao to host U.S. President Richard Nixon in China. Nixon’s startling 1972 China trip ushered in years of strengthening ties, and even Chinese-U.S. cooperation on efforts to thwart the Soviet occupation of Afghanistan. Moscow and Beijing officially ended their estrangement in 1989. Yet just a few years later, the Soviet collapse led Russian leaders to flirt with the idea of integrating with the West."

~/anaconda3/envs/delphi/lib/python3.7/site-packages/delphi/assembly.py in deltas(s)
     11 
     12 def deltas(s: Influence) -> Tuple[Delta, Delta]:
---> 13     return s.subj.delta, s.subj.delta
     14 
     15 

AttributeError: 'Event' object has no attribute 'subj'

Again, even though these are delphi example, but it seems that source of the problem is related to Eidos. Any idea why?

bethard commented 5 years ago

I don't know anything about this Python library you're using, but recent versions of the timenorm part of Eidos do not generate a duration for a time interval anymore since it's directly inferable from the start and end.

phosseini commented 5 years ago

I'm using the Delphi library (described in the linked paper). And, I'm calling Eidos directly from my local machine (using webservice parameter) and it is the latest version of Eidos. So why do you think I'm getting such error?

kwalcock commented 5 years ago

Yes, duration was removed some time ago. That is, it was removed from master, but we haven't updated Eidos with a release for quite some time.

phosseini commented 5 years ago

So you think then I don't have the latest version of Eidos installed? To install Eidos, I cloned the master branch and installed it on my local. So I wonder what else do I need to do?

[UPDATES] I think Delphi is not sync with Eidos and that causes Delphi's processor to through an error when parsing the json output of Eidos (correct me if I'm wrong). I'm closing this issue and I think I should create an issue on delphi. It would have been nice though if these three repositories, Eidos, INDRA, and Delphi be synchronized since they all are introduced in one paper.

adarshp commented 5 years ago

So you think then I don't have the latest version of Eidos installed? To install Eidos, I cloned the master branch and installed it on my local. So I wonder what else do I need to do?

[UPDATES] I think Delphi is not sync with Eidos and that causes Delphi's processor to through an error when parsing the json output of Eidos (correct me if I'm wrong). I'm closing this issue and I think I should create an issue on delphi. It would have been nice though if these three repositories, Eidos, INDRA, and Delphi be synchronized since they all are introduced in one paper.

Hi Pedram,

Thanks for your interest! We do try to keep things in sync as much as possible, but sometimes things do slip through the cracks, especially since Eidos, INDRA, and Delphi are all under very active development. I'll continue the thread on the issue you opened in the Delphi repository.

phosseini commented 5 years ago

So you think then I don't have the latest version of Eidos installed? To install Eidos, I cloned the master branch and installed it on my local. So I wonder what else do I need to do? [UPDATES] I think Delphi is not sync with Eidos and that causes Delphi's processor to through an error when parsing the json output of Eidos (correct me if I'm wrong). I'm closing this issue and I think I should create an issue on delphi. It would have been nice though if these three repositories, Eidos, INDRA, and Delphi be synchronized since they all are introduced in one paper.

Hi Pedram,

Thanks for your interest! We do try to keep things in sync as much as possible, but sometimes things do slip through the cracks, especially since Eidos, INDRA, and Delphi are all under very active development. I'll continue the thread on the issue you opened in the Delphi repository.

Thanks @adarshp for the follow up on this and being so responsive.

bgyori commented 5 years ago

You need to update your INDRA version (pip install -U indra), we have adapted to this change in Eidos' output format 2 months ago.