public List<TimeExpression> extractTimeExpressions(CoreMap annotation, String docDateStr) {
    List<CoreMap> mergedNumbers = NumberNormalizer.findAndMergeNumbers(annotation);
    annotation.set(CoreAnnotations.NumerizedTokensAnnotation.class, mergedNumbers);

    // TODO: docDate may not have century....
    SUTime.Time docDate = timexPatterns.parseDateTime(docDateStr);

    List<? extends MatchedExpression> matchedExpressions =
        expressionExtractor.extractExpressions(annotation);
    List<TimeExpression> timeExpressions = new ArrayList<TimeExpression>(matchedExpressions.size());
    for (MatchedExpression expr : matchedExpressions) {
      if (expr instanceof TimeExpression) {
        timeExpressions.add((TimeExpression) expr);
      } else {
        timeExpressions.add(new TimeExpression(expr));
      }
    }

    // Add back nested time expressions for ranges....
    // For now only one level of nesting...
    if (options.includeNested) {
      List<TimeExpression> nestedTimeExpressions = new ArrayList<TimeExpression>();
      for (TimeExpression te : timeExpressions) {
        if (te.isIncludeNested()) {
          List<? extends CoreMap> children =
              te.getAnnotation().get(TimeExpression.ChildrenAnnotation.class);
          if (children != null) {
            for (CoreMap child : children) {
              TimeExpression childTe = child.get(TimeExpression.Annotation.class);
              if (childTe != null) {
                nestedTimeExpressions.add(childTe);
              }
            }
          }
        }
      }
      timeExpressions.addAll(nestedTimeExpressions);
    }
    Collections.sort(timeExpressions, MatchedExpression.EXPR_TOKEN_OFFSETS_NESTED_FIRST_COMPARATOR);
    timeExpressions = filterInvalidTimeExpressions(timeExpressions);

    // Some resolving is done even if docDate null...
    if (
    /*docDate != null && */ timeExpressions != null) {
      resolveTimeExpressions(annotation, timeExpressions, docDate);
    }
    // Annotate timex
    return timeExpressions;
  }
 public void init(Options options) {
   this.options = options;
   timexPatterns = new TimeExpressionPatterns(options);
   // TODO: does not allow for multiple loggers
   if (options.verbose) {
     logger.setLevel(Level.FINE);
   } else {
     logger.setLevel(Level.SEVERE);
   }
   NumberNormalizer.setVerbose(options.verbose);
   if (options.grammarFilename != null) {
     List<String> filenames = StringUtils.split(options.grammarFilename, "\\s*[,;]\\s*");
     this.expressionExtractor =
         CoreMapExpressionExtractor.createExtractorFromFiles(timexPatterns.env, filenames);
     // this.expressionExtractor =
     // CoreMapExpressionExtractor.createExtractorFromFile(timexPatterns.env,
     // options.grammarFilename);
   } else {
     this.expressionExtractor = new CoreMapExpressionExtractor();
     this.expressionExtractor.setExtractRules(
         timexPatterns.getTimeExtractionRule(), timexPatterns.getCompositeTimeExtractionRule());
   }
   this.expressionExtractor.setLogger(logger);
 }