Exemple #1
0
  private boolean match(
      SyntacticChunk chunk, PatternElement patternElement, int baseTokenIndex, Sentence sentence) {
    // System.out.println(RuleUtils.getPatternElementAsString(patternElement));
    if (patternElement.getElement() != null)
      return match(chunk, patternElement.getElement(), baseTokenIndex, sentence);

    if (patternElement.getComposition().getAnd() != null) {
      List<PatternElement> l = patternElement.getComposition().getAnd().getPatternElement();
      for (PatternElement pe : l) {
        boolean match = match(chunk, pe, baseTokenIndex, sentence);
        if (!match) return false;
      }
      return true;
    } else {
      if (patternElement.getComposition().getOr() != null) {
        List<PatternElement> l = patternElement.getComposition().getOr().getPatternElement();
        for (PatternElement pe : l) {
          boolean match = match(chunk, pe, baseTokenIndex, sentence);
          if (match) return true;
        }

        return false;
      }
    }
    LOGGER.error("Shouldn't get here.");
    return false;
  }
Exemple #2
0
  private boolean match(
      Token token, PatternElement patternElement, int baseTokenIndex, Sentence sentence) {
    if (patternElement.getElement() != null)
      return match(token, patternElement.getElement(), baseTokenIndex, sentence);

    if (patternElement.getComposition().getAnd() != null) {
      List<PatternElement> l = patternElement.getComposition().getAnd().getPatternElement();
      for (PatternElement pe : l) {
        boolean match = match(token, pe, baseTokenIndex, sentence);
        if (!match) return false;
      }
      return true;
    } else {
      if (patternElement.getComposition().getOr() != null) {
        List<PatternElement> l = patternElement.getComposition().getOr().getPatternElement();
        for (PatternElement pe : l) {
          boolean match = match(token, pe, baseTokenIndex, sentence);
          if (match) return true;
        }

        return false;
      }
    }
    LOGGER.error("Shouldn't get here.");
    return false;
  }