Пример #1
0
  /*
   * Returns 0 - If NA 1 - If Incompatible 2 - If compatible
   */
  public static int sameSemanticClass(Annotation np1, Annotation np2, Document doc) {

    NPSemTypeEnum type1 = NPSemanticType.getValue(np1, doc);
    NPSemTypeEnum type2 = NPSemanticType.getValue(np2, doc);

    if (type1.equals(type2) && !type1.equals(NPSemTypeEnum.UNKNOWN)) return 2;

    String[] wn_senses1 = WNSemClass.getValue(np1, doc);
    String[] wn_senses2 = WNSemClass.getValue(np2, doc);

    if (wn_senses1.length < 1 || wn_senses2.length < 1) return 0;

    for (String s : COMP_SUPERTYPES) {
      if (memberArray(s, wn_senses1) && memberArray(s, wn_senses2)) return 2;
    }

    if (overlaps(wn_senses1, wn_senses2)) {
      if (FeatureUtils.isPronoun(np1, doc) || FeatureUtils.isPronoun(np2, doc)) return 2;
      String[] w1 = doc.getWords(np1);
      String[] w2 = doc.getWords(np2);
      if (intersection(w1, w2) > 0) return 2;
    }

    return 1;
  }
Пример #2
0
  public static boolean isIndefinite(Annotation np, Document doc) {

    String[] indefs = {"a", "an", "one"};
    String[] words = doc.getWords(np);
    String first = words[0];
    return memberArray(first, indefs);
    /*
    if(memberArray(first, defs))
    	return false;
    if(isPronoun(first))
    	return false;
    if(containsProperName(np, annotations, text))
    	return false;
    return true;*/
  }
Пример #3
0
 public static ArticleTypeEnum articleType(Annotation np, Document doc) {
   String[] indefs = {"a", "an", "one"};
   // String[] defs = { "the", "this", "that", "these", "those" };
   String[] quans = {"every", "all", "some", "most", "few", "many", "much"};
   String[] words = doc.getWords(np);
   String first = words[0];
   if (ProperName.getValue(np, doc)) return ArticleTypeEnum.DEFINITE;
   if (isPronoun(np, doc)) return ArticleTypeEnum.DEFINITE;
   if (memberArray(first, indefs)) return ArticleTypeEnum.INDEFINITE;
   if (memberArray(first, quans)) {
     if (words.length < 2 || !words[1].equalsIgnoreCase("of")) return ArticleTypeEnum.QUANTIFIED;
     else return ArticleTypeEnum.DEFINITE;
   }
   AnnotationSet pos = doc.getAnnotationSet(Constants.POS);
   pos = pos.getContained(np);
   if (pos != null && pos.size() > 0) {
     if (isCardinalNumber(pos.getFirst()) || isPredeterminer(pos.getFirst()))
       return ArticleTypeEnum.QUANTIFIED;
     if (isPossesivePronoun(pos.getFirst()) || isProperNoun(pos.getLast()))
       return ArticleTypeEnum.DEFINITE;
   }
   return ArticleTypeEnum.INDEFINITE;
 }