コード例 #1
0
  @Override
  public void getLexiconEntries(
      int spanStart,
      int spanEnd,
      AnnotatedSentence sentence,
      ChartEntry[] alreadyGenerated,
      int numAlreadyGenerated,
      List<Object> triggerAccumulator,
      List<CcgCategory> accumulator,
      List<Double> probAccumulator) {
    WikiTableMentionAnnotation annotation =
        (WikiTableMentionAnnotation) sentence.getAnnotation(annotationName);
    List<String> mentions = annotation.getMentions();
    List<String> mentionTypes = annotation.getMentionTypes();
    List<Integer> starts = annotation.getTokenStarts();
    List<Integer> ends = annotation.getTokenEnds();
    for (int i = 0; i < starts.size(); i++) {
      if (spanStart == starts.get(i) && spanEnd == ends.get(i) - 1) {
        CcgCategory c = typeCategoryMap.get(mentionTypes.get(i));
        Expression2 newLf =
            Expression2.nested(c.getLogicalForm(), Expression2.stringValue(mentions.get(i)));
        CcgCategory newCategory = c.replaceLogicalForm(newLf);

        triggerAccumulator.add(mentions.get(i));
        accumulator.add(newCategory);
        probAccumulator.add(1.0);
      }
    }
  }
コード例 #2
0
  public CcgExactHashTableChart(AnnotatedSentence input, int maxChartSize) {
    super(input, maxChartSize);
    numTerminals = input.size();

    this.chart = new ChartEntry[numTerminals][numTerminals][NUM_INITIAL_SPAN_ENTRIES];
    this.probabilities = new double[numTerminals][numTerminals][NUM_INITIAL_SPAN_ENTRIES];
    this.populatedIndexes = new int[numTerminals][numTerminals][NUM_INITIAL_SPAN_ENTRIES];
    this.numPopulatedIndexes = new int[numTerminals][numTerminals];

    this.chartList = new ChartEntry[numTerminals][numTerminals][];
    this.probabilitiesList = new double[numTerminals][numTerminals][];
    this.chartSizes = new int[numTerminals][numTerminals];

    this.chartEntriesBySyntacticCategory = new IntMultimap[numTerminals][numTerminals];

    this.totalChartSize = 0;
  }