Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 import java.util.List;
 public class TimidBaselineEventTimeRelationAnnotator extends RelationExtractorAnnotator {
   public static AnalysisEngineDescription createAnnotatorDescription(File modelDirectory)
       throws ResourceInitializationException {
     return AnalysisEngineFactory.createEngineDescription(
         new File(modelDirectory"model.jar"));
 	protected Class<? extends AnnotationgetCoveringClass() {
 		return Sentence.class;
   public List<IdentifiedAnnotationPair> getCandidateRelationArgumentPairs(
       JCas jCas,
       Annotation sentence) {
     List<EventMentionevents = JCasUtil.selectCovered(jCasEventMention.classsentence);
     List<TimeMentiontimes = JCasUtil.selectCovered(jCasTimeMention.classsentence);
     if(times.size() != 1 || events.size() < 1) {
       return Lists.newArrayList();
     // compute token distance for each time-event pair
     HashMap<IdentifiedAnnotationPair, IntegerdistanceLookup = new HashMap<IdentifiedAnnotationPair, Integer>();
     for (EventMention event : events) {
       // ignore subclasses like Procedure and Disease/Disorder
       if (event.getClass().equals(EventMention.class)) {
         for (TimeMention time : times) {
           IdentifiedAnnotationPair pair = new IdentifiedAnnotationPair(timeevent);
           List<BaseTokenbaseTokens = JCasUtil.selectBetween(jCasBaseToken.classpair.getArg1(), pair.getArg2());
           int distance = baseTokens.size();
     // find the pair where the distance between entities is the smallest and return it
     List<IdentifiedAnnotationPair> rankedPairs = new ArrayList<IdentifiedAnnotationPair>(distanceLookup.keySet());
     Function<IdentifiedAnnotationPair, IntegergetValue = Functions.forMap(distanceLookup);
     Collections.sort(rankedPairs, Ordering.natural().onResultOf(getValue));
     List<IdentifiedAnnotationPair> result = new ArrayList<IdentifiedAnnotationPair>();
     return result;
  public String classify(List<Feature> features) {
    return "CONTAINS";
New to GrepCode? Check out our FAQ X