Esempio n. 1
0
  @Override
  public String produceValue(
      Annotation np1, Annotation np2, Document doc, Map<Feature, String> featVector) {

    if (!ProperName.getValue(np1, doc) || !ProperName.getValue(np2, doc)) return NA;
    Annotation ne1 = (Annotation) np1.getProperty(Property.LINKED_PROPER_NAME);
    Annotation ne2 = (Annotation) np2.getProperty(Property.LINKED_PROPER_NAME);
    String[] infW1 = InfWords.getValue(ne1, doc);
    String[] infW2 = InfWords.getValue(ne2, doc);
    if (infW1 == null || infW2 == null || infW1.length < 1 || infW2.length < 1) return INCOMPATIBLE;
    if (Utils.isAnySubset(infW1, infW2)) return COMPATIBLE;
    else return INCOMPATIBLE;
  }
Esempio n. 2
0
  @Override
  public Object produceValue(Annotation np, Document doc) {
    // Get the sentence annotations
    AnnotationSet par = doc.getAnnotationSet(Constants.PAR);
    AnnotationSet nps = doc.getAnnotationSet(Constants.NP);

    for (Annotation p : par) {
      int num;
      if (Constants.PAR_NUMS_UNAVAILABLE) {
        num = 0;
      } else {
        num = Integer.parseInt(p.getAttribute("parNum"));
      }
      AnnotationSet enclosed = nps.getContained(p);
      for (Annotation e : enclosed) {
        e.setProperty(this, num);
      }
    }

    // Make sure that all annotations have an associated PARNUM
    for (Annotation n : nps) {
      if (n.getProperty(this) == null) {
        AnnotationSet o = par.getOverlapping(0, n.getEndOffset());
        if (o == null || o.size() < 1) {
          n.setProperty(this, 0);
        } else {
          Annotation p = o.getLast();
          int num = Integer.parseInt(p.getAttribute("parNum")); // = 0;
          n.setProperty(this, num);
        }
      }
    }

    if (np.getProperty(this) == null) {
      AnnotationSet o = par.getOverlapping(0, np.getEndOffset());
      if (o == null || o.size() < 1) {
        np.setProperty(this, 0);
      } else {
        Annotation p = o.getLast();
        int num = Integer.parseInt(p.getAttribute("parNum"));
        np.setProperty(this, num);
      }
    }

    return np.getProperty(this);
  }