Commit e79fae0c authored by Bruno López Trigo's avatar Bruno López Trigo

Añadida explicación más precisa de las reglas en el LanguageRealiser

parent 3447b73e
......@@ -3,7 +3,7 @@
<antecedents>
<antecedent>
<attribute name="Strength">
<value>0.038</value>
<value>0.04</value>
<textValue>Session</textValue>
<maxValue>0.136</maxValue>
<minValue>0.035</minValue>
......@@ -40,13 +40,13 @@
</attribute>
<interval>
<leftValue>0.035</leftValue>
<rightValue>0.057</rightValue>
<rightValue>0.07</rightValue>
</interval>
</antecedent>
<antecedent>
<attribute name="Color">
<value>10.0</value>
<textValue>Amber</textValue>
<value>20.0</value>
<textValue>Brown</textValue>
<maxValue>45.0</maxValue>
<minValue>0.0</minValue>
<properties>
......@@ -88,13 +88,13 @@
</properties>
</attribute>
<interval>
<leftValue>6.0</leftValue>
<rightValue>17.0</rightValue>
<leftValue>17.0</leftValue>
<rightValue>29.0</rightValue>
</interval>
</antecedent>
</antecedents>
<consequent>
<code>2.0</code>
<text>2.0</text>
<code>7.0</code>
<text>7.0</text>
</consequent>
</rule>
......@@ -89,6 +89,16 @@ public class Attribute {
return properties;
}
public Property getPropertyByTxt(String property) {
for (Property p: this.properties){
if(p.getValueTxt().toLowerCase().equals(property))
return p;
}
return null;
}
public void addProperty(Property prop){
this.properties.add(prop);
}
......
......@@ -39,14 +39,27 @@ public class LanguageRealiser implements LanguageRealiserInterface {
ArrayList<String> labelList = new ArrayList<>();
boolean fullCoincidence = false;
SPhraseSpec sentenceInterval;
SPhraseSpec explanationInterval;
NPPhraseSpec subjectInterval;
VPPhraseSpec verbInterval = this.nlgFactory.createVerbPhrase("be");
CoordinatedPhraseElement intervals;
Property property;
for(Antecedent ant: rule.getAntecedents()){
// Frase valor está entre intervalo
sentence = this.nlgFactory.createClause();
sentenceInterval = this.nlgFactory.createClause();
explanationInterval = this.nlgFactory.createClause();
intervals = this.nlgFactory.createCoordinatedPhrase();
subjectInterval = this.nlgFactory.createNounPhrase("interval");
subjectInterval.addModifier("possible");
subject = this.nlgFactory.createNounPhrase("its", ant.getAttribute().getName().toLowerCase());
sentence.setSubject(subject);
sentence.setVerb(verb);
sentence.addComplement("between " + String.valueOf(ant.getInterval().getLeftValue()) + " and " + String.valueOf(ant.getInterval().getRightValue()));
phrases.add(sentence);
sentenceInterval.setSubject(subject);
sentenceInterval.setVerb(verb);
sentenceInterval.addComplement("between " + String.valueOf(ant.getInterval().getLeftValue()) + " and " + String.valueOf(ant.getInterval().getRightValue()));
// Frase valor es propiedad
sentence = this.nlgFactory.createClause();
sentence.setSubject(subject);
......@@ -57,14 +70,21 @@ public class LanguageRealiser implements LanguageRealiserInterface {
if(entry.getValue()==1.0 && !fullCoincidence){
labelList.clear();
labelList.add(entry.getKey());
property = ant.getAttribute().getPropertyByTxt(entry.getKey());
intervals.addCoordinate("[" + property.getInterval().getLeftValue() + ", " + property.getInterval().getRightValue() + "] as \"" + entry.getKey() + "\"");
fullCoincidence = true;
}
else if(entry.getValue()==1.0){
property = ant.getAttribute().getPropertyByTxt(entry.getKey());
intervals.addCoordinate("[" + property.getInterval().getLeftValue() + ", " + property.getInterval().getRightValue() + "] as \"" + entry.getKey() + "\"");
labelList.add(entry.getKey());
}
else if(!fullCoincidence)
else if(!fullCoincidence){
property = ant.getAttribute().getPropertyByTxt(entry.getKey());
intervals.addCoordinate("[" + property.getInterval().getLeftValue() + ", " + property.getInterval().getRightValue() + "] as \"" + entry.getKey() + "\"");
labelList.add(entry.getKey());
}
}
if(labelList.size()>1){
......@@ -74,11 +94,19 @@ public class LanguageRealiser implements LanguageRealiserInterface {
}
types.setConjunction("or");
sentence.addComplement(types);
subjectInterval.setPlural(true);
}
else{
sentence.addComplement(labelList.get(0));
}
explanationInterval.setSubject(subjectInterval);
explanationInterval.setVerb(verbInterval);
sentenceInterval.setFeature(Feature.COMPLEMENTISER, "while");
explanationInterval.setObject(intervals);
explanationInterval.addComplement(sentenceInterval);
phrases.add(explanationInterval);
phrases.add(sentence);
fullCoincidence = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment