├── README.md ├── _config.yml ├── config ├── SignalWordSet.properties ├── VerbsIgnore.properties ├── directory.properties └── pipeline-config.properties ├── data ├── SampleInput │ ├── GeorgeLowe-long │ ├── GeorgeLowe-short │ ├── GermanUnemployment │ ├── TSA1 │ ├── TSA2 │ ├── TrumpFBI │ ├── TrumpIger1 │ ├── TrumpIger2 │ ├── US-Iraq │ ├── apple │ ├── flu │ ├── presentation │ └── wedding └── output │ ├── GeorgeLowe-long.html │ ├── GeorgeLowe-long.txt │ ├── REF-GeorgeLowe-long.html │ └── REF-GeorgeLowe-long.txt ├── lib └── gurobi.jar ├── pom.xml ├── scripts ├── example.sh └── install.sh └── src └── main ├── java └── edu │ └── illinois │ └── cs │ └── cogcomp │ ├── core │ └── datastructures │ │ └── textannotation │ │ └── myTextAnnotationUtilities.java │ └── temporal │ ├── TemporalRelationExtractor │ ├── EventAxisLabeler.java │ ├── EventAxisLabelerLBJ.java │ ├── EventAxisPerceptronTrainer.java │ ├── EventTokenCandidate.java │ ├── TempLangMdl.java │ ├── TempRelAnnotator.java │ ├── TempRelLabeler.java │ ├── TempRelLabelerLBJ_EE.java │ ├── TempRelLabelerLBJ_ET.java │ └── myTextPreprocessor.java │ ├── configurations │ ├── ParamLBJ.java │ ├── SignalWordSet.java │ ├── VerbIgnoreSet.java │ └── temporalConfigurator.java │ ├── datastruct │ ├── GeneralGraph │ │ ├── AugmentedGraph.java │ │ ├── AugmentedNode.java │ │ ├── BinaryRelation.java │ │ ├── BinaryRelationType.java │ │ └── InOutRelations.java │ └── Temporal │ │ ├── EventTemporalNode.java │ │ ├── TLINK.java │ │ ├── TempRelInferenceWrapper.java │ │ ├── TemporalGraph.java │ │ ├── TemporalNode.java │ │ ├── TemporalRelType.java │ │ ├── TemporalRelation.java │ │ ├── TemporalRelation_EE.java │ │ ├── TemporalRelation_ET.java │ │ ├── TemporalRelation_TT.java │ │ ├── TimexTemporalNode.java │ │ ├── mySimpleDate.java │ │ └── myTemporalDocument.java │ ├── lbjava │ ├── EventDetector │ │ ├── BiasTermDetector.java │ │ ├── ClosestTimexFeats.java │ │ ├── CoveringVerbSRL.java │ │ ├── IsVerbSRL.java │ │ ├── Label.java │ │ ├── Lemma.java │ │ ├── Lemma_IN_WIN.java │ │ ├── POS.java │ │ ├── POS_IN_WIN.java │ │ ├── POS_JOINT_FEAT.java │ │ ├── PPHead.java │ │ ├── PREV_EVENT_FEAT.java │ │ ├── SignalWords.java │ │ ├── VerbSRLFeats.java │ │ ├── eventDetector$$1.java │ │ ├── eventDetector.java │ │ ├── isIntention.java │ │ └── isReporting.java │ ├── TempRelCls │ │ ├── BiasTermTemprel.java │ │ ├── ClosestTimexFeats.java │ │ ├── CorpusStats.java │ │ ├── CoveringSRL.java │ │ ├── IsIntention.java │ │ ├── IsReporting.java │ │ ├── IsVerbSRL.java │ │ ├── Label.java │ │ ├── Lemma.java │ │ ├── POS.java │ │ ├── PPHead.java │ │ ├── SameSynSet.java │ │ ├── SentDist.java │ │ ├── SignalWords.java │ │ ├── TokenDist.java │ │ ├── eeTempRelCls$$1.java │ │ ├── eeTempRelCls.java │ │ ├── eeTempRelCls2$$1.java │ │ ├── eeTempRelCls2.java │ │ ├── eeTempRelCls3$$1.java │ │ ├── eeTempRelCls3.java │ │ ├── eeTempRelCls4$$1.java │ │ ├── eeTempRelCls4.java │ │ ├── eeTempRelCls5$$1.java │ │ └── eeTempRelCls5.java │ └── TempRelCls_ET │ │ ├── BiasTermTemprel.java │ │ ├── ClosestTimexFeats.java │ │ ├── CoveringSRL.java │ │ ├── IsIntention.java │ │ ├── IsReporting.java │ │ ├── IsVerbSRL.java │ │ ├── Label.java │ │ ├── Lemma.java │ │ ├── POS.java │ │ ├── PPHead.java │ │ ├── SentDist.java │ │ ├── SignalWords.java │ │ ├── TokenDist.java │ │ ├── etTempRelCls$$1.java │ │ └── etTempRelCls.java │ ├── readers │ ├── RED │ │ ├── RedDataset.java │ │ ├── RedDoc.java │ │ ├── RedEvent.java │ │ └── RedReader_Basic.java │ ├── axisAnnotationReader.java │ ├── myCSVReader.java │ └── temprelAnnotationReader.java │ └── utils │ ├── CoDL │ ├── CoDLWrapper_LBJ.java │ ├── MultiClassifiers.java │ ├── ScoringFunc.java │ └── TempRelLabelerMultiLBJ.java │ ├── CrossValidation │ ├── CVWrapper_LBJ.java │ ├── CVWrapper_LBJ_Perceptron.java │ ├── CrossValidationSplit.java │ └── CrossValidationWrapper.java │ ├── ExecutionTimeUtil.java │ ├── GraphVisualizer │ ├── GraphJavaScript.java │ ├── edge.java │ └── vertex.java │ ├── IO │ ├── IOManager.java │ ├── myIOUtils.java │ └── mySerialization.java │ ├── ListSampler.java │ ├── PrecisionRecallManager.java │ ├── Triplet.java │ ├── WordNet │ ├── SynsetNode.java │ └── WNSim.java │ ├── myLogFormatter.java │ └── myUtils4TextAnnotation.java └── lbj ├── eeTempRelCls.lbj ├── etTempRelCls.lbj └── eventDetector.lbj /README.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | CogCompTime is a state-of-the-art package for understanding time in natural language text. It can automatically (1) extract time expressions (e.g., yesterday and next Monday), (2) convert time expressions to computer-understandable format (e.g., 2018-05-31), and (3) extract verb events on the main-axis of stories and the temporal relations between them (e.g., event1 is before/after event2). 3 | This is the backend system of the online demo [here](http://groupspaceuiuc.com/temporal/). 4 | 5 | ### Prerequisites 6 | - This package was tested on Ubuntu Mate 16.04. 7 | - [maven](https://maven.apache.org/install.html) 8 | - [Gurobi](http://www.gurobi.com/downloads/gurobi-optimizer) . The environment variables `GUROBI_HOME` and `GRB_LICENSE_FILE` setup in path, as required by Gurobi. Gurobi would typically require adding the following lines to .bashrc or .bash_profile (please refer to Gurobi's installment instructions for details.) 9 | ``` 10 | export GUROBI_HOME=/opt/gurobi652/linux64 # "652" is the version number 6.5.2; we also tested with 8.1.0 11 | export PATH=$PATH:$GUROBI_HOME/bin 12 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GUROBI_HOME/lib 13 | export GRB_LICENSE_FILE=$GUROBI_HOME/gurobi.lic 14 | ``` 15 | **Note that if you can also run it without Gurobi, so that the transitivity constraints are not enforced during inference (which may be problematic in some applications)** 16 | 17 | ## Compile 18 | All the following commands should be run from the root dir of the project, i.e., `CogCompTime/`. 19 | 20 | ``` 21 | git clone git@github.com:CogComp/CogCompTime.git 22 | cd CogCompTime 23 | sh scripts/install.sh # to install gurobi.jar into the local .m2 repo 24 | mvn compile 25 | ``` 26 | 27 | ## Resources 28 | Please also download `WordNet-3.0` and `TemProb.txt` from my another repo [TemProb-NAACL18](https://github.com/CogComp/TemProb-NAACL18/tree/master/data) and put them into `CogCompTime/data/` before you move forward. 29 | 30 | ## Example Usage 31 | If no error messages pop up, you're can move forward by 32 | ``` 33 | sh scripts/example.sh 34 | ``` 35 | 36 | Again, if no errors are encountered, you should be able to see the output in `data/output/GeorgeLowe-long.html` (open it via any internet browser and you will see the *temporal graph* you see in our online demo) and `data/output/GeorgeLowe-long.txt` (the *timeline* you see in our online demo). Compare them with the reference output `data/output/REF-GeorgeLowe-long` to see if everything is the same. 37 | 38 | ## Trouble shooting 39 | - The first time you run the code, one component of CogCompTime will automatically download some resource files from CogCompGroup servers (specifically, that component is `illinois-nlp-pipeline`. Those resource files will be downloaded and saved into your `$HOME/.cogcomp-datastore`. If you have trouble downloading them, you can try this back-up [link (300MB)](http://qning2.web.engr.illinois.edu/misc/cogcomp-datestore.tar.gz) and unzip it into `$HOME/.cogcomp-datastore`. 40 | - There's a known issue in `illinois-nlp-pipeline` described [here](https://github.com/CogComp/cogcomp-nlp/issues/708). That is, when you use `illinois-nlp-pipeline` to process semantic role labeling (SRL), it's possible that it requires more than 32GB of memory. CogCompTime indeed relies on that SRL component. So if you do see this issue, you can try CogCompTime on a machine with more than 32GB in memory. 41 | 42 | ## Citation 43 | Please kindly cite the following paper: *Qiang Ning, Ben Zhou, Zhili Feng, Haoruo Peng and Dan Roth, CogCompTime: A Tool for Understanding Time in Natural Language EMNLP (Demo Track) (2018)* ([pdf](http://cogcomp.org/papers/NZFPR18.pdf)) 44 | 45 | ``` 46 | @inproceedings{NZFPR18, 47 | author = {Qiang Ning and Ben Zhou and Zhili Feng and Haoruo Peng and Dan Roth}, 48 | title = {CogCompTime: A Tool for Understanding Time in Natural Language}, 49 | booktitle = {EMNLP (Demo Track)}, 50 | month = {11}, 51 | year = {2018}, 52 | address = {Brussels, Belgium}, 53 | publisher = {Association for Computational Linguistics}, 54 | url = "http://cogcomp.org/papers/NZFPR18.pdf", 55 | } 56 | ``` 57 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal -------------------------------------------------------------------------------- /config/SignalWordSet.properties: -------------------------------------------------------------------------------- 1 | temporalConnectiveSet_before before,then,until,so,hence,thus,eventually,therefore,as a result,so as to,so that,in order to,later 2 | 3 | temporalConnectiveSet_after after,since,because 4 | 5 | temporalConnectiveSet_during when,while,meanwhile,during 6 | 7 | temporalConnectiveSet_contrast although,however,nevertheless,otherwise,even if,even though 8 | 9 | temporalAdverbSet previously,initially,recently,lately,afterwards,already,yet,former,following,followed 10 | 11 | modalVerbSet will,would,can,could,may,might 12 | 13 | axisSignalWordSet if,unless,not,n't,cannot,every,each,given,to 14 | 15 | reportingVerbSet say,tell,report,think,believe,argue,warn,assert,accuse,deny,consider,agree,indicate,know,promise,ask,show,suggest 16 | 17 | intentionVerbSet expect,want,predict,desire,need -------------------------------------------------------------------------------- /config/VerbsIgnore.properties: -------------------------------------------------------------------------------- 1 | VERBS_IGNORE be,have 2 | 3 | SRL_VERBS_IGNORE be,have,can,may,dare,must,ought,shall,will,may,might -------------------------------------------------------------------------------- /config/directory.properties: -------------------------------------------------------------------------------- 1 | WordNet_Dir data/WordNet-3.0 2 | 3 | TemProb_Dir data/TemProb.txt 4 | 5 | -------------------------------------------------------------------------------- /config/pipeline-config.properties: -------------------------------------------------------------------------------- 1 | cacheDirectory annotation-cache-test 2 | throwExceptionIfNotCached false 3 | usePos true 4 | useDep false 5 | useLemma true 6 | useShallowParse false 7 | useNerConll false 8 | useNerOntonotes false 9 | useSrlVerb true 10 | useSrlNom false 11 | useCommaSrl false 12 | useQuantifier false 13 | useStanfordParse false 14 | useStanfordDep false 15 | useMention false 16 | useRelation false -------------------------------------------------------------------------------- /data/SampleInput/GeorgeLowe-long: -------------------------------------------------------------------------------- 1 | DCT:2013-03-22 2 | The last surviving member of the team which first conquered Everest in 1953 has died in a Derbyshire nursing home. George Lowe, 89, died in Ripley on Wednesday after a long-term illness, with his wife Mary by his side. New Zealand-born Mr Lowe was part of the team that helped Sir Edmund Hillary and Tenzing Norgay to the summit in 1953.Family friend and historian Dr Huw Lewis-Jones paid tribute to a "gentle soul and fine climber" who shunned the limelight. Mr Lowe also took part in the trans-Antarctic expedition of 1957-58, which made the first successful overland crossing of Antarctica via the South Pole. He later made expeditions to Greenland, Greece and Ethiopia. Speaking to the BBC in 1995, Mr Lowe said of his Antarctic adventure: "We estimated we could do it in 100 days, and we got across on the 99th day. "There was a great feeling of euphoria from everyone. It had a multiplying effect. "We were pleased that England and New Zealand knew about it, and we thought that's where it would stop." He also talked about his "second job" as the group's cameraman, and having to wear four pairs of gloves to work the clockwork camera. "When there were dramas, there was a split problem. Do you take part in the urgency - or do you record it?" he said. Dr Lewis-Jones, the former curator at the Scott Polar Research Institute at the University of Cambridge, who first met Mr Lowe in 2005, called him a "hero". "I don't often use that word but then it is not very often that you get to meet one," he said. A book of memoirs and photographs from the climb by Mr Lowe, which he worked on with Dr Lewis-Jones, is due to be published in May. He said: "Lowe was a brilliant, kind fellow who never sought the limelight... and 60 years on from Everest his achievements deserve wider recognition. "He was involved in two of the most important explorations of the 20th Century... yet remained a humble, happy man right to the end... an inspirational lesson to us all." Before retiring in 1984, Mr Lowe worked as an Inspector of Schools with the Department of Education and Sciences, and he leaves three sons from a previous marriage. The last British climbing member of the 1953 team, Mike Westmacott, died last June. -------------------------------------------------------------------------------- /data/SampleInput/GeorgeLowe-short: -------------------------------------------------------------------------------- 1 | DCT:2013-03-22 2 | George Lowe, the last surviving member of the team which first conquered Everest in 1953, died in Ripley on Wednesday after a long-term illness, with his wife Mary by his side. The last British climbing member of the 1953 team, Mike Westmacott, died last June. Before retiring in 1984, Mr Lowe worked as an Inspector of Schools with the Department of Education and Sciences, and he leaves three sons from a previous marriage. -------------------------------------------------------------------------------- /data/SampleInput/GermanUnemployment: -------------------------------------------------------------------------------- 1 | Thousands of people in Germany have been demonstrating today against the high level of unemployment in the country. Latest report shows a sharp rise, with nearly five million Germans out of work. -------------------------------------------------------------------------------- /data/SampleInput/TSA1: -------------------------------------------------------------------------------- 1 | The Transportation Security Administration said it has added about two dozen dogs to monitor passengers coming in and out of the airport around the Super Bowl. On Saturday, TSA agents demonstrated how the dogs can sniff out many different types of explosives. -------------------------------------------------------------------------------- /data/SampleInput/TSA2: -------------------------------------------------------------------------------- 1 | TSA spokeswoman Lisa Farbstein said the dogs undergo 12 weeks of training, which costs about $200,000, factoring in food, vehicles and salaries for trainers. Dogs have been used in cargo areas for some time, but have just been introduced recently in passenger areas at Newark and JFK airports. -------------------------------------------------------------------------------- /data/SampleInput/TrumpFBI: -------------------------------------------------------------------------------- 1 | President Trump on Sunday demanded that the Justice Department investigate whether the FBI infiltrated his campaign as he targets those he views as political enemies. -------------------------------------------------------------------------------- /data/SampleInput/TrumpIger1: -------------------------------------------------------------------------------- 1 | The president called out Robert Iger who had phoned Valerie Jarrett on Tuesday to apologize. The president complained on Twitter that Mr. Iger had not called President Donald Trump to apologize for the horrible statements said about him on ABC. -------------------------------------------------------------------------------- /data/SampleInput/TrumpIger2: -------------------------------------------------------------------------------- 1 | Instead, he expressed his own grievances on Wednesday and Thursday with what the network’s on-air personalities have said about him, and insisted he was the one who deserved an apology. -------------------------------------------------------------------------------- /data/SampleInput/US-Iraq: -------------------------------------------------------------------------------- 1 | The US military buildup in the Persian gulf continues apace and more planes are heading from the United States. Senior officials say Iraq's president Saddam Hussein can expect punishing air strikes if he doesn't stop building biological and chemical weapons. -------------------------------------------------------------------------------- /data/SampleInput/apple: -------------------------------------------------------------------------------- 1 | DCT:2008-01-09 2 | The European Commission has forced Apple Inc. to lower its prices for media in its United Kingdom iTunes store , Apple 's online media shop . The change in policy will occur within the next six months , Apple announced this morning . Apple is the producer of the world 's most-sold MP3 Player , the iPod and launched the iTunes Music Store , a online music store , on April 28 , 2003 . The store was renamed to iTunes Store in 2006 , as Apple began selling other media apart from music , such as feature-length movies . Since its launch the store has sold more than 3 billion songs . At the moment songs are sold for 0.79 per song and 7.99 per album which after the price cut will on average be reduced to 0.74 and 7.48 to match the EU prices of 0.99 and 9.99 , according to Times Online . -------------------------------------------------------------------------------- /data/SampleInput/flu: -------------------------------------------------------------------------------- 1 | The flu season is winding down. It has killed 105 children so far. -------------------------------------------------------------------------------- /data/SampleInput/presentation: -------------------------------------------------------------------------------- 1 | Yesterday's presentation was well received since we had practiced a lot. -------------------------------------------------------------------------------- /data/SampleInput/wedding: -------------------------------------------------------------------------------- 1 | DCT:2018-05-01 2 | They became friends when they attended the same university 9 years ago. Now they are planning their wedding this June. -------------------------------------------------------------------------------- /data/output/GeorgeLowe-long.txt: -------------------------------------------------------------------------------- 1 | | 2 | |--------------E1:died 3 | | 4 | |1953----------E0:conquered 5 | | 6 | |2013-03-20----E2:died 7 | | 8 | |--------------E3:helped 9 | | 10 | |--------------E4:Tenzing 11 | | 12 | |--------------E6:shunned 13 | | 14 | |--------------E5:paid 15 | | 16 | |--------------E7:took 17 | | 18 | |--------------E8:made 19 | | 20 | |--------------E9:crossing 21 | | 22 | |--------------E13:estimated 23 | | 24 | |--------------E10:made 25 | | 26 | |1995----------E11:Speaking 27 | | 28 | |--------------E14:got 29 | | 30 | |--------------E12:said 31 | | 32 | |--------------E15:pleased 33 | | 34 | |--------------E17:thought 35 | | 36 | |--------------E18:talked 37 | | 38 | |--------------E16:knew 39 | | 40 | |--------------E20:met 41 | | 42 | |--------------E21:called 43 | | 44 | |--------------E19:said 45 | | 46 | |--------------E25:sought 47 | | 48 | |--------------E23:worked 49 | | 50 | |--------------E22:said 51 | | 52 | |--------------E27:remained 53 | | 54 | |--------------E26:involved 55 | | 56 | |--------------E24:said 57 | | 58 | |1984----------E28:retiring 59 | | 60 | |1984----------E29:worked 61 | | 62 | |2012-06-------E31:died 63 | | 64 | |--------------E30:leaves 65 | | 66 | V 67 | 68 | Time Axis 69 | -------------------------------------------------------------------------------- /data/output/REF-GeorgeLowe-long.txt: -------------------------------------------------------------------------------- 1 | | 2 | |--------------E1:died 3 | | 4 | |1953----------E0:conquered 5 | | 6 | |2013-03-20----E2:died 7 | | 8 | |--------------E3:helped 9 | | 10 | |--------------E4:Tenzing 11 | | 12 | |--------------E6:shunned 13 | | 14 | |--------------E5:paid 15 | | 16 | |--------------E7:took 17 | | 18 | |--------------E8:made 19 | | 20 | |--------------E9:crossing 21 | | 22 | |--------------E13:estimated 23 | | 24 | |--------------E10:made 25 | | 26 | |1995----------E11:Speaking 27 | | 28 | |--------------E14:got 29 | | 30 | |--------------E12:said 31 | | 32 | |--------------E15:pleased 33 | | 34 | |--------------E17:thought 35 | | 36 | |--------------E18:talked 37 | | 38 | |--------------E16:knew 39 | | 40 | |--------------E20:met 41 | | 42 | |--------------E21:called 43 | | 44 | |--------------E19:said 45 | | 46 | |--------------E25:sought 47 | | 48 | |--------------E23:worked 49 | | 50 | |--------------E22:said 51 | | 52 | |--------------E27:remained 53 | | 54 | |--------------E26:involved 55 | | 56 | |--------------E24:said 57 | | 58 | |1984----------E28:retiring 59 | | 60 | |1984----------E29:worked 61 | | 62 | |2012-06-------E31:died 63 | | 64 | |--------------E30:leaves 65 | | 66 | V 67 | 68 | Time Axis 69 | -------------------------------------------------------------------------------- /lib/gurobi.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CogComp/CogCompTime/b8e4a8dcc184f8f7fbfa4eb8e8e77ac6bf9602a5/lib/gurobi.jar -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | edu.illinois.cs.cogcomp 8 | CogCompTime 9 | 1.0.0 10 | 11 | 12 | 13 | edu.illinois.cs.cogcomp 14 | illinois-time 15 | 4.0.13 16 | 17 | 18 | edu.illinois.cs.cogcomp 19 | illinois-temporal-models 20 | 1.0.0 21 | 22 | 23 | edu.illinois.cs.cogcomp 24 | LBJava 25 | 1.3.1 26 | 27 | 28 | net.sf.jgrapht 29 | jgrapht 30 | 31 | 32 | 33 | 34 | Gurobi 35 | gurobi 36 | 6.5.2 37 | 38 | 39 | com.opencsv 40 | opencsv 41 | 4.0 42 | 43 | 44 | org.jgrapht 45 | jgrapht-core 46 | 1.1.0 47 | 48 | 49 | edu.illinois.cs.cogcomp 50 | illinois-core-utilities 51 | 4.0.13 52 | 53 | 54 | edu.illinois.cs.cogcomp 55 | illinois-ner 56 | 4.0.13 57 | 58 | 59 | edu.illinois.cs.cogcomp 60 | illinois-edison 61 | 4.0.13 62 | 63 | 64 | edu.illinois.cs.cogcomp 65 | illinois-nlp-pipeline 66 | 4.0.13 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | org.apache.maven.plugins 75 | maven-compiler-plugin 76 | 3.5.1 77 | 78 | 1.8 79 | 1.8 80 | 81 | 82 | 83 | 84 | 85 | 86 | CogcompSoftware 87 | CogcompSoftware 88 | http://cogcomp.org/m2repo/ 89 | 90 | 91 | 92 | 93 | CogcompSoftware 94 | CogcompSoftware 95 | scp://legolas.cs.illinois.edu:/srv/data/cogcomp/html/m2repo 96 | 97 | 98 | CogcompSoftwareDoc 99 | scp://legolas.cs.illinois.edu:/srv/data/cogcomp/html/software/doc/ 100 | 101 | 102 | 103 | true 104 | 105 | 106 | UTF-8 107 | UTF-8 108 | 109 | 110 | -------------------------------------------------------------------------------- /scripts/example.sh: -------------------------------------------------------------------------------- 1 | mvn exec:java -Dexec.mainClass=edu.illinois.cs.cogcomp.temporal.TemporalRelationExtractor.TempRelAnnotator -------------------------------------------------------------------------------- /scripts/install.sh: -------------------------------------------------------------------------------- 1 | mvn source:jar install:install-file -Dfile=lib/gurobi.jar -DgroupId=Gurobi -DartifactId=gurobi -Dversion=6.5.2 -Dpackaging=jar 2 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/TemporalRelationExtractor/EventAxisLabeler.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.TemporalRelationExtractor; 2 | 3 | public interface EventAxisLabeler { 4 | String axisLabel(EventTokenCandidate etc); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/TemporalRelationExtractor/EventAxisLabelerLBJ.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.TemporalRelationExtractor; 2 | 3 | import edu.illinois.cs.cogcomp.lbjava.learn.Learner; 4 | 5 | import static edu.illinois.cs.cogcomp.temporal.readers.axisAnnotationReader.LABEL_NOT_ON_ANY_AXIS; 6 | 7 | public class EventAxisLabelerLBJ implements EventAxisLabeler { 8 | public Learner classifier; 9 | 10 | public EventAxisLabelerLBJ(Learner classifier) { 11 | this.classifier = classifier; 12 | } 13 | 14 | @Override 15 | public String axisLabel(EventTokenCandidate etc) { 16 | return classifier!=null? 17 | classifier.discreteValue(etc):LABEL_NOT_ON_ANY_AXIS; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/TemporalRelationExtractor/TempRelLabeler.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.TemporalRelationExtractor; 2 | 3 | import edu.illinois.cs.cogcomp.lbjava.classify.ScoreSet; 4 | import edu.illinois.cs.cogcomp.lbjava.learn.Softmax; 5 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelType; 6 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation; 7 | 8 | public abstract class TempRelLabeler { 9 | // Do two things: 1) return a TemporalRelType label. 2) assign scores to TemporalRelType 10 | public abstract TemporalRelType tempRelLabel(TemporalRelation ee); 11 | 12 | public abstract boolean isIgnore(TemporalRelation ee); 13 | 14 | protected double[] temporalScores2doubles(ScoreSet scores, String[] allLabels, boolean norm){ 15 | if(norm) { 16 | Softmax sm = new Softmax(); 17 | scores = sm.normalize(scores); 18 | } 19 | int n = allLabels.length; 20 | double[] s = new double[n]; 21 | for(int i=0;i clist = dep.getConstituentsCoveringToken(i); 51 | for(Constituent c:clist){ 52 | List rels = c.getOutgoingRelations(); 53 | for(Relation r:rels){ 54 | System.out.println(r); 55 | System.out.println(r.getRelationName()); 56 | } 57 | rels = c.getIncomingRelations(); 58 | for(Relation r:rels){ 59 | int tokid = r.getTarget().getStartSpan(); 60 | System.out.println(r.getSource()); 61 | System.out.println(r.getTarget()); 62 | } 63 | System.out.println(); 64 | } 65 | } 66 | System.out.println(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/configurations/ParamLBJ.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.configurations; 2 | 3 | public class ParamLBJ { 4 | public static class EventDetectorPerceptronParams{ 5 | public static double learningRate = 0.001; 6 | public static double thickness = 1; 7 | } 8 | public static class EETempRelClassifierPerceptronParams{ 9 | public static double learningRate = 0.001; 10 | public static double thickness = 1; 11 | 12 | public static double[] LEARNRATE = new double[]{0.001}; 13 | public static double[] THICKNESS = new double[]{0,1}; 14 | public static double[] SAMRATE = new double[]{0.1,0.2,0.3}; 15 | public static double[] ROUND = new double[]{50,100,200}; 16 | } 17 | public static class ETTempRelClassifierPerceptronParams{ 18 | public static double learningRate = 0.001; 19 | public static double thickness = 1; 20 | 21 | public static double[] LEARNRATE = new double[]{0.001}; 22 | public static double[] THICKNESS = new double[]{0,1}; 23 | public static double[] SAMRATE = new double[]{0.4,0.5,0.6}; 24 | public static double[] ROUND = new double[]{50,100}; 25 | } 26 | } -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/configurations/SignalWordSet.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.configurations; 2 | 3 | 4 | import edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager; 5 | 6 | import java.util.Arrays; 7 | import java.util.HashSet; 8 | import java.util.Set; 9 | 10 | public class SignalWordSet { 11 | public class temporalSignals{ 12 | public Set connectives_before = new HashSet<>(); 13 | public Set connectives_after = new HashSet<>(); 14 | public Set connectives_during = new HashSet<>(); 15 | public Set connectives_contrast = new HashSet<>(); 16 | public Set connectives_adverb = new HashSet<>(); 17 | private HashSet allConnectives = new HashSet<>(); 18 | public HashSet getAllConnectives(){ 19 | if(allConnectives.size()==0){ 20 | allConnectives.addAll(connectives_before); 21 | allConnectives.addAll(connectives_after); 22 | allConnectives.addAll(connectives_during); 23 | allConnectives.addAll(connectives_contrast); 24 | allConnectives.addAll(connectives_adverb); 25 | } 26 | return allConnectives; 27 | } 28 | } 29 | public temporalSignals temporalSignalSet = new temporalSignals(); 30 | public Set modalVerbSet = new HashSet<>(),axisSignalWordSet = new HashSet<>(),reportingVerbSet = new HashSet<>(),intentionVerbSet = new HashSet<>(); 31 | public static SignalWordSet instance; 32 | private static Set parseRmProperty(ResourceManager rm, String propName){ 33 | String tmp = rm.getString(propName); 34 | return new HashSet(Arrays.asList(tmp.split(","))); 35 | } 36 | public static SignalWordSet getInstance(){ 37 | if(instance!=null) 38 | return instance; 39 | try { 40 | return getInstance(new ResourceManager("config/SignalWordSet.properties")); 41 | } 42 | catch (Exception e){ 43 | e.printStackTrace(); 44 | return new SignalWordSet(); 45 | } 46 | } 47 | public static SignalWordSet getInstance(ResourceManager rm){ 48 | if(instance!=null) 49 | return instance; 50 | instance = new SignalWordSet(); 51 | instance.temporalSignalSet.connectives_before = parseRmProperty(rm,"temporalConnectiveSet_before"); 52 | instance.temporalSignalSet.connectives_after = parseRmProperty(rm,"temporalConnectiveSet_after"); 53 | instance.temporalSignalSet.connectives_during = parseRmProperty(rm,"temporalConnectiveSet_during"); 54 | instance.temporalSignalSet.connectives_contrast = parseRmProperty(rm,"temporalConnectiveSet_contrast"); 55 | instance.temporalSignalSet.connectives_adverb = parseRmProperty(rm,"temporalAdverbSet"); 56 | instance.modalVerbSet = parseRmProperty(rm,"modalVerbSet"); 57 | instance.axisSignalWordSet = parseRmProperty(rm,"axisSignalWordSet"); 58 | instance.reportingVerbSet = parseRmProperty(rm,"reportingVerbSet"); 59 | instance.intentionVerbSet = parseRmProperty(rm,"intentionVerbSet"); 60 | return instance; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/configurations/VerbIgnoreSet.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.configurations; 2 | 3 | import edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager; 4 | 5 | import java.util.Arrays; 6 | import java.util.HashSet; 7 | import java.util.Set; 8 | 9 | public class VerbIgnoreSet { 10 | public Set verbIgnoreSet = new HashSet<>(), srlVerbIgnoreSet = new HashSet<>(); 11 | public static VerbIgnoreSet instance; 12 | private static Set parseRmProperty(ResourceManager rm, String propName){ 13 | String tmp = rm.getString(propName); 14 | return new HashSet(Arrays.asList(tmp.split(","))); 15 | } 16 | public static VerbIgnoreSet getInstance(){ 17 | if(instance!=null) 18 | return instance; 19 | try { 20 | return getInstance(new ResourceManager("config/VerbsIgnore.properties")); 21 | } 22 | catch (Exception e){ 23 | e.printStackTrace(); 24 | return new VerbIgnoreSet(); 25 | } 26 | } 27 | public static VerbIgnoreSet getInstance(ResourceManager rm){ 28 | if(instance!=null) 29 | return instance; 30 | instance = new VerbIgnoreSet(); 31 | instance.verbIgnoreSet = parseRmProperty(rm,"VERBS_IGNORE"); 32 | instance.srlVerbIgnoreSet = parseRmProperty(rm,"SRL_VERBS_IGNORE"); 33 | return instance; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/configurations/temporalConfigurator.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.configurations; 2 | 3 | import edu.illinois.cs.cogcomp.core.utilities.configuration.Configurator; 4 | import edu.illinois.cs.cogcomp.core.utilities.configuration.Property; 5 | import edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager; 6 | 7 | import java.io.IOException; 8 | 9 | public class temporalConfigurator extends Configurator { 10 | public static Property EVENT_DETECTOR_WINDOW = new Property("EVENT_DETECTOR_WINDOW", "2"); 11 | public static Property EVENT_TEMPREL_WINDOW = new Property("EVENT_TEMPREL_WINDOW", "3"); 12 | public static Property EVENT_TIMEX_TEMPREL_WINDOW = new Property("EVENT_TIMEX_TEMPREL_WINDOW", "3"); 13 | @Override 14 | public ResourceManager getDefaultConfig() { 15 | Property[] props = {EVENT_DETECTOR_WINDOW,EVENT_TEMPREL_WINDOW,EVENT_TIMEX_TEMPREL_WINDOW}; 16 | return new ResourceManager(generateProperties(props)); 17 | } 18 | 19 | public ResourceManager getConfig(String config_fname) throws IOException { 20 | return super.getConfig(new ResourceManager(config_fname)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/datastruct/GeneralGraph/AugmentedNode.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.datastruct.GeneralGraph; 2 | 3 | import java.io.Serializable; 4 | 5 | public abstract class AugmentedNode implements Serializable { 6 | private static final long serialVersionUID = 5662840974130314900L; 7 | protected int nodeId; 8 | protected String nodeType; 9 | protected String text; 10 | 11 | /*Constructors*/ 12 | 13 | public AugmentedNode() { 14 | } 15 | 16 | public AugmentedNode(AugmentedNode other){ 17 | nodeId = other.nodeId; 18 | nodeType = other.nodeType; 19 | text = other.text; 20 | } 21 | 22 | public AugmentedNode(int nodeId, String nodeType, String text) { 23 | this.nodeId = nodeId; 24 | this.nodeType = nodeType; 25 | this.text = text; 26 | } 27 | 28 | /*Functions*/ 29 | public boolean isEqual(AugmentedNode other){ 30 | return this.equals(other)|| 31 | other!=null&&getUniqueId().equals(other.getUniqueId()); 32 | } 33 | 34 | public int compare(AugmentedNode other){ 35 | return getUniqueId().compareTo(other.getUniqueId()); 36 | } 37 | 38 | /*Getters and Setters*/ 39 | 40 | public int getNodeId() { 41 | return nodeId; 42 | } 43 | 44 | public void setNodeId(int nodeId) { 45 | this.nodeId = nodeId; 46 | } 47 | 48 | public String getNodeType() { 49 | return nodeType; 50 | } 51 | 52 | public void setNodeType(String nodeType) { 53 | this.nodeType = nodeType; 54 | } 55 | 56 | public String getText() { 57 | return text; 58 | } 59 | 60 | public void setText(String text) { 61 | this.text = text; 62 | } 63 | 64 | public String getUniqueId(){return getUniqueId(nodeType,nodeId);} 65 | 66 | public static String getUniqueId(String nodeType, int nodeId){ 67 | return nodeType+nodeId; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/datastruct/GeneralGraph/BinaryRelation.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.datastruct.GeneralGraph; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by chuchu on 12/19/17. 9 | */ 10 | public abstract class BinaryRelation implements Serializable{ 11 | private static final long serialVersionUID = 1238168453574063459L; 12 | private Node sourceNode, targetNode; 13 | private BinaryRelationType relType; 14 | private BinaryRelation relation_inverse;//assume all binary relations are two-way, i.e., if A has relation to B, there must be an inverse relation such that B has "inverse relation" to A. 15 | 16 | /*Constructors*/ 17 | 18 | public BinaryRelation() { 19 | } 20 | 21 | public BinaryRelation(Node sourceNode, Node targetNode, BinaryRelationType relType) { 22 | this.sourceNode = sourceNode; 23 | this.targetNode = targetNode; 24 | this.relType = relType; 25 | } 26 | 27 | /*Functions*/ 28 | public abstract BinaryRelation inverse(); 29 | public void reverse(){ 30 | Node tmp = sourceNode; 31 | sourceNode = targetNode; 32 | targetNode = tmp; 33 | relType.reverse(); 34 | } 35 | public abstract boolean isNull(); 36 | 37 | @NotNull 38 | public BinaryRelation getInverse(){ 39 | if(relation_inverse ==null) { 40 | relation_inverse = inverse(); 41 | relation_inverse.setRelation_inverse(this); 42 | } 43 | return relation_inverse; 44 | } 45 | 46 | private boolean sameNodePair(BinaryRelation other){ 47 | if(other==null) return false; 48 | if(sourceNode.isEqual(other.getSourceNode())&&targetNode.isEqual(other.getTargetNode())) return true; 49 | if(sourceNode.isEqual(other.getTargetNode())&&targetNode.isEqual(other.getSourceNode())) return true; 50 | return false; 51 | } 52 | public boolean isEqual(BinaryRelation other){ 53 | return sameNodePair(other)&&isConsistent(other); 54 | } 55 | public boolean isConsistent(BinaryRelation other) {// return true if no conflicts 56 | if(!sameNodePair(other)) return true; 57 | if(sourceNode.isEqual(other.getSourceNode())&&relType.isEqual(other.getRelType())) return true; 58 | return relType.isEqual(other.getRelType().inverse()); 59 | } 60 | 61 | /*Getters and Setters*/ 62 | 63 | public Node getSourceNode() { 64 | return sourceNode; 65 | } 66 | 67 | public void setSourceNode(Node sourceNode) { 68 | this.sourceNode = sourceNode; 69 | } 70 | 71 | public Node getTargetNode() { 72 | return targetNode; 73 | } 74 | 75 | public void setTargetNode(Node targetNode) { 76 | this.targetNode = targetNode; 77 | } 78 | 79 | public BinaryRelationType getRelType() { 80 | return relType; 81 | } 82 | 83 | public void setRelType(BinaryRelationType relType) { 84 | this.relType = relType; 85 | } 86 | 87 | public BinaryRelation getRelation_inverse() { 88 | return relation_inverse; 89 | } 90 | 91 | public void setRelation_inverse(BinaryRelation relation_inverse) { 92 | this.relation_inverse = relation_inverse; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/datastruct/GeneralGraph/BinaryRelationType.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.datastruct.GeneralGraph; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by chuchu on 12/19/17. 8 | */ 9 | public abstract class BinaryRelationType implements Serializable { 10 | private static final long serialVersionUID = -2480151599728519342L; 11 | 12 | public BinaryRelationType() { 13 | } 14 | 15 | public abstract BinaryRelationType inverse(); 16 | public abstract void reverse(); 17 | public abstract List transitivity(BinaryRelationType rel); 18 | public abstract boolean isNull(); 19 | public abstract String toString(); 20 | public abstract boolean isEqual(BinaryRelationType other); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/datastruct/GeneralGraph/InOutRelations.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.datastruct.GeneralGraph; 2 | 3 | public class InOutRelations { 4 | /*private Node node; 5 | private HashMap> in_rels = new HashMap<>(); 6 | private HashMap> out_rels = new HashMap<>(); 7 | 8 | public InOutRelations(Node node) { 9 | this.node = node; 10 | } 11 | 12 | private boolean addInRel(BinaryRelation newrel){ 13 | in_rels.put(newrel.getSourceNode().getUniqueId(),newrel); 14 | return true; 15 | } 16 | private boolean addOutRel(BinaryRelation newrel){ 17 | out_rels.put(newrel.getTargetNode().getUniqueId(),newrel); 18 | return true; 19 | } 20 | private boolean addRel(BinaryRelation newrel){ 21 | // assume newrel has at least one node matching to current node 22 | if(newrel.getSourceNode().isEqual(node)) 23 | return addOutRel(newrel)&&addInRel(newrel.getInverse()); 24 | return addInRel(newrel)&&addOutRel(newrel.getInverse()); 25 | } 26 | public boolean addRelNoDup(BinaryRelation newrel){ 27 | if(newrel==null||newrel.isNull()) 28 | return false; 29 | if(newrel.getSourceNode().isEqual(node)||newrel.getTargetNode().isEqual(node)){ 30 | if(exists(newrel)){ 31 | System.out.println("newrel already exists; return false."); 32 | return false; 33 | } 34 | else{ 35 | return addRel(newrel); 36 | } 37 | } 38 | else{ 39 | System.out.println("newrel does not match to the node; return false."); 40 | System.out.printf("newrel=%s, node=%s\n",newrel.toString(),node.toString()); 41 | return false; 42 | } 43 | } 44 | protected boolean exists(BinaryRelation newrel){ 45 | // case 1: doesn't match to node 46 | if(!newrel.getSourceNode().isEqual(node)&&!newrel.getTargetNode().isEqual(node)) 47 | return false; 48 | // case 2: match to source node 49 | if(newrel.getSourceNode().isEqual(node)){ 50 | if(out_rels.containsKey(newrel.getTargetNode().getUniqueId())){ 51 | BinaryRelation outrel = out_rels.get(newrel.getTargetNode().getUniqueId()); 52 | if(!outrel.isConsistent(newrel)) 53 | System.out.println("WARNING: Trying to insert an inconsistent new BinaryRelation."); 54 | return true; 55 | } 56 | } 57 | // case 3: match to target node 58 | if(newrel.getTargetNode().isEqual(node)){ 59 | if(in_rels.containsKey(newrel.getSourceNode().getUniqueId())){ 60 | BinaryRelation inrel = in_rels.get(newrel.getSourceNode().getUniqueId()); 61 | if(!inrel.isConsistent(newrel)) 62 | System.out.println("WARNING: Trying to insert an inconsistent new BinaryRelation."); 63 | return true; 64 | } 65 | } 66 | return false; 67 | } 68 | 69 | public int getDeg_in() { 70 | return in_rels.size(); 71 | } 72 | 73 | public int getDeg_out() { 74 | return out_rels.size(); 75 | } 76 | 77 | public int getDeg() { 78 | return getDeg_in()+getDeg_out(); 79 | } 80 | 81 | public Node getNode() { 82 | return node; 83 | } 84 | 85 | public HashMap> getIn_rels() { 86 | return in_rels; 87 | } 88 | 89 | public HashMap> getOut_rels() { 90 | return out_rels; 91 | }*/ 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/datastruct/Temporal/TemporalNode.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.datastruct.Temporal; 2 | 3 | import edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation; 4 | import edu.illinois.cs.cogcomp.temporal.datastruct.GeneralGraph.AugmentedNode; 5 | 6 | import java.util.HashSet; 7 | 8 | /** 9 | * Created by chuchu on 12/20/17. 10 | */ 11 | public class TemporalNode extends AugmentedNode{ 12 | protected int sentId = -1; 13 | protected TextAnnotation ta; 14 | protected HashSet equivalentNodes = new HashSet<>();//valid only when equivalentNodeHead=self 15 | protected TemporalNode equivalentNodeHead; 16 | 17 | public TemporalNode(int nodeId, String nodeType, String text, int sentId) { 18 | super(nodeId, nodeType, text); 19 | this.sentId = sentId; 20 | equivalentNodeHead = this; 21 | } 22 | 23 | public TemporalNode(TemporalNode other){ 24 | // Note TextAnnotation is not deeply copied 25 | // this will also lose info about equivalentNodes 26 | this(other.nodeId,other.nodeType,other.text,other.sentId); 27 | ta = other.ta; 28 | } 29 | 30 | public int getSentId() { 31 | return sentId; 32 | } 33 | 34 | public TextAnnotation getTa() { 35 | return ta; 36 | } 37 | 38 | public void addEquivalentNode(TemporalNode node){ 39 | equivalentNodes.add(node); 40 | } 41 | 42 | public void setEquivalentNodeHead(TemporalNode equivalentNodeHead) { 43 | this.equivalentNodeHead = equivalentNodeHead; 44 | } 45 | 46 | public TemporalNode getEquivalentNodeHead() { 47 | return equivalentNodeHead; 48 | } 49 | 50 | public static void setEquivalentNodes(TemporalNode n1, TemporalNode n2){ 51 | if(n1.compare(n2)>0){// make sure n1 < n2 52 | TemporalNode n = n1; 53 | n1 = n2; 54 | n2 = n; 55 | } 56 | while(!n1.getEquivalentNodeHead().isEqual(n1)) 57 | n1 = n1.getEquivalentNodeHead(); 58 | n1.addEquivalentNode(n2); 59 | n2.setEquivalentNodeHead(n1); 60 | } 61 | 62 | public static void main(String[] args) { 63 | TemporalNode n1 = new TemporalNode(1,"test","",0); 64 | TemporalNode n2 = new TemporalNode(2,"test","",0); 65 | TemporalNode n3 = new TemporalNode(3,"test","",0); 66 | TemporalNode n4 = new TemporalNode(4,"test","",0); 67 | setEquivalentNodes(n1,n2); 68 | setEquivalentNodes(n1,n3); 69 | setEquivalentNodes(n2,n4); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/datastruct/Temporal/TemporalRelation_TT.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.datastruct.Temporal; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public class TemporalRelation_TT extends TemporalRelation{ 6 | public TemporalRelation_TT(TimexTemporalNode sourceNode, TimexTemporalNode targetNode, TemporalRelType relType, myTemporalDocument doc) { 7 | super(sourceNode, targetNode, relType, doc); 8 | } 9 | public TemporalRelation_TT(TemporalRelation_TT other, myTemporalDocument doc){ 10 | this(other.getSourceNode(),other.getTargetNode(),other.getRelType(),doc); 11 | } 12 | 13 | public boolean isSourceFirstInText(){ 14 | return getSourceNode().getTokenSpan().getFirst() 0) 54 | { 55 | if (verbSrls.length == 1) 56 | { 57 | __id = "SRL Same Sent:single"; 58 | __value = "true"; 59 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 60 | } 61 | else 62 | { 63 | if (verbSrls.length == 2) 64 | { 65 | __id = "SRL Same Sent:double"; 66 | __value = "true"; 67 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 68 | } 69 | else 70 | { 71 | __id = "SRL Same Sent:multiple"; 72 | __value = "true"; 73 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 74 | } 75 | } 76 | } 77 | return __result; 78 | } 79 | 80 | public FeatureVector[] classify(Object[] examples) 81 | { 82 | if (!(examples instanceof EventTokenCandidate[])) 83 | { 84 | String type = examples == null ? "null" : examples.getClass().getName(); 85 | System.err.println("Classifier 'VerbSRLFeats(EventTokenCandidate)' defined on line 140 of eventDetector.lbj received '" + type + "' as input."); 86 | new Exception().printStackTrace(); 87 | System.exit(1); 88 | } 89 | 90 | return super.classify(examples); 91 | } 92 | 93 | public int hashCode() { return "VerbSRLFeats".hashCode(); } 94 | public boolean equals(Object o) { return o instanceof VerbSRLFeats; } 95 | } 96 | 97 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/EventDetector/isIntention.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B88000000000000000B49CC2E4E2A4D294558CC26FCCB294DCB29CCCFC3D07D23023242F3B353FC9313F25233521182F9A529CA9A063ABA05DA0045E5A5497A0A4E91CA0E9E712EAE712E9EFE765A4A0AD0252A78C6C86A5B24D2000CC7D6E1B06000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.EventDetector; 5 | 6 | import edu.illinois.cs.cogcomp.core.datastructures.IntPair; 7 | import edu.illinois.cs.cogcomp.core.datastructures.Pair; 8 | import edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent; 9 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 10 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 11 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 12 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 13 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 14 | import edu.illinois.cs.cogcomp.temporal.TemporalRelationExtractor.EventTokenCandidate; 15 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 16 | import edu.illinois.cs.cogcomp.temporal.configurations.SignalWordSet; 17 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TimexTemporalNode; 18 | import java.lang.Object; 19 | import java.util.HashSet; 20 | import java.util.Iterator; 21 | import java.util.List; 22 | 23 | 24 | public class isIntention extends Classifier 25 | { 26 | public isIntention() 27 | { 28 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.EventDetector"; 29 | name = "isIntention"; 30 | } 31 | 32 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.TemporalRelationExtractor.EventTokenCandidate"; } 33 | public String getOutputType() { return "discrete"; } 34 | 35 | 36 | public FeatureVector classify(Object __example) 37 | { 38 | return new FeatureVector(featureValue(__example)); 39 | } 40 | 41 | public Feature featureValue(Object __example) 42 | { 43 | String result = discreteValue(__example); 44 | return new DiscretePrimitiveStringFeature(containingPackage, name, "", result, valueIndexOf(result), (short) allowableValues().length); 45 | } 46 | 47 | public String discreteValue(Object __example) 48 | { 49 | if (!(__example instanceof EventTokenCandidate)) 50 | { 51 | String type = __example == null ? "null" : __example.getClass().getName(); 52 | System.err.println("Classifier 'isIntention(EventTokenCandidate)' defined on line 106 of eventDetector.lbj received '" + type + "' as input."); 53 | new Exception().printStackTrace(); 54 | System.exit(1); 55 | } 56 | 57 | EventTokenCandidate etc = (EventTokenCandidate) __example; 58 | 59 | return "" + ("IS INTENTION:" + etc.isIntention()); 60 | } 61 | 62 | public FeatureVector[] classify(Object[] examples) 63 | { 64 | if (!(examples instanceof EventTokenCandidate[])) 65 | { 66 | String type = examples == null ? "null" : examples.getClass().getName(); 67 | System.err.println("Classifier 'isIntention(EventTokenCandidate)' defined on line 106 of eventDetector.lbj received '" + type + "' as input."); 68 | new Exception().printStackTrace(); 69 | System.exit(1); 70 | } 71 | 72 | return super.classify(examples); 73 | } 74 | 75 | public int hashCode() { return "isIntention".hashCode(); } 76 | public boolean equals(Object o) { return o instanceof isIntention; } 77 | } 78 | 79 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/EventDetector/isReporting.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B88000000000000000B49CC2E4E2A4D294558CC2E0A4D28CF2A29CCCB47D07D2B4DCB2909CFCE4DC37E4CCB49CC49440AC7A6942B6A28D8EA245B2005979615E92829760B2409B608F705887AF9BB592928638498E12B13A96DA05B0005ED60C1806000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.EventDetector; 5 | 6 | import edu.illinois.cs.cogcomp.core.datastructures.IntPair; 7 | import edu.illinois.cs.cogcomp.core.datastructures.Pair; 8 | import edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent; 9 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 10 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 11 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 12 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 13 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 14 | import edu.illinois.cs.cogcomp.temporal.TemporalRelationExtractor.EventTokenCandidate; 15 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 16 | import edu.illinois.cs.cogcomp.temporal.configurations.SignalWordSet; 17 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TimexTemporalNode; 18 | import java.lang.Object; 19 | import java.util.HashSet; 20 | import java.util.Iterator; 21 | import java.util.List; 22 | 23 | 24 | public class isReporting extends Classifier 25 | { 26 | public isReporting() 27 | { 28 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.EventDetector"; 29 | name = "isReporting"; 30 | } 31 | 32 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.TemporalRelationExtractor.EventTokenCandidate"; } 33 | public String getOutputType() { return "discrete"; } 34 | 35 | 36 | public FeatureVector classify(Object __example) 37 | { 38 | return new FeatureVector(featureValue(__example)); 39 | } 40 | 41 | public Feature featureValue(Object __example) 42 | { 43 | String result = discreteValue(__example); 44 | return new DiscretePrimitiveStringFeature(containingPackage, name, "", result, valueIndexOf(result), (short) allowableValues().length); 45 | } 46 | 47 | public String discreteValue(Object __example) 48 | { 49 | if (!(__example instanceof EventTokenCandidate)) 50 | { 51 | String type = __example == null ? "null" : __example.getClass().getName(); 52 | System.err.println("Classifier 'isReporting(EventTokenCandidate)' defined on line 101 of eventDetector.lbj received '" + type + "' as input."); 53 | new Exception().printStackTrace(); 54 | System.exit(1); 55 | } 56 | 57 | EventTokenCandidate etc = (EventTokenCandidate) __example; 58 | 59 | return "" + ("IS REPORTING:" + etc.isReporting()); 60 | } 61 | 62 | public FeatureVector[] classify(Object[] examples) 63 | { 64 | if (!(examples instanceof EventTokenCandidate[])) 65 | { 66 | String type = examples == null ? "null" : examples.getClass().getName(); 67 | System.err.println("Classifier 'isReporting(EventTokenCandidate)' defined on line 101 of eventDetector.lbj received '" + type + "' as input."); 68 | new Exception().printStackTrace(); 69 | System.exit(1); 70 | } 71 | 72 | return super.classify(examples); 73 | } 74 | 75 | public int hashCode() { return "isReporting".hashCode(); } 76 | public boolean equals(Object o) { return o instanceof isReporting; } 77 | } 78 | 79 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls/BiasTermTemprel.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B88000000000000000B49CC2E4E2A4D2945507ACC4C2E094D2ACD094DCD282A4DC1D001D9F549893149A939852999F971FEAEAA09A9AA9A063ABA05DA004D15A5497A0A49404D4A46DA05B000CEDD18864000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls; 5 | 6 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 7 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 8 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 9 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 10 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 11 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 12 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE; 14 | import java.lang.Object; 15 | import java.util.HashSet; 16 | import java.util.Iterator; 17 | import java.util.List; 18 | 19 | 20 | public class BiasTermTemprel extends Classifier 21 | { 22 | public BiasTermTemprel() 23 | { 24 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls"; 25 | name = "BiasTermTemprel"; 26 | } 27 | 28 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE"; } 29 | public String getOutputType() { return "discrete"; } 30 | 31 | 32 | public FeatureVector classify(Object __example) 33 | { 34 | return new FeatureVector(featureValue(__example)); 35 | } 36 | 37 | public Feature featureValue(Object __example) 38 | { 39 | String result = discreteValue(__example); 40 | return new DiscretePrimitiveStringFeature(containingPackage, name, "", result, valueIndexOf(result), (short) allowableValues().length); 41 | } 42 | 43 | public String discreteValue(Object __example) 44 | { 45 | if (!(__example instanceof TemporalRelation_EE)) 46 | { 47 | String type = __example == null ? "null" : __example.getClass().getName(); 48 | System.err.println("Classifier 'BiasTermTemprel(TemporalRelation_EE)' defined on line 174 of eeTempRelCls.lbj received '" + type + "' as input."); 49 | new Exception().printStackTrace(); 50 | System.exit(1); 51 | } 52 | 53 | TemporalRelation_EE ee = (TemporalRelation_EE) __example; 54 | 55 | return "bias"; 56 | } 57 | 58 | public FeatureVector[] classify(Object[] examples) 59 | { 60 | if (!(examples instanceof TemporalRelation_EE[])) 61 | { 62 | String type = examples == null ? "null" : examples.getClass().getName(); 63 | System.err.println("Classifier 'BiasTermTemprel(TemporalRelation_EE)' defined on line 174 of eeTempRelCls.lbj received '" + type + "' as input."); 64 | new Exception().printStackTrace(); 65 | System.exit(1); 66 | } 67 | 68 | return super.classify(examples); 69 | } 70 | 71 | public int hashCode() { return "BiasTermTemprel".hashCode(); } 72 | public boolean equals(Object o) { return o instanceof BiasTermTemprel; } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls/ClosestTimexFeats.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B8800000000000000056D81CA02C030144F7568280D026E30A5D39454F2E14B7790A3AD04BD84675C284FFDD4B873F6BCCCB97B73F27D845E20BD638054B6FD178D1D9A4E53BB7688EAD31B57AE34F79AA20960BE51E38DB396EC45CD7241B9458D705FF526A4C1491D96880F9E848EC31BEF79E44CBB1FD219F419D6C9C19386E6C4AF22CE588CEF4B54685ECA3BDFCC2A086C71B4C881FB08BF31D783D000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls; 5 | 6 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 7 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 8 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 9 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 10 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 11 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 12 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE; 14 | import java.lang.Object; 15 | import java.util.HashSet; 16 | import java.util.Iterator; 17 | import java.util.List; 18 | 19 | 20 | public class ClosestTimexFeats extends Classifier 21 | { 22 | public ClosestTimexFeats() 23 | { 24 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls"; 25 | name = "ClosestTimexFeats"; 26 | } 27 | 28 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE"; } 29 | public String getOutputType() { return "discrete%"; } 30 | 31 | public FeatureVector classify(Object __example) 32 | { 33 | if (!(__example instanceof TemporalRelation_EE)) 34 | { 35 | String type = __example == null ? "null" : __example.getClass().getName(); 36 | System.err.println("Classifier 'ClosestTimexFeats(TemporalRelation_EE)' defined on line 121 of eeTempRelCls.lbj received '" + type + "' as input."); 37 | new Exception().printStackTrace(); 38 | System.exit(1); 39 | } 40 | 41 | TemporalRelation_EE ee = (TemporalRelation_EE) __example; 42 | 43 | FeatureVector __result; 44 | __result = new FeatureVector(); 45 | String __id; 46 | String __value; 47 | 48 | HashSet feats = ee.getClosestTimexFeats(); 49 | Iterator iter = feats.iterator(); 50 | while (iter.hasNext()) 51 | { 52 | __id = "" + ("ClosestTimexFeats:" + iter.next()); 53 | __value = "true"; 54 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 55 | } 56 | return __result; 57 | } 58 | 59 | public FeatureVector[] classify(Object[] examples) 60 | { 61 | if (!(examples instanceof TemporalRelation_EE[])) 62 | { 63 | String type = examples == null ? "null" : examples.getClass().getName(); 64 | System.err.println("Classifier 'ClosestTimexFeats(TemporalRelation_EE)' defined on line 121 of eeTempRelCls.lbj received '" + type + "' as input."); 65 | new Exception().printStackTrace(); 66 | System.exit(1); 67 | } 68 | 69 | return super.classify(examples); 70 | } 71 | 72 | public int hashCode() { return "ClosestTimexFeats".hashCode(); } 73 | public boolean equals(Object o) { return o instanceof ClosestTimexFeats; } 74 | } 75 | 76 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls/CorpusStats.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B8800000000000000058F8BBE028040154F756A40D88A53A591A4B15B3368C0CE08423EE0EE3C6C8FFE2175944260BCB77EC4E4EA124E3E906326A5F67FE0D9D8E047965C02FE881D532A3FC2302A8165338B3821F503183178C0BEEAF4ACCB0AA4C01C4342CAC199F48B16DEBFB0D5D77F4FE0D8E29DB22B38CA250B4AD21C23958289C7906E14BFB8802D110A7DDF764D813163C800161F008D2AB372C2574FA63E41E1F405A553BDC87100000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls; 5 | 6 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 7 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 8 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 9 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 10 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 11 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 12 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE; 14 | import java.lang.Object; 15 | import java.util.HashSet; 16 | import java.util.Iterator; 17 | import java.util.List; 18 | 19 | 20 | public class CorpusStats extends Classifier 21 | { 22 | public CorpusStats() 23 | { 24 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls"; 25 | name = "CorpusStats"; 26 | } 27 | 28 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE"; } 29 | public String getOutputType() { return "real[]"; } 30 | 31 | public FeatureVector classify(Object __example) 32 | { 33 | if (!(__example instanceof TemporalRelation_EE)) 34 | { 35 | String type = __example == null ? "null" : __example.getClass().getName(); 36 | System.err.println("Classifier 'CorpusStats(TemporalRelation_EE)' defined on line 109 of eeTempRelCls.lbj received '" + type + "' as input."); 37 | new Exception().printStackTrace(); 38 | System.exit(1); 39 | } 40 | 41 | TemporalRelation_EE ee = (TemporalRelation_EE) __example; 42 | 43 | FeatureVector __result; 44 | __result = new FeatureVector(); 45 | int __featureIndex = 0; 46 | double __value; 47 | 48 | double total = ee.c_before + ee.c_after + ee.c_vague + ee.c_equal + ee.c_includes + ee.c_included; 49 | __value = 1.0d * ee.c_before / total; 50 | __result.addFeature(new RealArrayStringFeature(this.containingPackage, this.name, "", __value, __featureIndex++, 0)); 51 | __value = 1.0d * ee.c_after / total; 52 | __result.addFeature(new RealArrayStringFeature(this.containingPackage, this.name, "", __value, __featureIndex++, 0)); 53 | __value = 1.0d * ee.c_includes / total; 54 | __result.addFeature(new RealArrayStringFeature(this.containingPackage, this.name, "", __value, __featureIndex++, 0)); 55 | __value = 1.0d * ee.c_included / total; 56 | __result.addFeature(new RealArrayStringFeature(this.containingPackage, this.name, "", __value, __featureIndex++, 0)); 57 | __value = 1.0d * ee.c_equal / total; 58 | __result.addFeature(new RealArrayStringFeature(this.containingPackage, this.name, "", __value, __featureIndex++, 0)); 59 | __value = 1.0d * ee.c_vague / total; 60 | __result.addFeature(new RealArrayStringFeature(this.containingPackage, this.name, "", __value, __featureIndex++, 0)); 61 | __value = Math.log(total); 62 | __result.addFeature(new RealArrayStringFeature(this.containingPackage, this.name, "", __value, __featureIndex++, 0)); 63 | 64 | for (int __i = 0; __i < __result.featuresSize(); ++__i) 65 | __result.getFeature(__i).setArrayLength(__featureIndex); 66 | 67 | return __result; 68 | } 69 | 70 | public double[] realValueArray(Object __example) 71 | { 72 | return classify(__example).realValueArray(); 73 | } 74 | 75 | public FeatureVector[] classify(Object[] examples) 76 | { 77 | if (!(examples instanceof TemporalRelation_EE[])) 78 | { 79 | String type = examples == null ? "null" : examples.getClass().getName(); 80 | System.err.println("Classifier 'CorpusStats(TemporalRelation_EE)' defined on line 109 of eeTempRelCls.lbj received '" + type + "' as input."); 81 | new Exception().printStackTrace(); 82 | System.exit(1); 83 | } 84 | 85 | return super.classify(examples); 86 | } 87 | 88 | public int hashCode() { return "CorpusStats".hashCode(); } 89 | public boolean equals(Object o) { return o instanceof CorpusStats; } 90 | } 91 | 92 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls/CoveringSRL.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B88000000000000000D8F81CA028050154F75E23B252A0479614B887BB8616E6222E16A79014D72E39042AF7F42232338CDECCD37FCC4A99D4A663C3E90B13756D95979D78B572261599A3EC346E17399925B2502D5CA6E8B1C2B4B4882FED8049F18066078C50D3D9CB6CA9E36D0930DA0208CEC88BBCFD432A6B2E3B264D0AB9E6532C892ECDE04BEF704EDF5D6FCF05C38E8F61BEE2DDF9C3DE9DE24239F0CBF300E806DFB6B8100000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls; 5 | 6 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 7 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 8 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 9 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 10 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 11 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 12 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE; 14 | import java.lang.Object; 15 | import java.util.HashSet; 16 | import java.util.Iterator; 17 | import java.util.List; 18 | 19 | 20 | public class CoveringSRL extends Classifier 21 | { 22 | public CoveringSRL() 23 | { 24 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls"; 25 | name = "CoveringSRL"; 26 | } 27 | 28 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE"; } 29 | public String getOutputType() { return "discrete[]"; } 30 | 31 | public FeatureVector classify(Object __example) 32 | { 33 | if (!(__example instanceof TemporalRelation_EE)) 34 | { 35 | String type = __example == null ? "null" : __example.getClass().getName(); 36 | System.err.println("Classifier 'CoveringSRL(TemporalRelation_EE)' defined on line 163 of eeTempRelCls.lbj received '" + type + "' as input."); 37 | new Exception().printStackTrace(); 38 | System.exit(1); 39 | } 40 | 41 | TemporalRelation_EE ee = (TemporalRelation_EE) __example; 42 | 43 | FeatureVector __result; 44 | __result = new FeatureVector(); 45 | int __featureIndex = 0; 46 | String __value; 47 | 48 | __value = "" + ("E1 Covering E2:" + (ee.e1_covering_e2 ? "Yes" : "No")); 49 | __result.addFeature(new DiscreteArrayStringFeature(this.containingPackage, this.name, "", __value, valueIndexOf(__value), (short) 0, __featureIndex++, 0)); 50 | __value = "" + ("E1 Covering E2 Type:" + ee.e1_covering_e2_type); 51 | __result.addFeature(new DiscreteArrayStringFeature(this.containingPackage, this.name, "", __value, valueIndexOf(__value), (short) 0, __featureIndex++, 0)); 52 | __value = "" + ("E1 Covered by E2:" + (ee.e2_covering_e1 ? "Yes" : "No")); 53 | __result.addFeature(new DiscreteArrayStringFeature(this.containingPackage, this.name, "", __value, valueIndexOf(__value), (short) 0, __featureIndex++, 0)); 54 | __value = "" + ("E1 Covered by E2 Type:" + ee.e2_covering_e1_type); 55 | __result.addFeature(new DiscreteArrayStringFeature(this.containingPackage, this.name, "", __value, valueIndexOf(__value), (short) 0, __featureIndex++, 0)); 56 | __value = "" + ("E1_E2 Covering" + (ee.e1_covering_e2 ? "Yes" : "No") + ":" + (ee.e2_covering_e1 ? "Yes" : "No")); 57 | __result.addFeature(new DiscreteArrayStringFeature(this.containingPackage, this.name, "", __value, valueIndexOf(__value), (short) 0, __featureIndex++, 0)); 58 | 59 | for (int __i = 0; __i < __result.featuresSize(); ++__i) 60 | __result.getFeature(__i).setArrayLength(__featureIndex); 61 | 62 | return __result; 63 | } 64 | 65 | public String[] discreteValueArray(Object __example) 66 | { 67 | return classify(__example).discreteValueArray(); 68 | } 69 | 70 | public FeatureVector[] classify(Object[] examples) 71 | { 72 | if (!(examples instanceof TemporalRelation_EE[])) 73 | { 74 | String type = examples == null ? "null" : examples.getClass().getName(); 75 | System.err.println("Classifier 'CoveringSRL(TemporalRelation_EE)' defined on line 163 of eeTempRelCls.lbj received '" + type + "' as input."); 76 | new Exception().printStackTrace(); 77 | System.exit(1); 78 | } 79 | 80 | return super.classify(examples); 81 | } 82 | 83 | public int hashCode() { return "CoveringSRL".hashCode(); } 84 | public boolean equals(Object o) { return o instanceof CoveringSRL; } 85 | } 86 | 87 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls/IsIntention.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B8800000000000000059F81BA038030168F55E8041419A0664BD2D9C1C5C1A579E429AEF411C625298D5A4FDDB170BD82E0579B38BBF8FEEFB6A535B685C682739B4B096B55238217F782D2AB31A313C0AAC232024ADF69E549D3D1532158A604848E0E6F1FD06FCAA7D53689601EE6905EF54B41AD5D11DBA25D14847E2F28C0C6217BE523F94E3329FC94309604C2B4CF7E256411503D337426718164921B241B0D57BAB7CF40C7140C7D8029A6AE8F323444C6DC5A7F700BC182254AC100000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls; 5 | 6 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 7 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 8 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 9 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 10 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 11 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 12 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE; 14 | import java.lang.Object; 15 | import java.util.HashSet; 16 | import java.util.Iterator; 17 | import java.util.List; 18 | 19 | 20 | public class IsIntention extends Classifier 21 | { 22 | public IsIntention() 23 | { 24 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls"; 25 | name = "IsIntention"; 26 | } 27 | 28 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE"; } 29 | public String getOutputType() { return "discrete%"; } 30 | 31 | public FeatureVector classify(Object __example) 32 | { 33 | if (!(__example instanceof TemporalRelation_EE)) 34 | { 35 | String type = __example == null ? "null" : __example.getClass().getName(); 36 | System.err.println("Classifier 'IsIntention(TemporalRelation_EE)' defined on line 152 of eeTempRelCls.lbj received '" + type + "' as input."); 37 | new Exception().printStackTrace(); 38 | System.exit(1); 39 | } 40 | 41 | TemporalRelation_EE ee = (TemporalRelation_EE) __example; 42 | 43 | FeatureVector __result; 44 | __result = new FeatureVector(); 45 | String __id; 46 | String __value; 47 | 48 | EventTemporalNode e1 = ee.getSourceNode(); 49 | EventTemporalNode e2 = ee.getTargetNode(); 50 | boolean e1IsIntention = e1.isIntention(); 51 | boolean e2IsIntention = e2.isIntention(); 52 | __id = "" + ("E1 IsIntention:" + (e1IsIntention ? "Yes" : "No")); 53 | __value = "true"; 54 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 55 | __id = "" + ("E2 IsIntention:" + (e2IsIntention ? "Yes" : "No")); 56 | __value = "true"; 57 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 58 | __id = "" + ("E1_E2 IsIntention" + (e1IsIntention ? "Yes" : "No") + ":" + (e2IsIntention ? "Yes" : "No")); 59 | __value = "true"; 60 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 61 | return __result; 62 | } 63 | 64 | public FeatureVector[] classify(Object[] examples) 65 | { 66 | if (!(examples instanceof TemporalRelation_EE[])) 67 | { 68 | String type = examples == null ? "null" : examples.getClass().getName(); 69 | System.err.println("Classifier 'IsIntention(TemporalRelation_EE)' defined on line 152 of eeTempRelCls.lbj received '" + type + "' as input."); 70 | new Exception().printStackTrace(); 71 | System.exit(1); 72 | } 73 | 74 | return super.classify(examples); 75 | } 76 | 77 | public int hashCode() { return "IsIntention".hashCode(); } 78 | public boolean equals(Object o) { return o instanceof IsIntention; } 79 | } 80 | 81 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls/IsReporting.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B8800000000000000059F81BA038034154F75E118282251CC86B5A39347170BE2D9425DB880639294CE25AFFED838D641786797909C1ECDBFA9EC4DA161B1A39920775AD672BD0A4CDCD554F50A716B352BAC232024ADF69E949D302DE444EAA10121A38BFF8B58D3BA147D81F538077B682FF0A5A0DE6E48E559AE124A379754646398B3FA99F42F509C794A1843026952EF27923A882897CC198D506815A4C275C2477A5D30EB20EB220EFF8029A6EE8F1A3444CEF94A7DB1049647FD1AC100000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls; 5 | 6 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 7 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 8 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 9 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 10 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 11 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 12 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE; 14 | import java.lang.Object; 15 | import java.util.HashSet; 16 | import java.util.Iterator; 17 | import java.util.List; 18 | 19 | 20 | public class IsReporting extends Classifier 21 | { 22 | public IsReporting() 23 | { 24 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls"; 25 | name = "IsReporting"; 26 | } 27 | 28 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE"; } 29 | public String getOutputType() { return "discrete%"; } 30 | 31 | public FeatureVector classify(Object __example) 32 | { 33 | if (!(__example instanceof TemporalRelation_EE)) 34 | { 35 | String type = __example == null ? "null" : __example.getClass().getName(); 36 | System.err.println("Classifier 'IsReporting(TemporalRelation_EE)' defined on line 141 of eeTempRelCls.lbj received '" + type + "' as input."); 37 | new Exception().printStackTrace(); 38 | System.exit(1); 39 | } 40 | 41 | TemporalRelation_EE ee = (TemporalRelation_EE) __example; 42 | 43 | FeatureVector __result; 44 | __result = new FeatureVector(); 45 | String __id; 46 | String __value; 47 | 48 | EventTemporalNode e1 = ee.getSourceNode(); 49 | EventTemporalNode e2 = ee.getTargetNode(); 50 | boolean e1IsReporting = e1.isReporting(); 51 | boolean e2IsReporting = e2.isReporting(); 52 | __id = "" + ("E1 IsReporting:" + (e1IsReporting ? "Yes" : "No")); 53 | __value = "true"; 54 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 55 | __id = "" + ("E2 IsReporting:" + (e2IsReporting ? "Yes" : "No")); 56 | __value = "true"; 57 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 58 | __id = "" + ("E1_E2 IsReporting" + (e1IsReporting ? "Yes" : "No") + ":" + (e2IsReporting ? "Yes" : "No")); 59 | __value = "true"; 60 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 61 | return __result; 62 | } 63 | 64 | public FeatureVector[] classify(Object[] examples) 65 | { 66 | if (!(examples instanceof TemporalRelation_EE[])) 67 | { 68 | String type = examples == null ? "null" : examples.getClass().getName(); 69 | System.err.println("Classifier 'IsReporting(TemporalRelation_EE)' defined on line 141 of eeTempRelCls.lbj received '" + type + "' as input."); 70 | new Exception().printStackTrace(); 71 | System.exit(1); 72 | } 73 | 74 | return super.classify(examples); 75 | } 76 | 77 | public int hashCode() { return "IsReporting".hashCode(); } 78 | public boolean equals(Object o) { return o instanceof IsReporting; } 79 | } 80 | 81 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls/IsVerbSRL.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B88000000000000000D8FCD4B02803C1600FFA2FF60182250EE865472F014870590A398F2F012CAD26B9D52AFEE9E1C798A8CBC6C6BFD3B76BAA635A685C29E06E40D5421F1D9417DB92D9B881227B5B299581210E2D6754F0A0FE096B7119AA040F967DE9FAF20B98A64798E67D1773FD82F186A9BE67CE961A4904E2BDBB6876472DFE467BECC861E8B4B8D19C6488987EF6E9FF2F602D08858EF8FDC081974EC4B07F4CEC03C820261926E6B3B5DD06C03FF803F9F16F3B96EFF67B74C6E77C3F50154F1EA16C100000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls; 5 | 6 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 7 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 8 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 9 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 10 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 11 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 12 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE; 14 | import java.lang.Object; 15 | import java.util.HashSet; 16 | import java.util.Iterator; 17 | import java.util.List; 18 | 19 | 20 | public class IsVerbSRL extends Classifier 21 | { 22 | public IsVerbSRL() 23 | { 24 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls"; 25 | name = "IsVerbSRL"; 26 | } 27 | 28 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE"; } 29 | public String getOutputType() { return "discrete%"; } 30 | 31 | public FeatureVector classify(Object __example) 32 | { 33 | if (!(__example instanceof TemporalRelation_EE)) 34 | { 35 | String type = __example == null ? "null" : __example.getClass().getName(); 36 | System.err.println("Classifier 'IsVerbSRL(TemporalRelation_EE)' defined on line 130 of eeTempRelCls.lbj received '" + type + "' as input."); 37 | new Exception().printStackTrace(); 38 | System.exit(1); 39 | } 40 | 41 | TemporalRelation_EE ee = (TemporalRelation_EE) __example; 42 | 43 | FeatureVector __result; 44 | __result = new FeatureVector(); 45 | String __id; 46 | String __value; 47 | 48 | EventTemporalNode e1 = ee.getSourceNode(); 49 | EventTemporalNode e2 = ee.getTargetNode(); 50 | boolean e1IsVerbSRL = e1.getVerb_srl() != null; 51 | boolean e2IsVerbSRL = e2.getVerb_srl() != null; 52 | __id = "" + ("E1 IsVerbSRL:" + (e1IsVerbSRL ? "Yes" : "No")); 53 | __value = "true"; 54 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 55 | __id = "" + ("E2 IsVerbSRL:" + (e2IsVerbSRL ? "Yes" : "No")); 56 | __value = "true"; 57 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 58 | __id = "" + ("E1_E2 IsVerbSRL" + (e1IsVerbSRL ? "Yes" : "No") + ":" + (e2IsVerbSRL ? "Yes" : "No")); 59 | __value = "true"; 60 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 61 | return __result; 62 | } 63 | 64 | public FeatureVector[] classify(Object[] examples) 65 | { 66 | if (!(examples instanceof TemporalRelation_EE[])) 67 | { 68 | String type = examples == null ? "null" : examples.getClass().getName(); 69 | System.err.println("Classifier 'IsVerbSRL(TemporalRelation_EE)' defined on line 130 of eeTempRelCls.lbj received '" + type + "' as input."); 70 | new Exception().printStackTrace(); 71 | System.exit(1); 72 | } 73 | 74 | return super.classify(examples); 75 | } 76 | 77 | public int hashCode() { return "IsVerbSRL".hashCode(); } 78 | public boolean equals(Object o) { return o instanceof IsVerbSRL; } 79 | } 80 | 81 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls/Label.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B88000000000000000B49CC2E4E2A4D294550F94C4A4DC1D8094DCD28CF2A4CC90A4DC94C29CCCFCB877575584D45D450B1D558A6500AAB2D2AC302F5F2D35B402AE53DA51A61050C7599B34000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls; 5 | 6 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 7 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 8 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 9 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 10 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 11 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 12 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE; 14 | import java.lang.Object; 15 | import java.util.HashSet; 16 | import java.util.Iterator; 17 | import java.util.List; 18 | 19 | 20 | public class Label extends Classifier 21 | { 22 | public Label() 23 | { 24 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls"; 25 | name = "Label"; 26 | } 27 | 28 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE"; } 29 | public String getOutputType() { return "discrete"; } 30 | 31 | 32 | public FeatureVector classify(Object __example) 33 | { 34 | return new FeatureVector(featureValue(__example)); 35 | } 36 | 37 | public Feature featureValue(Object __example) 38 | { 39 | String result = discreteValue(__example); 40 | return new DiscretePrimitiveStringFeature(containingPackage, name, "", result, valueIndexOf(result), (short) allowableValues().length); 41 | } 42 | 43 | public String discreteValue(Object __example) 44 | { 45 | if (!(__example instanceof TemporalRelation_EE)) 46 | { 47 | String type = __example == null ? "null" : __example.getClass().getName(); 48 | System.err.println("Classifier 'Label(TemporalRelation_EE)' defined on line 13 of eeTempRelCls.lbj received '" + type + "' as input."); 49 | new Exception().printStackTrace(); 50 | System.exit(1); 51 | } 52 | 53 | TemporalRelation_EE ee = (TemporalRelation_EE) __example; 54 | 55 | return "" + (ee.getLabel()); 56 | } 57 | 58 | public FeatureVector[] classify(Object[] examples) 59 | { 60 | if (!(examples instanceof TemporalRelation_EE[])) 61 | { 62 | String type = examples == null ? "null" : examples.getClass().getName(); 63 | System.err.println("Classifier 'Label(TemporalRelation_EE)' defined on line 13 of eeTempRelCls.lbj received '" + type + "' as input."); 64 | new Exception().printStackTrace(); 65 | System.exit(1); 66 | } 67 | 68 | return super.classify(examples); 69 | } 70 | 71 | public int hashCode() { return "Label".hashCode(); } 72 | public boolean equals(Object o) { return o instanceof Label; } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls/Lemma.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B8800000000000000057FC14B0280381600EFB2F1E9632214F89570F0BB9A14A7988091AF6128AB2D9D52CFFEDCA4158ABCE0B7F9FEDDEBCB863B60A17A33508AA29C2145735D8C2F0825AE245D9A014007ADEA9E942E18A5F822259380E0DEC4E6F51A365D539168B56CDBF54DD98622B137E84B54DD28C21E4A188034F7361DAC4FE0EE3F5A91177E4CD5092E24C613563EED9C2B56B07C9B9536A70D4F5CE782EB5A7411B5E15F482D4AF7554BF73AEF5E34B5C05A3100000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls; 5 | 6 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 7 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 8 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 9 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 10 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 11 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 12 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE; 14 | import java.lang.Object; 15 | import java.util.HashSet; 16 | import java.util.Iterator; 17 | import java.util.List; 18 | 19 | 20 | public class Lemma extends Classifier 21 | { 22 | public Lemma() 23 | { 24 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls"; 25 | name = "Lemma"; 26 | } 27 | 28 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE"; } 29 | public String getOutputType() { return "discrete[]"; } 30 | 31 | public FeatureVector classify(Object __example) 32 | { 33 | if (!(__example instanceof TemporalRelation_EE)) 34 | { 35 | String type = __example == null ? "null" : __example.getClass().getName(); 36 | System.err.println("Classifier 'Lemma(TemporalRelation_EE)' defined on line 52 of eeTempRelCls.lbj received '" + type + "' as input."); 37 | new Exception().printStackTrace(); 38 | System.exit(1); 39 | } 40 | 41 | TemporalRelation_EE ee = (TemporalRelation_EE) __example; 42 | 43 | FeatureVector __result; 44 | __result = new FeatureVector(); 45 | int __featureIndex = 0; 46 | String __value; 47 | 48 | EventTemporalNode e1 = ee.getSourceNode(); 49 | EventTemporalNode e2 = ee.getTargetNode(); 50 | __value = "" + ("E1_LEMMA:" + e1.getLemma()); 51 | __result.addFeature(new DiscreteArrayStringFeature(this.containingPackage, this.name, "", __value, valueIndexOf(__value), (short) 0, __featureIndex++, 0)); 52 | __value = "" + ("E2_LEMMA:" + e2.getLemma()); 53 | __result.addFeature(new DiscreteArrayStringFeature(this.containingPackage, this.name, "", __value, valueIndexOf(__value), (short) 0, __featureIndex++, 0)); 54 | if (e1.getLemma().equals(e2.getLemma())) 55 | { 56 | __value = "E1E2_SAME_LEMMA:YES"; 57 | __result.addFeature(new DiscreteArrayStringFeature(this.containingPackage, this.name, "", __value, valueIndexOf(__value), (short) 0, __featureIndex++, 0)); 58 | } 59 | else 60 | { 61 | __value = "E1E2_SAME_LEMMA:NO"; 62 | __result.addFeature(new DiscreteArrayStringFeature(this.containingPackage, this.name, "", __value, valueIndexOf(__value), (short) 0, __featureIndex++, 0)); 63 | } 64 | 65 | for (int __i = 0; __i < __result.featuresSize(); ++__i) 66 | __result.getFeature(__i).setArrayLength(__featureIndex); 67 | 68 | return __result; 69 | } 70 | 71 | public String[] discreteValueArray(Object __example) 72 | { 73 | return classify(__example).discreteValueArray(); 74 | } 75 | 76 | public FeatureVector[] classify(Object[] examples) 77 | { 78 | if (!(examples instanceof TemporalRelation_EE[])) 79 | { 80 | String type = examples == null ? "null" : examples.getClass().getName(); 81 | System.err.println("Classifier 'Lemma(TemporalRelation_EE)' defined on line 52 of eeTempRelCls.lbj received '" + type + "' as input."); 82 | new Exception().printStackTrace(); 83 | System.exit(1); 84 | } 85 | 86 | return super.classify(examples); 87 | } 88 | 89 | public int hashCode() { return "Lemma".hashCode(); } 90 | public boolean equals(Object o) { return o instanceof Lemma; } 91 | } 92 | 93 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls/PPHead.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B88000000000000000D7FCB3B02C0341500EFB27D080D02A2674F1341C08B8538DE2E4128D3A61A6BA96AE22EF77351A5F18A4023CDC7C9B7294A5E6D0C2AB425E20A31F26C1F4581D9DA1996B9619B212800E43DE3D594C509BD644854202C8866EED70B78D8A8ACC615F4D3E39F64DF696CAD8BBB1A522F214C4C84949A612289F8915FC527D25E94D1AEA5C96C46D4587A6FFD5BFFD57AB32FA3F11530C9B2D959E1B078103ECDDFBA65F30D740F387B58D5988285A86B9C6444CAD5D73246E8DF1E1EAE55BB377A6AF34E8E8100000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls; 5 | 6 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 7 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 8 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 9 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 10 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 11 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 12 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE; 14 | import java.lang.Object; 15 | import java.util.HashSet; 16 | import java.util.Iterator; 17 | import java.util.List; 18 | 19 | 20 | public class PPHead extends Classifier 21 | { 22 | public PPHead() 23 | { 24 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls"; 25 | name = "PPHead"; 26 | } 27 | 28 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE"; } 29 | public String getOutputType() { return "discrete%"; } 30 | 31 | public FeatureVector classify(Object __example) 32 | { 33 | if (!(__example instanceof TemporalRelation_EE)) 34 | { 35 | String type = __example == null ? "null" : __example.getClass().getName(); 36 | System.err.println("Classifier 'PPHead(TemporalRelation_EE)' defined on line 72 of eeTempRelCls.lbj received '" + type + "' as input."); 37 | new Exception().printStackTrace(); 38 | System.exit(1); 39 | } 40 | 41 | TemporalRelation_EE ee = (TemporalRelation_EE) __example; 42 | 43 | FeatureVector __result; 44 | __result = new FeatureVector(); 45 | String __id; 46 | String __value; 47 | 48 | EventTemporalNode e1 = ee.getSourceNode(); 49 | EventTemporalNode e2 = ee.getTargetNode(); 50 | __id = "" + ("E1_PP_HEAD:" + e1.getPp_head()); 51 | __value = "true"; 52 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 53 | __id = "" + ("E2_PP_HEAD:" + e2.getPp_head()); 54 | __value = "true"; 55 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 56 | if (!e1.getPp_head().equals("N/A")) 57 | { 58 | if (e1.getPp_head().equals(e2.getPp_head())) 59 | { 60 | __id = "E1E2_SAME_PP_HEAD:YES"; 61 | __value = "true"; 62 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 63 | } 64 | else 65 | { 66 | __id = "E1E2_SAME_PP_HEAD:NO"; 67 | __value = "true"; 68 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 69 | } 70 | } 71 | return __result; 72 | } 73 | 74 | public FeatureVector[] classify(Object[] examples) 75 | { 76 | if (!(examples instanceof TemporalRelation_EE[])) 77 | { 78 | String type = examples == null ? "null" : examples.getClass().getName(); 79 | System.err.println("Classifier 'PPHead(TemporalRelation_EE)' defined on line 72 of eeTempRelCls.lbj received '" + type + "' as input."); 80 | new Exception().printStackTrace(); 81 | System.exit(1); 82 | } 83 | 84 | return super.classify(examples); 85 | } 86 | 87 | public int hashCode() { return "PPHead".hashCode(); } 88 | public boolean equals(Object o) { return o instanceof PPHead; } 89 | } 90 | 91 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls/SameSynSet.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B88000000000000000B49CC2E4E2A4D2945580E4CCD4D0EACCB0E4D21D8094DCD28CF2A4CC90A4DC94C29CCCFCB877575584D45D450B1D558A658CC4350D84D45DBCC268A68260A60D4D40A400D492D2AC3505A0674F57D8F0E84FB067D01BA847D0652B658A5584DC92E45C1A4CFCF1CA2A61003E811E0998000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls; 5 | 6 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 7 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 8 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 9 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 10 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 11 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 12 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE; 14 | import java.lang.Object; 15 | import java.util.HashSet; 16 | import java.util.Iterator; 17 | import java.util.List; 18 | 19 | 20 | public class SameSynSet extends Classifier 21 | { 22 | public SameSynSet() 23 | { 24 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls"; 25 | name = "SameSynSet"; 26 | } 27 | 28 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE"; } 29 | public String getOutputType() { return "discrete"; } 30 | 31 | 32 | public FeatureVector classify(Object __example) 33 | { 34 | return new FeatureVector(featureValue(__example)); 35 | } 36 | 37 | public Feature featureValue(Object __example) 38 | { 39 | String result = discreteValue(__example); 40 | return new DiscretePrimitiveStringFeature(containingPackage, name, "", result, valueIndexOf(result), (short) allowableValues().length); 41 | } 42 | 43 | public String discreteValue(Object __example) 44 | { 45 | if (!(__example instanceof TemporalRelation_EE)) 46 | { 47 | String type = __example == null ? "null" : __example.getClass().getName(); 48 | System.err.println("Classifier 'SameSynSet(TemporalRelation_EE)' defined on line 64 of eeTempRelCls.lbj received '" + type + "' as input."); 49 | new Exception().printStackTrace(); 50 | System.exit(1); 51 | } 52 | 53 | TemporalRelation_EE ee = (TemporalRelation_EE) __example; 54 | 55 | if (ee.isSameSynset()) 56 | { 57 | return "SAME_SYNSET:YES"; 58 | } 59 | else 60 | { 61 | return "SAME_SYNSET:NO"; 62 | } 63 | } 64 | 65 | public FeatureVector[] classify(Object[] examples) 66 | { 67 | if (!(examples instanceof TemporalRelation_EE[])) 68 | { 69 | String type = examples == null ? "null" : examples.getClass().getName(); 70 | System.err.println("Classifier 'SameSynSet(TemporalRelation_EE)' defined on line 64 of eeTempRelCls.lbj received '" + type + "' as input."); 71 | new Exception().printStackTrace(); 72 | System.exit(1); 73 | } 74 | 75 | return super.classify(examples); 76 | } 77 | 78 | public int hashCode() { return "SameSynSet".hashCode(); } 79 | public boolean equals(Object o) { return o instanceof SameSynSet; } 80 | } 81 | 82 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls/SentDist.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B88000000000000000D6D8D3B020130144FFAC07552582ADA7E57E592281B790AB1958CDED19CA5888FFDD87822E70BDDCEB73374EC7844A40742AB2ECA6674DD0D72F17B41DB27F2BF6B50195C2728B2854197423404352F9E984DD33036B607089730D0666B85560EC9405DB6361EC77455D8B18266A74DE7953FFB6D64E34AF9FFADBC5640ACDD14E7CDCEA8D000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls; 5 | 6 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 7 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 8 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 9 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 10 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 11 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 12 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE; 14 | import java.lang.Object; 15 | import java.util.HashSet; 16 | import java.util.Iterator; 17 | import java.util.List; 18 | 19 | 20 | public class SentDist extends Classifier 21 | { 22 | public SentDist() 23 | { 24 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls"; 25 | name = "SentDist"; 26 | } 27 | 28 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE"; } 29 | public String getOutputType() { return "discrete"; } 30 | 31 | 32 | public FeatureVector classify(Object __example) 33 | { 34 | return new FeatureVector(featureValue(__example)); 35 | } 36 | 37 | public Feature featureValue(Object __example) 38 | { 39 | String result = discreteValue(__example); 40 | return new DiscretePrimitiveStringFeature(containingPackage, name, "", result, valueIndexOf(result), (short) allowableValues().length); 41 | } 42 | 43 | public String discreteValue(Object __example) 44 | { 45 | if (!(__example instanceof TemporalRelation_EE)) 46 | { 47 | String type = __example == null ? "null" : __example.getClass().getName(); 48 | System.err.println("Classifier 'SentDist(TemporalRelation_EE)' defined on line 18 of eeTempRelCls.lbj received '" + type + "' as input."); 49 | new Exception().printStackTrace(); 50 | System.exit(1); 51 | } 52 | 53 | TemporalRelation_EE ee = (TemporalRelation_EE) __example; 54 | 55 | int sentDiff = ee.getSentDiff(); 56 | if (sentDiff == 0) 57 | { 58 | return "SentDist:Same"; 59 | } 60 | else 61 | { 62 | if (sentDiff == 1) 63 | { 64 | return "SentDist:One"; 65 | } 66 | else 67 | { 68 | return "SentDist:Many"; 69 | } 70 | } 71 | } 72 | 73 | public FeatureVector[] classify(Object[] examples) 74 | { 75 | if (!(examples instanceof TemporalRelation_EE[])) 76 | { 77 | String type = examples == null ? "null" : examples.getClass().getName(); 78 | System.err.println("Classifier 'SentDist(TemporalRelation_EE)' defined on line 18 of eeTempRelCls.lbj received '" + type + "' as input."); 79 | new Exception().printStackTrace(); 80 | System.exit(1); 81 | } 82 | 83 | return super.classify(examples); 84 | } 85 | 86 | public int hashCode() { return "SentDist".hashCode(); } 87 | public boolean equals(Object o) { return o instanceof SentDist; } 88 | } 89 | 90 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls/SignalWords.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B8800000000000000059F8BCA02C030154F7560148611BF10E361A011DD824B507921DED6B18A984232A02EFBBD64732D2267518B9376EEC46ACD9C28134A4451A565B73633714A83F5C85955C8A42B23AF02401012DC6C4F0A5B475620627E50778322736143FA988A0072F51701E4B340EB10AB3C0F9779223768D690E3D60FD4DFA463694DB1BFE5D225F9FE60DB59AA2050D441592DD6177E02C0BE3BC14B30D069265BB85C460432F3C22DE10A901BDB26A4FC6758F5AB7674AB7126BFF798F34B755C2659A88F741C3F50D7DFA519F100000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls; 5 | 6 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 7 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 8 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 9 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 10 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 11 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 12 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE; 14 | import java.lang.Object; 15 | import java.util.HashSet; 16 | import java.util.Iterator; 17 | import java.util.List; 18 | 19 | 20 | public class SignalWords extends Classifier 21 | { 22 | public SignalWords() 23 | { 24 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls"; 25 | name = "SignalWords"; 26 | } 27 | 28 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE"; } 29 | public String getOutputType() { return "discrete%"; } 30 | 31 | public FeatureVector classify(Object __example) 32 | { 33 | if (!(__example instanceof TemporalRelation_EE)) 34 | { 35 | String type = __example == null ? "null" : __example.getClass().getName(); 36 | System.err.println("Classifier 'SignalWords(TemporalRelation_EE)' defined on line 87 of eeTempRelCls.lbj received '" + type + "' as input."); 37 | new Exception().printStackTrace(); 38 | System.exit(1); 39 | } 40 | 41 | TemporalRelation_EE ee = (TemporalRelation_EE) __example; 42 | 43 | FeatureVector __result; 44 | __result = new FeatureVector(); 45 | String __id; 46 | String __value; 47 | 48 | HashSet signals_before = ee.getSignals_before(); 49 | HashSet signals_between = ee.getSignals_between(); 50 | HashSet signals_after = ee.getSignals_after(); 51 | Iterator iter = signals_before.iterator(); 52 | while (iter.hasNext()) 53 | { 54 | __id = "" + ("BEFORE:" + iter.next()); 55 | __value = "true"; 56 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 57 | } 58 | iter = signals_between.iterator(); 59 | while (iter.hasNext()) 60 | { 61 | __id = "" + ("BETWEEN:" + iter.next()); 62 | __value = "true"; 63 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 64 | } 65 | iter = signals_after.iterator(); 66 | while (iter.hasNext()) 67 | { 68 | __id = "" + ("AFTER:" + iter.next()); 69 | __value = "true"; 70 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 71 | } 72 | return __result; 73 | } 74 | 75 | public FeatureVector[] classify(Object[] examples) 76 | { 77 | if (!(examples instanceof TemporalRelation_EE[])) 78 | { 79 | String type = examples == null ? "null" : examples.getClass().getName(); 80 | System.err.println("Classifier 'SignalWords(TemporalRelation_EE)' defined on line 87 of eeTempRelCls.lbj received '" + type + "' as input."); 81 | new Exception().printStackTrace(); 82 | System.exit(1); 83 | } 84 | 85 | return super.classify(examples); 86 | } 87 | 88 | public int hashCode() { return "SignalWords".hashCode(); } 89 | public boolean equals(Object o) { return o instanceof SignalWords; } 90 | } 91 | 92 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls/TokenDist.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B88000000000000000B2A4D4CC15809CFCE4DC379CC2E21D8094DCD28CF2A4CC90A4DC94C29CCCFCB877575584D45D450B1D558A6582A4D292D2AC302F5F2D35B408A7C5233D2D4343DA51A610CFF9EB0054000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls; 5 | 6 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 7 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 8 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 9 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 10 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 11 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 12 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE; 14 | import java.lang.Object; 15 | import java.util.HashSet; 16 | import java.util.Iterator; 17 | import java.util.List; 18 | 19 | 20 | public class TokenDist extends Classifier 21 | { 22 | public TokenDist() 23 | { 24 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls"; 25 | name = "TokenDist"; 26 | } 27 | 28 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE"; } 29 | public String getOutputType() { return "real"; } 30 | 31 | 32 | public FeatureVector classify(Object __example) 33 | { 34 | return new FeatureVector(featureValue(__example)); 35 | } 36 | 37 | public Feature featureValue(Object __example) 38 | { 39 | double result = realValue(__example); 40 | return new RealPrimitiveStringFeature(containingPackage, name, "", result); 41 | } 42 | 43 | public double realValue(Object __example) 44 | { 45 | if (!(__example instanceof TemporalRelation_EE)) 46 | { 47 | String type = __example == null ? "null" : __example.getClass().getName(); 48 | System.err.println("Classifier 'TokenDist(TemporalRelation_EE)' defined on line 28 of eeTempRelCls.lbj received '" + type + "' as input."); 49 | new Exception().printStackTrace(); 50 | System.exit(1); 51 | } 52 | 53 | TemporalRelation_EE ee = (TemporalRelation_EE) __example; 54 | 55 | return ee.getTokDiff(); 56 | } 57 | 58 | public FeatureVector[] classify(Object[] examples) 59 | { 60 | if (!(examples instanceof TemporalRelation_EE[])) 61 | { 62 | String type = examples == null ? "null" : examples.getClass().getName(); 63 | System.err.println("Classifier 'TokenDist(TemporalRelation_EE)' defined on line 28 of eeTempRelCls.lbj received '" + type + "' as input."); 64 | new Exception().printStackTrace(); 65 | System.exit(1); 66 | } 67 | 68 | return super.classify(examples); 69 | } 70 | 71 | public int hashCode() { return "TokenDist".hashCode(); } 72 | public boolean equals(Object o) { return o instanceof TokenDist; } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls_ET/BiasTermTemprel.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B88000000000000000B49CC2E4E2A4D2945507ACC4C2E094D2ACD094DCD282A4DC1D001D9F549893149A939852999F971FEA12A09A52A9A063ABA05DA004D15A5497A0A49404D4A46DA05B00EC47BA6464000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET; 5 | 6 | import edu.illinois.cs.cogcomp.core.datastructures.IntPair; 7 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 8 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 9 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 10 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 11 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 12 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 14 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET; 15 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TimexTemporalNode; 16 | import java.lang.Object; 17 | import java.util.HashSet; 18 | import java.util.Iterator; 19 | import java.util.List; 20 | 21 | 22 | public class BiasTermTemprel extends Classifier 23 | { 24 | public BiasTermTemprel() 25 | { 26 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET"; 27 | name = "BiasTermTemprel"; 28 | } 29 | 30 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET"; } 31 | public String getOutputType() { return "discrete"; } 32 | 33 | 34 | public FeatureVector classify(Object __example) 35 | { 36 | return new FeatureVector(featureValue(__example)); 37 | } 38 | 39 | public Feature featureValue(Object __example) 40 | { 41 | String result = discreteValue(__example); 42 | return new DiscretePrimitiveStringFeature(containingPackage, name, "", result, valueIndexOf(result), (short) allowableValues().length); 43 | } 44 | 45 | public String discreteValue(Object __example) 46 | { 47 | if (!(__example instanceof TemporalRelation_ET)) 48 | { 49 | String type = __example == null ? "null" : __example.getClass().getName(); 50 | System.err.println("Classifier 'BiasTermTemprel(TemporalRelation_ET)' defined on line 152 of etTempRelCls.lbj received '" + type + "' as input."); 51 | new Exception().printStackTrace(); 52 | System.exit(1); 53 | } 54 | 55 | TemporalRelation_ET et = (TemporalRelation_ET) __example; 56 | 57 | return "bias"; 58 | } 59 | 60 | public FeatureVector[] classify(Object[] examples) 61 | { 62 | if (!(examples instanceof TemporalRelation_ET[])) 63 | { 64 | String type = examples == null ? "null" : examples.getClass().getName(); 65 | System.err.println("Classifier 'BiasTermTemprel(TemporalRelation_ET)' defined on line 152 of etTempRelCls.lbj received '" + type + "' as input."); 66 | new Exception().printStackTrace(); 67 | System.exit(1); 68 | } 69 | 70 | return super.classify(examples); 71 | } 72 | 73 | public int hashCode() { return "BiasTermTemprel".hashCode(); } 74 | public boolean equals(Object o) { return o instanceof BiasTermTemprel; } 75 | } 76 | 77 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls_ET/ClosestTimexFeats.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B8800000000000000056D81CA02C030144F7568280D026E30A5D3982A71F0ADBB40D1D60AD642BB2614AFFE6A5CB5F6BCCCB97B77F27B845E20BD628054B2FD2BFD3D9A4E51BD7588EA933B17AE3477DD550AA1CA758F2E0E4AEB051F8115C62516F94D9B4C4983A23A3D011E3D190D9626DFF3D198F4DEB122F132B5B3931B7DCD894F548D9019DC4B54685E4A3BDD4C2A086C73B4C081E7043E7E5AF3D000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET; 5 | 6 | import edu.illinois.cs.cogcomp.core.datastructures.IntPair; 7 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 8 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 9 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 10 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 11 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 12 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 14 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET; 15 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TimexTemporalNode; 16 | import java.lang.Object; 17 | import java.util.HashSet; 18 | import java.util.Iterator; 19 | import java.util.List; 20 | 21 | 22 | public class ClosestTimexFeats extends Classifier 23 | { 24 | public ClosestTimexFeats() 25 | { 26 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET"; 27 | name = "ClosestTimexFeats"; 28 | } 29 | 30 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET"; } 31 | public String getOutputType() { return "discrete%"; } 32 | 33 | public FeatureVector classify(Object __example) 34 | { 35 | if (!(__example instanceof TemporalRelation_ET)) 36 | { 37 | String type = __example == null ? "null" : __example.getClass().getName(); 38 | System.err.println("Classifier 'ClosestTimexFeats(TemporalRelation_ET)' defined on line 114 of etTempRelCls.lbj received '" + type + "' as input."); 39 | new Exception().printStackTrace(); 40 | System.exit(1); 41 | } 42 | 43 | TemporalRelation_ET et = (TemporalRelation_ET) __example; 44 | 45 | FeatureVector __result; 46 | __result = new FeatureVector(); 47 | String __id; 48 | String __value; 49 | 50 | HashSet feats = et.getClosestTimexFeats(); 51 | Iterator iter = feats.iterator(); 52 | while (iter.hasNext()) 53 | { 54 | __id = "" + ("ClosestTimexFeats:" + iter.next()); 55 | __value = "true"; 56 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 57 | } 58 | return __result; 59 | } 60 | 61 | public FeatureVector[] classify(Object[] examples) 62 | { 63 | if (!(examples instanceof TemporalRelation_ET[])) 64 | { 65 | String type = examples == null ? "null" : examples.getClass().getName(); 66 | System.err.println("Classifier 'ClosestTimexFeats(TemporalRelation_ET)' defined on line 114 of etTempRelCls.lbj received '" + type + "' as input."); 67 | new Exception().printStackTrace(); 68 | System.exit(1); 69 | } 70 | 71 | return super.classify(examples); 72 | } 73 | 74 | public int hashCode() { return "ClosestTimexFeats".hashCode(); } 75 | public boolean equals(Object o) { return o instanceof ClosestTimexFeats; } 76 | } 77 | 78 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls_ET/CoveringSRL.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B88000000000000000B49CC2E4E2A4D294D8E85507ECF2B4D2ACCCB4F0E02F1D8094DCD28CF2A4CC90A4DC94C29CCCFCB877D01584D21D450B1D558A6582E4DCB2E4550527D0375FB018BE25801F4F57D80B25250D650D84D21DB4D8F468A44C79828DB282546A61B2928592829F5EB296A53E3314124A2B0251C6C0A9921F520490B658A5002E5DB9482B000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET; 5 | 6 | import edu.illinois.cs.cogcomp.core.datastructures.IntPair; 7 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 8 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 9 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 10 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 11 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 12 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 14 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET; 15 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TimexTemporalNode; 16 | import java.lang.Object; 17 | import java.util.HashSet; 18 | import java.util.Iterator; 19 | import java.util.List; 20 | 21 | 22 | public class CoveringSRL extends Classifier 23 | { 24 | public CoveringSRL() 25 | { 26 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET"; 27 | name = "CoveringSRL"; 28 | } 29 | 30 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET"; } 31 | public String getOutputType() { return "discrete[]"; } 32 | 33 | public FeatureVector classify(Object __example) 34 | { 35 | if (!(__example instanceof TemporalRelation_ET)) 36 | { 37 | String type = __example == null ? "null" : __example.getClass().getName(); 38 | System.err.println("Classifier 'CoveringSRL(TemporalRelation_ET)' defined on line 144 of etTempRelCls.lbj received '" + type + "' as input."); 39 | new Exception().printStackTrace(); 40 | System.exit(1); 41 | } 42 | 43 | TemporalRelation_ET et = (TemporalRelation_ET) __example; 44 | 45 | FeatureVector __result; 46 | __result = new FeatureVector(); 47 | int __featureIndex = 0; 48 | String __value; 49 | 50 | __value = "" + ("EVENT Covering TIMEX:" + (et.e_covering_t ? "Yes" : "No")); 51 | __result.addFeature(new DiscreteArrayStringFeature(this.containingPackage, this.name, "", __value, valueIndexOf(__value), (short) 0, __featureIndex++, 0)); 52 | __value = "" + ("EVENT Covering TIMEX Type:" + et.e_covering_t_type); 53 | __result.addFeature(new DiscreteArrayStringFeature(this.containingPackage, this.name, "", __value, valueIndexOf(__value), (short) 0, __featureIndex++, 0)); 54 | 55 | for (int __i = 0; __i < __result.featuresSize(); ++__i) 56 | __result.getFeature(__i).setArrayLength(__featureIndex); 57 | 58 | return __result; 59 | } 60 | 61 | public String[] discreteValueArray(Object __example) 62 | { 63 | return classify(__example).discreteValueArray(); 64 | } 65 | 66 | public FeatureVector[] classify(Object[] examples) 67 | { 68 | if (!(examples instanceof TemporalRelation_ET[])) 69 | { 70 | String type = examples == null ? "null" : examples.getClass().getName(); 71 | System.err.println("Classifier 'CoveringSRL(TemporalRelation_ET)' defined on line 144 of etTempRelCls.lbj received '" + type + "' as input."); 72 | new Exception().printStackTrace(); 73 | System.exit(1); 74 | } 75 | 76 | return super.classify(examples); 77 | } 78 | 79 | public int hashCode() { return "CoveringSRL".hashCode(); } 80 | public boolean equals(Object o) { return o instanceof CoveringSRL; } 81 | } 82 | 83 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls_ET/IsIntention.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B8800000000000000055E81CA02C030144F7568080D0261A7D651F4934F2D38401C3944B3840A625A98E54CF773114887A5897F677764B1EAB032758E34FE22D54BED55A97F9DF266A307239383B2D06498DE60F28A762BE76C0E7428D067987D736CF2CC1652B3C5CBF986C52E5C1FCA635BD2EB52330D50248A3AA1479D4A51853AAFFDFD34C98140A5881CB09966C5E1CE0FEF0A93703E6CC000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET; 5 | 6 | import edu.illinois.cs.cogcomp.core.datastructures.IntPair; 7 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 8 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 9 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 10 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 11 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 12 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 14 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET; 15 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TimexTemporalNode; 16 | import java.lang.Object; 17 | import java.util.HashSet; 18 | import java.util.Iterator; 19 | import java.util.List; 20 | 21 | 22 | public class IsIntention extends Classifier 23 | { 24 | public IsIntention() 25 | { 26 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET"; 27 | name = "IsIntention"; 28 | } 29 | 30 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET"; } 31 | public String getOutputType() { return "discrete%"; } 32 | 33 | public FeatureVector classify(Object __example) 34 | { 35 | if (!(__example instanceof TemporalRelation_ET)) 36 | { 37 | String type = __example == null ? "null" : __example.getClass().getName(); 38 | System.err.println("Classifier 'IsIntention(TemporalRelation_ET)' defined on line 137 of etTempRelCls.lbj received '" + type + "' as input."); 39 | new Exception().printStackTrace(); 40 | System.exit(1); 41 | } 42 | 43 | TemporalRelation_ET et = (TemporalRelation_ET) __example; 44 | 45 | FeatureVector __result; 46 | __result = new FeatureVector(); 47 | String __id; 48 | String __value; 49 | 50 | EventTemporalNode e1 = et.getEventNode(); 51 | boolean e1IsIntention = e1.isIntention(); 52 | __id = "" + ("EVENT IsIntention:" + (e1IsIntention ? "Yes" : "No")); 53 | __value = "true"; 54 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 55 | return __result; 56 | } 57 | 58 | public FeatureVector[] classify(Object[] examples) 59 | { 60 | if (!(examples instanceof TemporalRelation_ET[])) 61 | { 62 | String type = examples == null ? "null" : examples.getClass().getName(); 63 | System.err.println("Classifier 'IsIntention(TemporalRelation_ET)' defined on line 137 of etTempRelCls.lbj received '" + type + "' as input."); 64 | new Exception().printStackTrace(); 65 | System.exit(1); 66 | } 67 | 68 | return super.classify(examples); 69 | } 70 | 71 | public int hashCode() { return "IsIntention".hashCode(); } 72 | public boolean equals(Object o) { return o instanceof IsIntention; } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls_ET/IsReporting.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B8800000000000000055E813B02C030158FFAC3202438858EADA2E491C523492283945BF8218A98427AB88FFDD4501AE477CD7FDDDDB1C5AB64A075834A697F015C9F1B8E87BCD6F35BC9A7171CF9D470A86C673871CC39E5E768D0301CA0BBCCBC192F583F0B0DD0E212C4CED76EB83E3BA559E61FD2B998E311ACC1D8DE6994A65853A8FFDFD34D98941A682B149EC552E38D0EDF130E2F20BCC000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET; 5 | 6 | import edu.illinois.cs.cogcomp.core.datastructures.IntPair; 7 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 8 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 9 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 10 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 11 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 12 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 14 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET; 15 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TimexTemporalNode; 16 | import java.lang.Object; 17 | import java.util.HashSet; 18 | import java.util.Iterator; 19 | import java.util.List; 20 | 21 | 22 | public class IsReporting extends Classifier 23 | { 24 | public IsReporting() 25 | { 26 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET"; 27 | name = "IsReporting"; 28 | } 29 | 30 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET"; } 31 | public String getOutputType() { return "discrete%"; } 32 | 33 | public FeatureVector classify(Object __example) 34 | { 35 | if (!(__example instanceof TemporalRelation_ET)) 36 | { 37 | String type = __example == null ? "null" : __example.getClass().getName(); 38 | System.err.println("Classifier 'IsReporting(TemporalRelation_ET)' defined on line 130 of etTempRelCls.lbj received '" + type + "' as input."); 39 | new Exception().printStackTrace(); 40 | System.exit(1); 41 | } 42 | 43 | TemporalRelation_ET et = (TemporalRelation_ET) __example; 44 | 45 | FeatureVector __result; 46 | __result = new FeatureVector(); 47 | String __id; 48 | String __value; 49 | 50 | EventTemporalNode e1 = et.getEventNode(); 51 | boolean e1IsReporting = e1.isReporting(); 52 | __id = "" + ("EVENT IsReporting:" + (e1IsReporting ? "Yes" : "No")); 53 | __value = "true"; 54 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 55 | return __result; 56 | } 57 | 58 | public FeatureVector[] classify(Object[] examples) 59 | { 60 | if (!(examples instanceof TemporalRelation_ET[])) 61 | { 62 | String type = examples == null ? "null" : examples.getClass().getName(); 63 | System.err.println("Classifier 'IsReporting(TemporalRelation_ET)' defined on line 130 of etTempRelCls.lbj received '" + type + "' as input."); 64 | new Exception().printStackTrace(); 65 | System.exit(1); 66 | } 67 | 68 | return super.classify(examples); 69 | } 70 | 71 | public int hashCode() { return "IsReporting".hashCode(); } 72 | public boolean equals(Object o) { return o instanceof IsReporting; } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls_ET/IsVerbSRL.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B88000000000000000D4E8BCA02C034144F756C080922A0DD6B617595802D54D250755A5B3841262294AE64CF77B11C7CA68B7FC1689164F767C0C526FEB1ABEF85D146DCBEDCABE4754DD581DA9655D06840BD53E10577A90F13A4B301C415CCC73716873C8F4994E8EDA5DCECCCCFB5D15C43A81FE6DB3D231C2A08994BEC1E96C312453AACAF7B62318514EF77CE02E44F20914496542376073137C3F50997C659DCC000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET; 5 | 6 | import edu.illinois.cs.cogcomp.core.datastructures.IntPair; 7 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 8 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 9 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 10 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 11 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 12 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 14 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET; 15 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TimexTemporalNode; 16 | import java.lang.Object; 17 | import java.util.HashSet; 18 | import java.util.Iterator; 19 | import java.util.List; 20 | 21 | 22 | public class IsVerbSRL extends Classifier 23 | { 24 | public IsVerbSRL() 25 | { 26 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET"; 27 | name = "IsVerbSRL"; 28 | } 29 | 30 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET"; } 31 | public String getOutputType() { return "discrete%"; } 32 | 33 | public FeatureVector classify(Object __example) 34 | { 35 | if (!(__example instanceof TemporalRelation_ET)) 36 | { 37 | String type = __example == null ? "null" : __example.getClass().getName(); 38 | System.err.println("Classifier 'IsVerbSRL(TemporalRelation_ET)' defined on line 123 of etTempRelCls.lbj received '" + type + "' as input."); 39 | new Exception().printStackTrace(); 40 | System.exit(1); 41 | } 42 | 43 | TemporalRelation_ET et = (TemporalRelation_ET) __example; 44 | 45 | FeatureVector __result; 46 | __result = new FeatureVector(); 47 | String __id; 48 | String __value; 49 | 50 | EventTemporalNode e1 = et.getEventNode(); 51 | boolean e1IsVerbSRL = e1.getVerb_srl() != null; 52 | __id = "" + ("EVENT IsVerbSRL:" + (e1IsVerbSRL ? "Yes" : "No")); 53 | __value = "true"; 54 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 55 | return __result; 56 | } 57 | 58 | public FeatureVector[] classify(Object[] examples) 59 | { 60 | if (!(examples instanceof TemporalRelation_ET[])) 61 | { 62 | String type = examples == null ? "null" : examples.getClass().getName(); 63 | System.err.println("Classifier 'IsVerbSRL(TemporalRelation_ET)' defined on line 123 of etTempRelCls.lbj received '" + type + "' as input."); 64 | new Exception().printStackTrace(); 65 | System.exit(1); 66 | } 67 | 68 | return super.classify(examples); 69 | } 70 | 71 | public int hashCode() { return "IsVerbSRL".hashCode(); } 72 | public boolean equals(Object o) { return o instanceof IsVerbSRL; } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls_ET/Label.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B88000000000000000B49CC2E4E2A4D294550F94C4A4DC1D8094DCD28CF2A4CC90A4DC94C29CCCFCB877D01584D21D450B1D558A6500AAB2D2AC302F5F2D35B402AE53DA51A6106F511A5A34000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET; 5 | 6 | import edu.illinois.cs.cogcomp.core.datastructures.IntPair; 7 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 8 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 9 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 10 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 11 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 12 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 14 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET; 15 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TimexTemporalNode; 16 | import java.lang.Object; 17 | import java.util.HashSet; 18 | import java.util.Iterator; 19 | import java.util.List; 20 | 21 | 22 | public class Label extends Classifier 23 | { 24 | public Label() 25 | { 26 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET"; 27 | name = "Label"; 28 | } 29 | 30 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET"; } 31 | public String getOutputType() { return "discrete"; } 32 | 33 | 34 | public FeatureVector classify(Object __example) 35 | { 36 | return new FeatureVector(featureValue(__example)); 37 | } 38 | 39 | public Feature featureValue(Object __example) 40 | { 41 | String result = discreteValue(__example); 42 | return new DiscretePrimitiveStringFeature(containingPackage, name, "", result, valueIndexOf(result), (short) allowableValues().length); 43 | } 44 | 45 | public String discreteValue(Object __example) 46 | { 47 | if (!(__example instanceof TemporalRelation_ET)) 48 | { 49 | String type = __example == null ? "null" : __example.getClass().getName(); 50 | System.err.println("Classifier 'Label(TemporalRelation_ET)' defined on line 15 of etTempRelCls.lbj received '" + type + "' as input."); 51 | new Exception().printStackTrace(); 52 | System.exit(1); 53 | } 54 | 55 | TemporalRelation_ET et = (TemporalRelation_ET) __example; 56 | 57 | return "" + (et.getLabel()); 58 | } 59 | 60 | public FeatureVector[] classify(Object[] examples) 61 | { 62 | if (!(examples instanceof TemporalRelation_ET[])) 63 | { 64 | String type = examples == null ? "null" : examples.getClass().getName(); 65 | System.err.println("Classifier 'Label(TemporalRelation_ET)' defined on line 15 of etTempRelCls.lbj received '" + type + "' as input."); 66 | new Exception().printStackTrace(); 67 | System.exit(1); 68 | } 69 | 70 | return super.classify(examples); 71 | } 72 | 73 | public int hashCode() { return "Label".hashCode(); } 74 | public boolean equals(Object o) { return o instanceof Label; } 75 | } 76 | 77 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls_ET/Lemma.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B8800000000000000056ECDCA0280441500E75938018225F0065B8613B3D6113BF142F01283A23E53A88EDD3D91CE786B7EC7C9B7BAA783B3A0758C96D691B6ADEB3756372635A4DD5B64960521CE6D8704D59DAC22E8D55401BF9AEDC582EBB93B839D247D697BF182F68EBB50E0C6702225627554178C224A0EC82C33902388B19F17A3043AFED3FF57A88C781EEC44EB61E9F200ED39AADAE000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET; 5 | 6 | import edu.illinois.cs.cogcomp.core.datastructures.IntPair; 7 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 8 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 9 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 10 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 11 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 12 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 14 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET; 15 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TimexTemporalNode; 16 | import java.lang.Object; 17 | import java.util.HashSet; 18 | import java.util.Iterator; 19 | import java.util.List; 20 | 21 | 22 | public class Lemma extends Classifier 23 | { 24 | public Lemma() 25 | { 26 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET"; 27 | name = "Lemma"; 28 | } 29 | 30 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET"; } 31 | public String getOutputType() { return "discrete%"; } 32 | 33 | public FeatureVector classify(Object __example) 34 | { 35 | if (!(__example instanceof TemporalRelation_ET)) 36 | { 37 | String type = __example == null ? "null" : __example.getClass().getName(); 38 | System.err.println("Classifier 'Lemma(TemporalRelation_ET)' defined on line 68 of etTempRelCls.lbj received '" + type + "' as input."); 39 | new Exception().printStackTrace(); 40 | System.exit(1); 41 | } 42 | 43 | TemporalRelation_ET et = (TemporalRelation_ET) __example; 44 | 45 | FeatureVector __result; 46 | __result = new FeatureVector(); 47 | String __id; 48 | String __value; 49 | 50 | EventTemporalNode e = et.getEventNode(); 51 | TimexTemporalNode t = et.getTimexNode(); 52 | __id = "" + ("E_LEMMA:" + e.getLemma()); 53 | __value = "true"; 54 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 55 | __id = "" + ("ET_LEMMA_Type:" + e.getLemma() + ":" + t.getType()); 56 | __value = "true"; 57 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 58 | return __result; 59 | } 60 | 61 | public FeatureVector[] classify(Object[] examples) 62 | { 63 | if (!(examples instanceof TemporalRelation_ET[])) 64 | { 65 | String type = examples == null ? "null" : examples.getClass().getName(); 66 | System.err.println("Classifier 'Lemma(TemporalRelation_ET)' defined on line 68 of etTempRelCls.lbj received '" + type + "' as input."); 67 | new Exception().printStackTrace(); 68 | System.exit(1); 69 | } 70 | 71 | return super.classify(examples); 72 | } 73 | 74 | public int hashCode() { return "Lemma".hashCode(); } 75 | public boolean equals(Object o) { return o instanceof Lemma; } 76 | } 77 | 78 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls_ET/PPHead.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B8800000000000000057FCDCA0280441500E759BD040E019DEDA612430E62B12763DA609C3590EF5A36401DBB7A286906CDDDC9F8B7FC441757E216037292D348195A096197916274421A983FC4B05403C963B4A719870233DB0F3F8040AD631BD7589E2B6FDC2EB62517A87E80A9106795F0B246518890D25A6F48BB3781D280D23958EB5B58839346ACA1385532B66AD6C712B663ED363EE578945613F75E23ECB9FE4B86ADC87B678BF6AA470EEEFBD7F422063C5D7312960DF5CEF1E7D633F104CF06F34F7100000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET; 5 | 6 | import edu.illinois.cs.cogcomp.core.datastructures.IntPair; 7 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 8 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 9 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 10 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 11 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 12 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 14 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET; 15 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TimexTemporalNode; 16 | import java.lang.Object; 17 | import java.util.HashSet; 18 | import java.util.Iterator; 19 | import java.util.List; 20 | 21 | 22 | public class PPHead extends Classifier 23 | { 24 | public PPHead() 25 | { 26 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET"; 27 | name = "PPHead"; 28 | } 29 | 30 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET"; } 31 | public String getOutputType() { return "discrete%"; } 32 | 33 | public FeatureVector classify(Object __example) 34 | { 35 | if (!(__example instanceof TemporalRelation_ET)) 36 | { 37 | String type = __example == null ? "null" : __example.getClass().getName(); 38 | System.err.println("Classifier 'PPHead(TemporalRelation_ET)' defined on line 77 of etTempRelCls.lbj received '" + type + "' as input."); 39 | new Exception().printStackTrace(); 40 | System.exit(1); 41 | } 42 | 43 | TemporalRelation_ET et = (TemporalRelation_ET) __example; 44 | 45 | FeatureVector __result; 46 | __result = new FeatureVector(); 47 | String __id; 48 | String __value; 49 | 50 | EventTemporalNode e = et.getEventNode(); 51 | TimexTemporalNode t = et.getTimexNode(); 52 | __id = "" + ("E_PP_HEAD:" + e.getPp_head()); 53 | __value = "true"; 54 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 55 | __id = "" + ("T_PP_HEAD:" + t.getPp_head()); 56 | __value = "true"; 57 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 58 | if (!e.getPp_head().equals("N/A")) 59 | { 60 | if (e.getPp_head().equals(t.getPp_head())) 61 | { 62 | __id = "ET_SAME_PP_HEAD:YES"; 63 | __value = "true"; 64 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 65 | } 66 | else 67 | { 68 | __id = "ET_SAME_PP_HEAD:NO"; 69 | __value = "true"; 70 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 71 | } 72 | } 73 | return __result; 74 | } 75 | 76 | public FeatureVector[] classify(Object[] examples) 77 | { 78 | if (!(examples instanceof TemporalRelation_ET[])) 79 | { 80 | String type = examples == null ? "null" : examples.getClass().getName(); 81 | System.err.println("Classifier 'PPHead(TemporalRelation_ET)' defined on line 77 of etTempRelCls.lbj received '" + type + "' as input."); 82 | new Exception().printStackTrace(); 83 | System.exit(1); 84 | } 85 | 86 | return super.classify(examples); 87 | } 88 | 89 | public int hashCode() { return "PPHead".hashCode(); } 90 | public boolean equals(Object o) { return o instanceof PPHead; } 91 | } 92 | 93 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls_ET/SentDist.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B88000000000000000D6D8D3B020130144FFAC07552582ADA7E57A5A806EA790AB1958CDED19CA5888FFDD87822E70BDDCEB73374EC7844A40742AB2ECA6A5AE68E39F8B3A8E59B79DFAB509A5C2728B2854197423404352F9E984DD33036B607089730D0666B85560EC9405DB6361EC77455D8B18266A74DE7953FFB6D65E34AF9FF6CBC5640ACDD195582B8C8D000000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET; 5 | 6 | import edu.illinois.cs.cogcomp.core.datastructures.IntPair; 7 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 8 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 9 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 10 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 11 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 12 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 14 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET; 15 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TimexTemporalNode; 16 | import java.lang.Object; 17 | import java.util.HashSet; 18 | import java.util.Iterator; 19 | import java.util.List; 20 | 21 | 22 | public class SentDist extends Classifier 23 | { 24 | public SentDist() 25 | { 26 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET"; 27 | name = "SentDist"; 28 | } 29 | 30 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET"; } 31 | public String getOutputType() { return "discrete"; } 32 | 33 | 34 | public FeatureVector classify(Object __example) 35 | { 36 | return new FeatureVector(featureValue(__example)); 37 | } 38 | 39 | public Feature featureValue(Object __example) 40 | { 41 | String result = discreteValue(__example); 42 | return new DiscretePrimitiveStringFeature(containingPackage, name, "", result, valueIndexOf(result), (short) allowableValues().length); 43 | } 44 | 45 | public String discreteValue(Object __example) 46 | { 47 | if (!(__example instanceof TemporalRelation_ET)) 48 | { 49 | String type = __example == null ? "null" : __example.getClass().getName(); 50 | System.err.println("Classifier 'SentDist(TemporalRelation_ET)' defined on line 20 of etTempRelCls.lbj received '" + type + "' as input."); 51 | new Exception().printStackTrace(); 52 | System.exit(1); 53 | } 54 | 55 | TemporalRelation_ET et = (TemporalRelation_ET) __example; 56 | 57 | int sentDiff = et.getSentDiff(); 58 | if (sentDiff == 0) 59 | { 60 | return "SentDist:Same"; 61 | } 62 | else 63 | { 64 | if (sentDiff == 1) 65 | { 66 | return "SentDist:One"; 67 | } 68 | else 69 | { 70 | return "SentDist:Many"; 71 | } 72 | } 73 | } 74 | 75 | public FeatureVector[] classify(Object[] examples) 76 | { 77 | if (!(examples instanceof TemporalRelation_ET[])) 78 | { 79 | String type = examples == null ? "null" : examples.getClass().getName(); 80 | System.err.println("Classifier 'SentDist(TemporalRelation_ET)' defined on line 20 of etTempRelCls.lbj received '" + type + "' as input."); 81 | new Exception().printStackTrace(); 82 | System.exit(1); 83 | } 84 | 85 | return super.classify(examples); 86 | } 87 | 88 | public int hashCode() { return "SentDist".hashCode(); } 89 | public boolean equals(Object o) { return o instanceof SentDist; } 90 | } 91 | 92 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/lbjava/TempRelCls_ET/SignalWords.java: -------------------------------------------------------------------------------- 1 | // Modifying this comment will cause the next execution of LBJava to overwrite this file. 2 | // F1B8800000000000000059F8BCA02C030154F7560148611BF10E361A092AB9A0D61AB498A7D6305319464414AFFE6B1DD885447518B9376EECC149BDB50368499A25BCAB036F0E28C17A3B1B2BE415B46564F654E40E096636AB3DA4ABA230393F28BDEE07436143F6988A4076F61701E4B740EB20AB7C0F97F922F8C0BF128F4B3C7DDEB29D8525F4CED75B84DBEBB34FA59AA14147154594790E6C14816B76938670A1C254CB945C460432F3C22DE10A901BDB06A4DC7658F5AFFCE8CB01229FDB4CF1AF755C22EC54AF5A0A970087BA47DF9F100000 3 | 4 | package edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET; 5 | 6 | import edu.illinois.cs.cogcomp.core.datastructures.IntPair; 7 | import edu.illinois.cs.cogcomp.lbjava.classify.*; 8 | import edu.illinois.cs.cogcomp.lbjava.infer.*; 9 | import edu.illinois.cs.cogcomp.lbjava.io.IOUtilities; 10 | import edu.illinois.cs.cogcomp.lbjava.learn.*; 11 | import edu.illinois.cs.cogcomp.lbjava.parse.*; 12 | import edu.illinois.cs.cogcomp.temporal.configurations.ParamLBJ; 13 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.EventTemporalNode; 14 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET; 15 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TimexTemporalNode; 16 | import java.lang.Object; 17 | import java.util.HashSet; 18 | import java.util.Iterator; 19 | import java.util.List; 20 | 21 | 22 | public class SignalWords extends Classifier 23 | { 24 | public SignalWords() 25 | { 26 | containingPackage = "edu.illinois.cs.cogcomp.temporal.lbjava.TempRelCls_ET"; 27 | name = "SignalWords"; 28 | } 29 | 30 | public String getInputType() { return "edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_ET"; } 31 | public String getOutputType() { return "discrete%"; } 32 | 33 | public FeatureVector classify(Object __example) 34 | { 35 | if (!(__example instanceof TemporalRelation_ET)) 36 | { 37 | String type = __example == null ? "null" : __example.getClass().getName(); 38 | System.err.println("Classifier 'SignalWords(TemporalRelation_ET)' defined on line 92 of etTempRelCls.lbj received '" + type + "' as input."); 39 | new Exception().printStackTrace(); 40 | System.exit(1); 41 | } 42 | 43 | TemporalRelation_ET et = (TemporalRelation_ET) __example; 44 | 45 | FeatureVector __result; 46 | __result = new FeatureVector(); 47 | String __id; 48 | String __value; 49 | 50 | HashSet signals_before = et.getSignals_before(); 51 | HashSet signals_between = et.getSignals_between(); 52 | HashSet signals_after = et.getSignals_after(); 53 | Iterator iter = signals_before.iterator(); 54 | while (iter.hasNext()) 55 | { 56 | __id = "" + ("BEFORE:" + iter.next()); 57 | __value = "true"; 58 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 59 | } 60 | iter = signals_between.iterator(); 61 | while (iter.hasNext()) 62 | { 63 | __id = "" + ("BETWEEN:" + iter.next()); 64 | __value = "true"; 65 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 66 | } 67 | iter = signals_after.iterator(); 68 | while (iter.hasNext()) 69 | { 70 | __id = "" + ("AFTER:" + iter.next()); 71 | __value = "true"; 72 | __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); 73 | } 74 | return __result; 75 | } 76 | 77 | public FeatureVector[] classify(Object[] examples) 78 | { 79 | if (!(examples instanceof TemporalRelation_ET[])) 80 | { 81 | String type = examples == null ? "null" : examples.getClass().getName(); 82 | System.err.println("Classifier 'SignalWords(TemporalRelation_ET)' defined on line 92 of etTempRelCls.lbj received '" + type + "' as input."); 83 | new Exception().printStackTrace(); 84 | System.exit(1); 85 | } 86 | 87 | return super.classify(examples); 88 | } 89 | 90 | public int hashCode() { return "SignalWords".hashCode(); } 91 | public boolean equals(Object o) { return o instanceof SignalWords; } 92 | } 93 | 94 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/readers/RED/RedDataset.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.readers.RED; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | 5 | import java.io.FileOutputStream; 6 | import java.io.PrintStream; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | public class RedDataset { 11 | private List dataset; 12 | 13 | public RedDataset(){ 14 | dataset = new ArrayList<>(); 15 | } 16 | public void addDoc(RedDoc doc){ 17 | dataset.add(doc); 18 | } 19 | public int getNum_doc(){ 20 | return dataset.size(); 21 | } 22 | public int getNum_event(){ 23 | int n = 0; 24 | for(RedDoc doc:dataset){ 25 | n+=doc.getEvents().size(); 26 | } 27 | return n; 28 | } 29 | 30 | public List getDataset() { 31 | return dataset; 32 | } 33 | @Nullable 34 | public RedDoc getDocFromId(String docid){ 35 | for(RedDoc doc:dataset){ 36 | if(doc.getDocId().equals(docid)) 37 | return doc; 38 | } 39 | return null; 40 | } 41 | public void Render4Crowdflower(String outputfile,String color){ 42 | StringBuilder sb = new StringBuilder(); 43 | sb.append("\"docid\",\"eventid\",\"verb\",\"bodytext\"\n"); 44 | for(RedDoc doc:dataset){ 45 | sb.append(doc.Render4Crowdflower(color)); 46 | } 47 | try (PrintStream out = new PrintStream(new FileOutputStream(outputfile))) { 48 | out.print(sb.toString()); 49 | } 50 | catch (Exception e){ 51 | e.printStackTrace(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/readers/RED/RedDoc.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.readers.RED; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class RedDoc { 7 | private String bodyText; 8 | private String docId; 9 | private List events = new ArrayList<>(); 10 | 11 | public RedDoc(String bodyText, String docId) { 12 | this.bodyText = bodyText; 13 | this.docId = docId; 14 | } 15 | 16 | public void addEvent(RedEvent event){ 17 | events.add(event); 18 | } 19 | 20 | public List getEvents() { 21 | return events; 22 | } 23 | 24 | public String getBodyText() { 25 | return bodyText; 26 | } 27 | 28 | public String getDocId() { 29 | return docId; 30 | } 31 | public RedEvent getEventFromId(int eventid){ 32 | for(RedEvent e:events){ 33 | if(e.getId()==eventid) 34 | return e; 35 | } 36 | return null; 37 | } 38 | public String Render4Crowdflower(String color){ 39 | StringBuilder sb = new StringBuilder(); 40 | for(RedEvent e:events){ 41 | sb.append(String.format("\"%s\",\"%d\",\"%s\",\"%s\"\n",docId,e.getId(),e.getText(),e.Render4Crowdflower("red"))); 42 | } 43 | return sb.toString(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/readers/RED/RedEvent.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.readers.RED; 2 | 3 | public class RedEvent{ 4 | protected class IntPair{ 5 | private int first, second; 6 | 7 | public IntPair(int first, int second) { 8 | this.first = first; 9 | this.second = second; 10 | } 11 | 12 | public int getFirst() { 13 | return first; 14 | } 15 | 16 | public int getSecond() { 17 | return second; 18 | } 19 | } 20 | private String polarity,contextualModality; 21 | private IntPair charSpan;//right exclusive 22 | private String text; 23 | private int id; 24 | private RedDoc doc; 25 | 26 | private static String nodeType = "RedEvent"; 27 | 28 | // Constructors 29 | public RedEvent(RedDoc doc, int id, int charStart, int charEnd, String polarity, String contextualModality) { 30 | this.doc = doc; 31 | this.id = id; 32 | charSpan = new IntPair(charStart,charEnd); 33 | if(charStart<0||charEnd>=doc.getBodyText().length()){ 34 | System.out.println("Invalid char spans."); 35 | } 36 | this.text = doc.getBodyText().substring(charStart,charEnd); 37 | this.polarity = polarity; 38 | this.contextualModality = contextualModality; 39 | } 40 | 41 | 42 | 43 | // other functions 44 | public String toString() { 45 | return String.format("Doc=%s, id=%d ([%d,%d)): %s, POLARITY=%s, MODALITY=%s\n", 46 | doc.getDocId(),id,charSpan.getFirst(),charSpan.getSecond(),text,polarity,contextualModality); 47 | } 48 | 49 | public String getPolarity() { 50 | return polarity; 51 | } 52 | 53 | public String getContextualModality() { 54 | return contextualModality; 55 | } 56 | 57 | public IntPair getCharSpan() { 58 | return charSpan; 59 | } 60 | 61 | public String getText() { 62 | return text; 63 | } 64 | 65 | public int getId() { 66 | return id; 67 | } 68 | 69 | public RedDoc getDoc() { 70 | return doc; 71 | } 72 | 73 | public static String getNodeType() { 74 | return nodeType; 75 | } 76 | public String Render4Crowdflower(String color){ 77 | int charStart = charSpan.getFirst(), charEnd = charSpan.getSecond(); 78 | StringBuilder sb = new StringBuilder(); 79 | String left = doc.getBodyText().substring(0,charStart).replaceAll("\n"," ").replaceAll("\""," "); 80 | left = left.substring(left.lastIndexOf(">")+1,left.length()); 81 | String right = doc.getBodyText().substring(charEnd).replaceAll("\n"," ").replaceAll("\""," "); 82 | int tmp = right.indexOf("<"); 83 | right = right.substring(0,tmp>0?tmp:right.length()); 84 | sb.append("

"); 85 | sb.append(left); 86 | sb.append(String.format("%s",color,text)); 87 | sb.append(right); 88 | sb.append("

"); 89 | return sb.toString(); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/readers/axisAnnotationReader.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.readers; 2 | 3 | import edu.illinois.cs.cogcomp.temporal.utils.IO.myIOUtils; 4 | 5 | import java.util.HashMap; 6 | 7 | public class axisAnnotationReader { 8 | public static String LABEL_NOT_ON_ANY_AXIS = "null"; 9 | public static String LABEL_ON_MAIN_AXIS = "main"; 10 | public static String LABEL_ON_ORTHOGONAL_AXIS = "orthogonal"; 11 | public static String LABEL_ON_NEGATION_AXIS = "negation"; 12 | public static String LABEL_ON_HYPO_AXIS = "hypothesis"; 13 | public static String LABEL_ON_OTHER_AXIS = "others"; 14 | public static String axis_label_conversion(String label){ 15 | switch (label){ 16 | case "yes"://herited from older version of anchorability 17 | case "yes_its_anchorable": 18 | return LABEL_ON_MAIN_AXIS; 19 | case "no_its_intentionwishopinion": 20 | //return LABEL_ON_ORTHOGONAL_AXIS; 21 | case "no_its_negation": 22 | //return LABEL_ON_NEGATION_AXIS; 23 | case "no_its_hypotheticalcondition": 24 | //return LABEL_ON_HYPO_AXIS; 25 | case "no_its_recurrent": 26 | case "no_its_static": 27 | case "no_its_abstractnonspecific": 28 | return LABEL_ON_OTHER_AXIS; 29 | default: 30 | return LABEL_NOT_ON_ANY_AXIS; 31 | } 32 | } 33 | public static HashMap> readAxisMapFromCrowdFlower(String fileList){ 34 | // docid-->eventid (index in doc)-->axis_label 35 | HashMap> axisMap = new HashMap<>(); 36 | String[] files = fileList.split(","); 37 | for(String file:files){ 38 | String tmpDir = myIOUtils.getParentDir(file); 39 | String tmpFile = myIOUtils.getFileOrDirName(file); 40 | myCSVReader cf_reader = new myCSVReader(tmpDir,tmpFile); 41 | for(int i=0;i()); 50 | axisMap.get(docid).put(eventid,anchorability); 51 | } 52 | catch (Exception e){ 53 | e.printStackTrace(); 54 | } 55 | } 56 | } 57 | return axisMap; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/readers/myCSVReader.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.readers; 2 | 3 | import com.opencsv.CSVReader; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | import java.io.File; 7 | import java.io.FileReader; 8 | import java.util.ArrayList; 9 | import java.util.HashMap; 10 | import java.util.List; 11 | 12 | public class myCSVReader { 13 | private String dir = ""; 14 | private String fname = ""; 15 | private String[] header; 16 | private List content = new ArrayList<>(); 17 | private HashMap col2idx = new HashMap<>(); 18 | 19 | public myCSVReader(String dir, String fname) { 20 | this.dir = dir; 21 | this.fname = fname; 22 | try { 23 | CSVReader csvReader = new CSVReader(new FileReader(dir+ File.separator+fname)); 24 | content = csvReader.readAll(); 25 | if(content==null||content.isEmpty()){ 26 | System.out.println("File "+dir+" is empty."); 27 | return; 28 | } 29 | extractHeader(); 30 | } 31 | catch (Exception e){ 32 | System.out.println("Failed loading file "+dir); 33 | e.printStackTrace(); 34 | } 35 | } 36 | private void extractHeader(){ 37 | header = content.get(0); 38 | for(int i=0;i=getContentLines()){ 69 | System.out.println("Line "+line+" doesn't exist."); 70 | return ""; 71 | } 72 | return content.get(line)[idx]; 73 | } 74 | 75 | public String getDir() { 76 | return dir; 77 | } 78 | 79 | public String getFname() { 80 | return fname; 81 | } 82 | 83 | public String[] getHeader() { 84 | return header; 85 | } 86 | 87 | public List getContent() { 88 | return content; 89 | } 90 | 91 | public HashMap getCol2idx() { 92 | return col2idx; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/utils/CoDL/ScoringFunc.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.utils.CoDL; 2 | 3 | import edu.illinois.cs.cogcomp.lbjava.classify.ScoreSet; 4 | 5 | public interface ScoringFunc { 6 | ScoreSet scores(LearningObj obj); 7 | String discreteValue(LearningObj obj); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/utils/CoDL/TempRelLabelerMultiLBJ.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.utils.CoDL; 2 | 3 | import edu.illinois.cs.cogcomp.lbjava.learn.Learner; 4 | import edu.illinois.cs.cogcomp.temporal.TemporalRelationExtractor.TempRelLabeler; 5 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelType; 6 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation; 7 | import edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelation_EE; 8 | import edu.illinois.cs.cogcomp.temporal.utils.CoDL.MultiClassifiers; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | import static edu.illinois.cs.cogcomp.temporal.datastruct.Temporal.TemporalRelType.getNullTempRel; 12 | 13 | public class TempRelLabelerMultiLBJ extends TempRelLabeler{ 14 | private MultiClassifiers multiClassifiers; 15 | 16 | public TempRelLabelerMultiLBJ(MultiClassifiers multiClassifiers) { 17 | this.multiClassifiers = multiClassifiers; 18 | } 19 | 20 | public TempRelLabelerMultiLBJ(Learner cls, double lambda, boolean norm_before_merge) { 21 | super(); 22 | multiClassifiers = new MultiClassifiers<>(cls, lambda, norm_before_merge); 23 | } 24 | 25 | public TempRelLabelerMultiLBJ(double lambda, boolean norm_before_merge) { 26 | super(); 27 | multiClassifiers = new MultiClassifiers<>(lambda, norm_before_merge); 28 | } 29 | 30 | public void addClassifier(Learner classifier){ 31 | multiClassifiers.addClassifier(classifier); 32 | } 33 | 34 | public void dropClassifier(){ 35 | multiClassifiers.dropClassifier(); 36 | } 37 | 38 | public MultiClassifiers getMultiClassifiers() { 39 | return multiClassifiers; 40 | } 41 | 42 | @Override 43 | public boolean isIgnore(TemporalRelation ee) { 44 | return ! (ee instanceof TemporalRelation_EE) 45 | ||Math.abs(ee.getSentDiff()) > 1; 46 | } 47 | 48 | @Override 49 | @NotNull 50 | public TemporalRelType tempRelLabel(TemporalRelation ee) { 51 | TemporalRelType ret = getNullTempRel(); 52 | if(isIgnore(ee)) 53 | return ret; 54 | if (ee.getSentDiff() == 0 || ee.getSentDiff() == 1) { 55 | ret = new TemporalRelType(multiClassifiers.discreteValue((TemporalRelation_EE)ee)); 56 | ret.setScores(temporalScores2doubles(multiClassifiers.scores((TemporalRelation_EE)ee), TemporalRelType.relTypes.getAllNames(), true)); 57 | } 58 | return ret; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/utils/CrossValidation/CVWrapper_LBJ.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.utils.CrossValidation; 2 | 3 | import edu.illinois.cs.cogcomp.core.io.IOUtils; 4 | import edu.illinois.cs.cogcomp.lbjava.learn.Learner; 5 | import edu.illinois.cs.cogcomp.lbjava.learn.Lexicon; 6 | import edu.illinois.cs.cogcomp.temporal.utils.ExecutionTimeUtil; 7 | import edu.illinois.cs.cogcomp.temporal.utils.PrecisionRecallManager; 8 | 9 | import java.io.File; 10 | import java.util.List; 11 | 12 | public abstract class CVWrapper_LBJ extends CrossValidationWrapper { 13 | protected Learner classifier; 14 | protected List testStructs; 15 | protected int evalMetric = 2;//0:prec. 1: recall. 2: f1 16 | protected String modelPath, lexiconPath; 17 | protected static String[] LABEL_TO_IGNORE = new String[]{}; 18 | 19 | public CVWrapper_LBJ(int seed, int totalFold, int evalMetric) { 20 | super(seed, totalFold); 21 | this.evalMetric = evalMetric; 22 | } 23 | public void setModelPath(String dir, String name) { 24 | IOUtils.mkdir(dir); 25 | modelPath = dir+ File.separator+name+".lc"; 26 | lexiconPath = dir+File.separator+name+".lex"; 27 | } 28 | 29 | public abstract String getLabel(LearningStruct learningStruct); 30 | @Override 31 | public double evaluate(List slist, int verbose) { 32 | ExecutionTimeUtil timer = new ExecutionTimeUtil(); 33 | PrecisionRecallManager evaluator = new PrecisionRecallManager(); 34 | timer.start(); 35 | for(LearningStruct learningStruct:slist){ 36 | String p = classifier.discreteValue(learningStruct); 37 | String l = getLabel(learningStruct); 38 | evaluator.addPredGoldLabels(p,l); 39 | } 40 | timer.end(); 41 | if(verbose>0) { 42 | evaluator.printPrecisionRecall(LABEL_TO_IGNORE); 43 | } 44 | double res; 45 | switch(evalMetric){ 46 | case 0: 47 | res = evaluator.getResultStruct(LABEL_TO_IGNORE).prec; 48 | break; 49 | case 1: 50 | res = evaluator.getResultStruct(LABEL_TO_IGNORE).rec; 51 | break; 52 | case 2: 53 | res = evaluator.getResultStruct(LABEL_TO_IGNORE).f; 54 | break; 55 | default: 56 | res = evaluator.getResultStruct(LABEL_TO_IGNORE).f; 57 | } 58 | return res; 59 | } 60 | public double evaluateTest(){ 61 | System.out.println("-------------------"); 62 | System.out.println("Evaluating TestSet..."); 63 | return evaluate(testStructs,1); 64 | } 65 | public void saveClassifier(){ 66 | classifier.write(modelPath,lexiconPath); 67 | } 68 | 69 | public static void StandardExperiment(CVWrapper_LBJ exp){ 70 | // remember to setup model names before calling this 71 | exp.load(); 72 | exp.myParamTuner(); 73 | exp.retrainUsingBest(); 74 | Lexicon lex = exp.classifier.getLexicon(); 75 | System.out.printf("Lexicon size: %d\n",lex.size()); 76 | exp.evaluateTest(); 77 | exp.saveClassifier(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/utils/CrossValidation/CVWrapper_LBJ_Perceptron.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.utils.CrossValidation; 2 | 3 | import edu.illinois.cs.cogcomp.temporal.utils.myLogFormatter; 4 | 5 | import java.util.Arrays; 6 | import java.util.Collections; 7 | import java.util.List; 8 | import java.util.Random; 9 | 10 | public abstract class CVWrapper_LBJ_Perceptron extends CVWrapper_LBJ { 11 | protected static double[] LEARNRATE,THICKNESS,SAMRATE,ROUND; 12 | 13 | public CVWrapper_LBJ_Perceptron(int seed, int totalFold, int evalMetric) { 14 | super(seed, totalFold, evalMetric); 15 | } 16 | 17 | public abstract List SetLrThSrCls(double lr, double th, double sr,List slist); 18 | @Override 19 | public void learn(List slist, double[] param, int seed) { 20 | double lr = param[0]; 21 | double th = param[1]; 22 | double sr = param[2]; 23 | int round = (int) Math.round(param[3]); 24 | List slist_sample = SetLrThSrCls(lr,th,sr,slist); 25 | classifier.forget(); 26 | classifier.beginTraining(); 27 | for(int iter=0;iter allIdx = new ArrayList<>(); 15 | public CrossValidationSplit(int TotalFold, int SampleSize, int seed){ 16 | this.TotalFold = TotalFold; 17 | this.SampleSize = SampleSize; 18 | this.seed = seed; 19 | for(int i=0;i getFold(int fold){ 25 | if(fold < 1 || fold > TotalFold) 26 | return null; 27 | int left = (int)(1.0*(fold-1)*SampleSize/TotalFold); 28 | int right = (int)(1.0*fold*SampleSize/TotalFold); 29 | left = left<0? 0 : left; 30 | right = right>SampleSize? SampleSize:right; 31 | return allIdx.subList(left,right); 32 | } 33 | public Pair,List> TrainTestSplit(int fold){ 34 | if(fold < 1 || fold > TotalFold) 35 | return null; 36 | List test = getFold(fold); 37 | List train = new ArrayList<>(); 38 | for(int i = 1; i <= TotalFold; i++){ 39 | if(i == fold) 40 | continue; 41 | train.addAll(getFold(i)); 42 | } 43 | return new Pair<>(train,test); 44 | 45 | } 46 | public static void main(String[] args) { 47 | int TotalFold = 3; 48 | int SampleSize = 10; 49 | CrossValidationSplit cv = new CrossValidationSplit(TotalFold,SampleSize,1); 50 | System.out.println(cv.allIdx); 51 | for(int i = 1;i<=TotalFold;i++) { 52 | System.out.println("******Fold: "+i+"******\nTrain:"); 53 | System.out.println(cv.TrainTestSplit(i).getFirst()+"\nTest:"); 54 | System.out.println(cv.TrainTestSplit(i).getSecond()); 55 | } 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/utils/ExecutionTimeUtil.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.utils; 2 | 3 | import edu.illinois.cs.cogcomp.core.utilities.ExecutionTimer; 4 | 5 | /** 6 | * Created by qning2 on 11/28/16. 7 | */ 8 | public class ExecutionTimeUtil extends ExecutionTimer { 9 | 10 | public void print(){ 11 | System.out.println("Total Time: "+getTimeSeconds()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/utils/GraphVisualizer/edge.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.utils.GraphVisualizer; 2 | 3 | public class edge { 4 | private int source; 5 | private int target; 6 | private String label; 7 | private int length; 8 | private int colorId; 9 | private String markerEnd; 10 | 11 | public int getSource() { 12 | return source; 13 | } 14 | 15 | public void setSource(int source) { 16 | this.source = source; 17 | } 18 | 19 | public int getTarget() { 20 | return target; 21 | } 22 | 23 | public void setTarget(int target) { 24 | this.target = target; 25 | } 26 | 27 | public String getLabel() { 28 | return label; 29 | } 30 | 31 | public void setLabel(String label) { 32 | this.label = label; 33 | } 34 | 35 | public edge(int source, int target, String label, int length, int colorId, String markerEnd) { 36 | this.source = source; 37 | this.target = target; 38 | this.label = label; 39 | this.length = length; 40 | this.colorId = colorId; 41 | this.markerEnd = markerEnd; 42 | } 43 | 44 | public String toString4d3(){ 45 | return String.format("source: %d, target: %d, label: \"%s\", len: %d, color: %d, markerend: \"%s\"",source,target,label,length, colorId,markerEnd); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/utils/GraphVisualizer/vertex.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.utils.GraphVisualizer; 2 | 3 | public class vertex { 4 | private String uniqueid; 5 | private String text; 6 | private int colorId; 7 | 8 | public vertex(String uniqueid, String text, int colorId) { 9 | this.uniqueid = uniqueid; 10 | this.text = text; 11 | this.colorId = colorId; 12 | } 13 | 14 | public boolean equals(vertex v2){ 15 | return uniqueid.equals(v2.uniqueid); 16 | } 17 | 18 | public String getUniqueid() { 19 | return uniqueid; 20 | } 21 | 22 | public String getText() { 23 | return text; 24 | } 25 | 26 | public String toString4d3(){ 27 | return String.format("name:\"%s\", color: %d", toString(),colorId); 28 | } 29 | 30 | public String toString(){ 31 | return uniqueid+":"+text; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/utils/IO/myIOUtils.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.utils.IO; 2 | 3 | import edu.illinois.cs.cogcomp.core.io.IOUtils; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | import java.io.File; 7 | 8 | public class myIOUtils extends IOUtils { 9 | @NotNull 10 | public static String removeLastSeparatorIfExists(String path){ 11 | while(path.endsWith(File.separator))// hopefully we don't have cases like "/foo///.../" 12 | path = path.substring(0,path.length()-1); 13 | return path; 14 | } 15 | public static String getParentDir(String path){ 16 | path = removeLastSeparatorIfExists(path); 17 | int slashIndex = path.lastIndexOf(File.separator); 18 | return path.substring(0,slashIndex); 19 | } 20 | public static String getFileOrDirName(String path) { 21 | path = removeLastSeparatorIfExists(path); 22 | int slashIndex = path.lastIndexOf(File.separator); 23 | return path.substring(slashIndex + 1); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/utils/IO/mySerialization.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.utils.IO; 2 | 3 | import java.io.*; 4 | 5 | public class mySerialization { 6 | private boolean verbose; 7 | 8 | public mySerialization() { 9 | verbose = true; 10 | } 11 | 12 | public mySerialization(boolean verbose) { 13 | this.verbose = verbose; 14 | } 15 | 16 | public void serialize(Object obj, String path) throws Exception{ 17 | File serializedFile = new File(path); 18 | FileOutputStream fileOut = new FileOutputStream(serializedFile.getPath()); 19 | ObjectOutputStream out = new ObjectOutputStream(fileOut); 20 | out.writeObject(obj); 21 | out.close(); 22 | fileOut.close(); 23 | if(verbose) 24 | System.out.println("Serialization of object has been saved to "+serializedFile.getPath()); 25 | } 26 | public Object deserialize(String path) throws Exception{ 27 | File serializedFile = new File(path); 28 | Object obj = null; 29 | if(serializedFile.exists()){ 30 | if(verbose) 31 | System.out.println("Serialization exists. Loading from "+serializedFile.getPath()); 32 | FileInputStream fileIn = new FileInputStream(serializedFile.getPath()); 33 | ObjectInputStream in = new ObjectInputStream(fileIn); 34 | obj = in.readObject(); 35 | in.close(); 36 | fileIn.close(); 37 | } 38 | else{ 39 | if(verbose) 40 | System.out.println("Serialization doesn't exist. Return null. "); 41 | } 42 | return obj; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/utils/ListSampler.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.utils; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Random; 6 | 7 | public class ListSampler { 8 | public interface ListElementLabeler{ 9 | boolean labeler(T element);// those elements with "True" labels won't be affected by samplingRate 10 | } 11 | 12 | ListElementLabeler listElementLabeler; 13 | 14 | public ListSampler(ListElementLabeler listElementLabeler) { 15 | this.listElementLabeler = listElementLabeler; 16 | } 17 | 18 | public double autoSelectSamplingRate(List list){ 19 | int cnt1 = 0, cnt2 = 0; 20 | for(T element:list){ 21 | if(listElementLabeler.labeler(element)) 22 | cnt1++; 23 | else 24 | cnt2++; 25 | } 26 | return 1.0*cnt1/cnt2; 27 | } 28 | public List ListSampling(List list, Random rng){ 29 | double samplingRate = autoSelectSamplingRate(list); 30 | return ListSampling(list,samplingRate,rng); 31 | } 32 | public List ListSampling(List list, double samplingRate, Random rng){ 33 | List newlist = new ArrayList<>(); 34 | for(T element:list){ 35 | if(listElementLabeler.labeler(element)) 36 | newlist.add(element); 37 | else{ 38 | if(samplingRate==1) 39 | newlist.add(element); 40 | else if(samplingRate<1){ 41 | if(rng.nextDouble() <= samplingRate) 42 | newlist.add(element); 43 | } 44 | else{ 45 | double tmp = samplingRate; 46 | for (; tmp > 1; tmp--) { 47 | newlist.add(element); 48 | } 49 | if (rng.nextDouble() <= tmp) 50 | newlist.add(element); 51 | } 52 | } 53 | } 54 | return newlist; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/utils/Triplet.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.utils; 2 | 3 | /** 4 | * Created by qning2 on 12/21/16. 5 | */ 6 | public class Triplet { 7 | private T first; 8 | private F second; 9 | private K third; 10 | public Triplet(T first, F second, K third){ 11 | this.first=first; 12 | this.second=second; 13 | this.third=third; 14 | } 15 | 16 | public T getFirst() { 17 | return first; 18 | } 19 | 20 | public void setFirst(T first) { 21 | this.first = first; 22 | } 23 | 24 | public F getSecond() { 25 | return second; 26 | } 27 | 28 | public void setSecond(F second) { 29 | this.second = second; 30 | } 31 | 32 | public K getThird() { 33 | return third; 34 | } 35 | 36 | public void setThird(K third) { 37 | this.third = third; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/utils/WordNet/SynsetNode.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.utils.WordNet; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * @author qning2 Apr 24, 2018 8 | */ 9 | public class SynsetNode { 10 | 11 | public String nodeId; 12 | public List words = null; 13 | public List hyperIds = null; 14 | public List entailIds = null; 15 | public List antonIds = null; 16 | public List derivationIds = null; 17 | 18 | public SynsetNode() { 19 | nodeId = "NULL"; 20 | words = new ArrayList(); 21 | hyperIds = new ArrayList(); 22 | entailIds = new ArrayList(); 23 | antonIds = new ArrayList(); 24 | derivationIds = new ArrayList(); 25 | } 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/main/java/edu/illinois/cs/cogcomp/temporal/utils/myLogFormatter.java: -------------------------------------------------------------------------------- 1 | package edu.illinois.cs.cogcomp.temporal.utils; 2 | 3 | import java.util.Arrays; 4 | 5 | public class myLogFormatter { 6 | public static int gap = 5; 7 | public static int level = 0; 8 | private static char[] tagsLevel = new char[]{'#','*','+','-','.'}; 9 | private static char tagAtLevel(){ 10 | if(level<0) 11 | return tagsLevel[0]; 12 | if(level>=tagsLevel.length) 13 | return tagsLevel[tagsLevel.length-1]; 14 | return tagsLevel[level]; 15 | } 16 | public static String fullBlockLog(String label){ 17 | char tag = tagAtLevel(); 18 | label = label.replaceAll("\n"," ");//make sure it's oneline 19 | int len = label.length(); 20 | StringBuilder sb = new StringBuilder(); 21 | sb.append(lineOfTag(tag,len+gap*2)); 22 | sb.append("\n"); 23 | sb.append(middleBlockLog(label)); 24 | sb.append(lineOfTag(tag,len+gap*2)); 25 | sb.append("\n"); 26 | return sb.toString(); 27 | } 28 | public static String startBlockLog(String label){ 29 | char tag = tagAtLevel(); 30 | label = label.replaceAll("\n"," ");//make sure it's oneline 31 | int len = label.length(); 32 | StringBuilder sb = new StringBuilder(); 33 | sb.append(lineOfTag(tag,len+gap*2)); 34 | sb.append("\n"); 35 | sb.append(middleBlockLog(label)); 36 | level++; 37 | if(level>=tagsLevel.length) 38 | level = tagsLevel.length-1; 39 | return sb.toString(); 40 | } 41 | public static String endBlockLog(String label){ 42 | level--; 43 | if(level<0) 44 | level = 0; 45 | char tag = tagAtLevel(); 46 | label = label.replaceAll("\n"," ");//make sure it's oneline 47 | int len = label.length(); 48 | StringBuilder sb = new StringBuilder(); 49 | sb.append(middleBlockLog(label)); 50 | sb.append(lineOfTag(tag,len+gap*2)); 51 | sb.append("\n"); 52 | return sb.toString(); 53 | } 54 | public static String middleBlockLog(String label){ 55 | char tag = tagAtLevel(); 56 | label = label.replaceAll("\n"," ");//make sure it's oneline 57 | int len = label.length(); 58 | StringBuilder sb = new StringBuilder(); 59 | sb.append(tag); 60 | sb.append(lineOfTag(' ',len+gap*2-2)); 61 | sb.append(tag+"\n"+tag); 62 | sb.append(lineOfTag(' ',gap-1)); 63 | sb.append(label); 64 | sb.append(lineOfTag(' ',gap-1)); 65 | sb.append(tag+"\n"+tag); 66 | sb.append(lineOfTag(' ',len+gap*2-2)); 67 | sb.append(tag+"\n"); 68 | return sb.toString(); 69 | } 70 | public static String lineOfTag(char tag, int len){ 71 | char[] line = new char[len]; 72 | Arrays.fill(line,tag); 73 | return String.valueOf(line); 74 | } 75 | 76 | public static void main(String[] args) { 77 | System.out.println(startBlockLog("testtesttest")); 78 | System.out.println(startBlockLog("testtesttest")); 79 | System.out.println(endBlockLog("testtesttest")); 80 | System.out.println(endBlockLog("testtesttest")); 81 | } 82 | } 83 | --------------------------------------------------------------------------------