@Override
  public SPhraseSpec generate() {
    Lexicon lexicon = Lexicon.getDefaultLexicon();
    NLGFactory nlgFactory = new NLGFactory(lexicon);

    SPhraseSpec s = nlgFactory.createClause();

    s.setFrontModifier("moreover");

    NPPhraseSpec secondDive = nlgFactory.createNounPhrase("dive");
    secondDive.setDeterminer("your");
    secondDive.setPreModifier("second");

    VPPhraseSpec be = nlgFactory.createVerbPhrase("be");
    NLGElement predicative = nlgFactory.createInflectedWord("deep", LexicalCategory.ADVERB);
    predicative.setFeature(Feature.IS_COMPARATIVE, true);
    be.addComplement(predicative);

    PPPhraseSpec than = nlgFactory.createPrepositionPhrase("than");
    NPPhraseSpec firstDive = nlgFactory.createNounPhrase("one");
    firstDive.setDeterminer("the");
    firstDive.setPreModifier("first");
    than.addComplement(firstDive);

    s.setSubject(secondDive);
    s.setVerb(be);
    s.addComplement(than);
    s.setFeature(Feature.TENSE, Tense.PAST);

    SPhraseSpec which = nlgFactory.createClause();
    VPPhraseSpec beNot = nlgFactory.createVerbPhrase("be");
    beNot.setFeature(Feature.NEGATED, true);

    NLGElement recommended = nlgFactory.createAdjectivePhrase("recommended");
    beNot.addComplement(recommended);
    beNot.addModifier("really");
    which.setVerb(beNot);

    which.setFeature(Feature.COMPLEMENTISER, "which");
    s.addComplement(which);

    return s;
  }
Exemple #2
0
 /**
  * Takes a DBPedia class and returns the correct label for it
  *
  * @param className Name of a class
  * @return Label
  */
 public NPPhraseSpec getNPPhrase(String className, boolean plural) {
   NPPhraseSpec object = null;
   if (className.equals(OWL.Thing.getURI())) {
     object = nlgFactory.createNounPhrase(GenericType.ENTITY.getNlr());
   } else if (className.equals(RDFS.Literal.getURI())) {
     object = nlgFactory.createNounPhrase(GenericType.VALUE.getNlr());
   } else if (className.equals(RDF.Property.getURI())) {
     object = nlgFactory.createNounPhrase(GenericType.RELATION.getNlr());
   } else if (className.equals(RDF.type.getURI())) {
     object = nlgFactory.createNounPhrase(GenericType.TYPE.getNlr());
   } else {
     String label = uriConverter.convert(className);
     if (label != null) {
       object = nlgFactory.createNounPhrase(label);
     } else {
       object = nlgFactory.createNounPhrase(GenericType.ENTITY.getNlr());
     }
   }
   object.setPlural(plural);
   return object;
 }
Exemple #3
0
 private NLGElement processTypes(
     Map<String, Set<String>> typeMap, Set<String> vars, boolean count, boolean distinct) {
   List<NPPhraseSpec> objects = new ArrayList<NPPhraseSpec>();
   // process the type information to create the object(s)
   for (String s : typeMap.keySet()) {
     if (vars.contains(s)) {
       // contains the objects to the sentence
       NPPhraseSpec object;
       object = nlgFactory.createNounPhrase("?" + s);
       Set<String> types = typeMap.get(s);
       if (types.size() == 1) {
         NPPhraseSpec np = getNPPhrase(types.iterator().next(), true);
         if (distinct) {
           np.addModifier("distinct");
         }
         object.addPreModifier(np);
       } else {
         Iterator<String> typeIterator = types.iterator();
         String type0 = typeIterator.next();
         String type1 = typeIterator.next();
         NPPhraseSpec np0 = getNPPhrase(type0, true);
         //                        if (distinct) {
         //                            np0.addModifier("distinct");
         //                        }
         NPPhraseSpec np1 = getNPPhrase(type1, true);
         //                        if (distinct) {
         //                            np1.addModifier("distinct");
         //                        }
         CoordinatedPhraseElement cpe = nlgFactory.createCoordinatedPhrase(np0, np1);
         while (typeIterator.hasNext()) {
           NPPhraseSpec np = getNPPhrase(typeIterator.next(), true);
           //                        if (distinct) {
           //                            np.addModifier("distinct");
           //                        }
           cpe.addCoordinate(np);
         }
         cpe.setConjunction("as well as");
         if (distinct) {
           cpe.addPreModifier("distinct");
         }
         object.addPreModifier(cpe);
       }
       object.setFeature(Feature.CONJUNCTION, "or");
       objects.add(object);
     }
   }
   if (objects.size() == 1) {
     // if(count) objects.get(0).addPreModifier("the number of");
     return objects.get(0);
   } else {
     CoordinatedPhraseElement cpe =
         nlgFactory.createCoordinatedPhrase(objects.get(0), objects.get(1));
     if (objects.size() > 2) {
       for (int i = 2; i < objects.size(); i++) {
         cpe.addCoordinate(objects.get(i));
       }
     }
     // if(count) cpe.addPreModifier("the number of");
     return cpe;
   }
 }