コード例 #1
0
ファイル: SimpleNLG.java プロジェクト: QTL2/SemWeb2NL
  public SimpleNLG(SparqlEndpoint endpoint) {
    this.endpoint = endpoint;

    lexicon = Lexicon.getDefaultLexicon();
    nlgFactory = new NLGFactory(lexicon);
    realiser = new Realiser(lexicon);

    uriConverter = new DefaultIRIConverter(endpoint);
    literalConverter = new LiteralConverter(uriConverter);
    expressionConverter = new FilterExpressionConverter(uriConverter, literalConverter);
  }
コード例 #2
0
  @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;
  }