rename qualia -> quality
This commit is contained in:
parent
b62d5b2e66
commit
72e41f231c
@ -3,6 +3,7 @@
|
||||
"dependencies" : [
|
||||
"./data/webs/philosophy/concept.json",
|
||||
"./data/webs/philosophy/person/person.json",
|
||||
"./data/webs/philosophy/person/self.json"
|
||||
"./data/webs/philosophy/person/self.json",
|
||||
"./data/webs/philosophy/quality/quality.json"
|
||||
]
|
||||
}
|
||||
@ -15,7 +15,7 @@
|
||||
"id" : 0,
|
||||
"name" : "instanceOf",
|
||||
"parent" : 0,
|
||||
"parentWeb" : "qualia",
|
||||
"parentWeb" : "quality",
|
||||
"child" : 0
|
||||
},
|
||||
"1" : {
|
||||
@ -1,15 +1,15 @@
|
||||
{
|
||||
"tag" : "qualia",
|
||||
"tag" : "quality",
|
||||
"nodes" : {
|
||||
"0" : {
|
||||
"id" : 0,
|
||||
"name" : "qualia"
|
||||
"name" : "quality"
|
||||
}
|
||||
},
|
||||
"anchors" : {
|
||||
"qualia" : 0
|
||||
"quality" : 0
|
||||
},
|
||||
"dependencies" : [
|
||||
"./data/webs/qualia/color.json"
|
||||
"./data/webs/philosophy/quality/color.json"
|
||||
]
|
||||
}
|
||||
@ -22,7 +22,7 @@
|
||||
"1" : {
|
||||
"comment" : "The color of bert's hat is blue",
|
||||
"id" : 1,
|
||||
"name" : "qualiaOf",
|
||||
"name" : "qualityOf",
|
||||
"parent" : 1,
|
||||
"parentWeb" : "color",
|
||||
"child" : 9
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
},
|
||||
"dependencies" : [
|
||||
"./data/webs/linguistics/linguistics.json",
|
||||
"./data/webs/philosophy/philosophy.json",
|
||||
"./data/webs/qualia/qualia.json"
|
||||
"./data/webs/philosophy/philosophy.json"
|
||||
]
|
||||
}
|
||||
@ -3,7 +3,7 @@
|
||||
A list of things to consider fleshing out in the web
|
||||
|
||||
|
||||
Qualia
|
||||
Qualities of an object
|
||||
|
||||
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ import org.studiorailgun.conversation.tracking.Quote;
|
||||
import org.studiorailgun.conversation.tracking.Sentence;
|
||||
import org.studiorailgun.knowledge.Node;
|
||||
import org.studiorailgun.knowledge.query.InstanceQuery;
|
||||
import org.studiorailgun.knowledge.query.QualiaQuery;
|
||||
import org.studiorailgun.knowledge.query.QualityQuery;
|
||||
import org.studiorailgun.knowledge.query.filter.PossessionQueryFilter;
|
||||
|
||||
/**
|
||||
@ -45,7 +45,7 @@ public class Interrogative {
|
||||
* @return null
|
||||
*/
|
||||
public static void evalWhichQuery(Conversation conversation, Quote quote, Sentence sentence, NounStack interrogative, NounStack items){
|
||||
if(QualiaQuery.isQualiaClarificationQuery(interrogative)){
|
||||
if(QualityQuery.isQualityClarificationQuery(interrogative)){
|
||||
Node finalQualifier = InstanceQuery.getConcept(items.indexedWord.originalText());
|
||||
|
||||
if(items.possessive != null){
|
||||
@ -53,9 +53,9 @@ public class Interrogative {
|
||||
finalQualifier = PossessionQueryFilter.withPossessor(qualifierInstances, Globals.web.getAnchors().getSelfNode());
|
||||
}
|
||||
|
||||
List<Node> qualiaOfInstance = QualiaQuery.getQualiaOfInstance(finalQualifier);
|
||||
List<Node> qualitiesOfInstance = QualityQuery.getQualitiesOfInstance(finalQualifier);
|
||||
|
||||
Node qualiaType = QualiaQuery.getRequestedQualiaType(interrogative);
|
||||
Node qualityType = QualityQuery.getRequestedQualityType(interrogative);
|
||||
|
||||
conversation.getGoalData().getQueryData().getRecentQueries().add(sentence);
|
||||
} else {
|
||||
@ -72,7 +72,7 @@ public class Interrogative {
|
||||
* @return null
|
||||
*/
|
||||
public static void evalWhatQuery(Conversation conversation, Quote quote, Sentence sentence, NounStack interrogative, NounStack items){
|
||||
if(QualiaQuery.isQualiaClarificationQuery(interrogative)){
|
||||
if(QualityQuery.isQualityClarificationQuery(interrogative)){
|
||||
Node finalQualifier = InstanceQuery.getConcept(items.indexedWord.originalText());
|
||||
|
||||
if(items.possessive != null){
|
||||
@ -80,9 +80,9 @@ public class Interrogative {
|
||||
finalQualifier = PossessionQueryFilter.withPossessor(qualifierInstances, Globals.web.getAnchors().getSelfNode());
|
||||
}
|
||||
|
||||
List<Node> qualiaOfInstance = QualiaQuery.getQualiaOfInstance(finalQualifier);
|
||||
List<Node> qualitiesOfInstance = QualityQuery.getQualitiesOfInstance(finalQualifier);
|
||||
|
||||
Node qualiaType = QualiaQuery.getRequestedQualiaType(interrogative);
|
||||
Node qualityType = QualityQuery.getRequestedQualityType(interrogative);
|
||||
|
||||
conversation.getGoalData().getQueryData().getRecentQueries().add(sentence);
|
||||
} else {
|
||||
|
||||
@ -11,7 +11,7 @@ import org.studiorailgun.conversation.tracking.Quote;
|
||||
import org.studiorailgun.conversation.tracking.Sentence;
|
||||
import org.studiorailgun.knowledge.Node;
|
||||
import org.studiorailgun.knowledge.query.InstanceQuery;
|
||||
import org.studiorailgun.knowledge.query.QualiaQuery;
|
||||
import org.studiorailgun.knowledge.query.QualityQuery;
|
||||
import org.studiorailgun.knowledge.query.filter.InstanceQueryFilter;
|
||||
import org.studiorailgun.knowledge.query.filter.PossessionQueryFilter;
|
||||
|
||||
@ -31,7 +31,7 @@ public class Interrogative {
|
||||
public static String evalWhichQuery(Conversation conversation, Quote quote, Sentence sentence, NounStack interrogative, NounStack items){
|
||||
|
||||
//get the thing that has the quality
|
||||
if(QualiaQuery.isQualiaClarificationQuery(interrogative)){
|
||||
if(QualityQuery.isQualityClarificationQuery(interrogative)){
|
||||
Node finalQualifier = InstanceQuery.getConcept(items.getIndexedWord().originalText());
|
||||
if(items.getPossessive() != null){
|
||||
List<Node> qualifierInstances = InstanceQuery.getInstances(finalQualifier);
|
||||
@ -39,14 +39,14 @@ public class Interrogative {
|
||||
}
|
||||
|
||||
//get the actual qualities that we care about
|
||||
List<Node> qualiaOfInstance = QualiaQuery.getQualiaOfInstance(finalQualifier);
|
||||
Node qualiaType = QualiaQuery.getRequestedQualiaType(interrogative);
|
||||
List<Node> applicableQualities = InstanceQueryFilter.filter(qualiaOfInstance, qualiaType);
|
||||
List<Node> qualitiesOfInstance = QualityQuery.getQualitiesOfInstance(finalQualifier);
|
||||
Node qualityType = QualityQuery.getRequestedQualityType(interrogative);
|
||||
List<Node> applicableQualities = InstanceQueryFilter.filter(qualitiesOfInstance, qualityType);
|
||||
|
||||
//synthesize
|
||||
String subject = NounStackSynthesizer.synthesize(finalQualifier, items.getPossessive() != null);
|
||||
String verb = "is";
|
||||
String object = QualitySynthesizer.synthesize(applicableQualities, qualiaType);
|
||||
String object = QualitySynthesizer.synthesize(applicableQualities, qualityType);
|
||||
|
||||
return subject + " " + verb + " " + object;
|
||||
} else {
|
||||
@ -63,7 +63,7 @@ public class Interrogative {
|
||||
* @return null
|
||||
*/
|
||||
public static String evalWhatQuery(Conversation conversation, Quote quote, Sentence sentence, NounStack interrogative, NounStack items){
|
||||
if(QualiaQuery.isQualiaClarificationQuery(interrogative)){
|
||||
if(QualityQuery.isQualityClarificationQuery(interrogative)){
|
||||
|
||||
//get the thing that has the quality
|
||||
Node finalQualifier = InstanceQuery.getConcept(items.getIndexedWord().originalText());
|
||||
@ -73,14 +73,14 @@ public class Interrogative {
|
||||
}
|
||||
|
||||
//get the actual qualities that we care about
|
||||
List<Node> qualiaOfInstance = QualiaQuery.getQualiaOfInstance(finalQualifier);
|
||||
Node qualiaType = QualiaQuery.getRequestedQualiaType(interrogative);
|
||||
List<Node> applicableQualities = InstanceQueryFilter.filter(qualiaOfInstance, qualiaType);
|
||||
List<Node> qualitiesOfInstance = QualityQuery.getQualitiesOfInstance(finalQualifier);
|
||||
Node qualityType = QualityQuery.getRequestedQualityType(interrogative);
|
||||
List<Node> applicableQualities = InstanceQueryFilter.filter(qualitiesOfInstance, qualityType);
|
||||
|
||||
//synthesize
|
||||
String subject = NounStackSynthesizer.synthesize(finalQualifier, items.getPossessive() != null);
|
||||
String verb = "is";
|
||||
String object = QualitySynthesizer.synthesize(applicableQualities, qualiaType);
|
||||
String object = QualitySynthesizer.synthesize(applicableQualities, qualityType);
|
||||
|
||||
return subject + " " + verb + " " + object;
|
||||
} else {
|
||||
|
||||
@ -21,9 +21,9 @@ public class AnchorNodes {
|
||||
Integer concept;
|
||||
|
||||
/**
|
||||
* The concept of a qualia
|
||||
* The concept of a quality
|
||||
*/
|
||||
Integer qualia;
|
||||
Integer quality;
|
||||
|
||||
/**
|
||||
* The concept of a name
|
||||
@ -85,30 +85,30 @@ public class AnchorNodes {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the idea of a qualia
|
||||
* @return The idea of a qualia
|
||||
* Gets the idea of a quality
|
||||
* @return The idea of a quality
|
||||
*/
|
||||
public Node getQualiaNode() {
|
||||
if(qualia == null){
|
||||
public Node getQualityNode() {
|
||||
if(quality == null){
|
||||
return null;
|
||||
}
|
||||
return Globals.web.getNode(qualia);
|
||||
return Globals.web.getNode(quality);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the qualia node
|
||||
* @param id The qualia node
|
||||
* Sets the quality node
|
||||
* @param id The quality node
|
||||
*/
|
||||
public void setQualia(int id){
|
||||
this.qualia = id;
|
||||
public void setQuality(int id){
|
||||
this.quality = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id for the qualia node
|
||||
* @return The id for the qualia node
|
||||
* Gets the id for the quality node
|
||||
* @return The id for the quality node
|
||||
*/
|
||||
public Integer getQualia(){
|
||||
return qualia;
|
||||
public Integer getQuality(){
|
||||
return quality;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,8 +150,8 @@ public class AnchorNodes {
|
||||
if(childAnchors.getSelf() != null){
|
||||
parentAnchors.setSelf(childAnchors.getSelf());
|
||||
}
|
||||
if(childAnchors.getQualia() != null){
|
||||
parentAnchors.setQualia(childAnchors.getQualia());
|
||||
if(childAnchors.getQuality() != null){
|
||||
parentAnchors.setQuality(childAnchors.getQuality());
|
||||
}
|
||||
if(childAnchors.getName() != null){
|
||||
parentAnchors.setName(childAnchors.getName());
|
||||
@ -180,11 +180,11 @@ public class AnchorNodes {
|
||||
newNodeId = crossRelationLookupMap.get(lookupId);
|
||||
this.setConcept(newNodeId);
|
||||
}
|
||||
if(this.getQualia() != null){
|
||||
oldId = this.getQualia();
|
||||
if(this.getQuality() != null){
|
||||
oldId = this.getQuality();
|
||||
lookupId = "node-" + tag + oldId;
|
||||
newNodeId = crossRelationLookupMap.get(lookupId);
|
||||
this.setQualia(newNodeId);
|
||||
this.setQuality(newNodeId);
|
||||
}
|
||||
if(this.getName() != null){
|
||||
oldId = this.getName();
|
||||
|
||||
@ -10,41 +10,41 @@ import org.studiorailgun.knowledge.query.filter.NameQueryFilter;
|
||||
import org.studiorailgun.knowledge.types.RelationTypes;
|
||||
|
||||
/**
|
||||
* Performs a qualia query
|
||||
* Performs a quality query
|
||||
*/
|
||||
public class QualiaQuery {
|
||||
public class QualityQuery {
|
||||
|
||||
/**
|
||||
* Checks if this noun stack is querying for a qualia
|
||||
* Checks if this noun stack is querying for a quality
|
||||
* @param interrogativeStack The interrogative noun stack
|
||||
* @return true if it is a qualia query, false otherwise
|
||||
* @return true if it is a quality query, false otherwise
|
||||
*/
|
||||
public static boolean isQualiaClarificationQuery(NounStack interrogativeStack){
|
||||
public static boolean isQualityClarificationQuery(NounStack interrogativeStack){
|
||||
String originalWord = interrogativeStack.getIndexedWord().originalText();
|
||||
List<Node> nodes = InstanceQuery.getInstances(Globals.web.getAnchors().getQualiaNode());
|
||||
List<Node> nodes = InstanceQuery.getInstances(Globals.web.getAnchors().getQualityNode());
|
||||
Node rVal = NameQueryFilter.withNodeName(nodes, originalWord);
|
||||
return rVal != null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the type of qualia requested by the interrogative stack
|
||||
* @param interrogativeStack The noun stack containing the qualia type
|
||||
* @return The qualia type
|
||||
* Gets the type of quality requested by the interrogative stack
|
||||
* @param interrogativeStack The noun stack containing the quality type
|
||||
* @return The quality type's node
|
||||
*/
|
||||
public static Node getRequestedQualiaType(NounStack interrogativeStack){
|
||||
public static Node getRequestedQualityType(NounStack interrogativeStack){
|
||||
String originalWord = interrogativeStack.getIndexedWord().originalText();
|
||||
List<Node> nodes = InstanceQuery.getInstances(Globals.web.getAnchors().getQualiaNode());
|
||||
List<Node> nodes = InstanceQuery.getInstances(Globals.web.getAnchors().getQualityNode());
|
||||
return NameQueryFilter.withNodeName(nodes, originalWord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the qualia of an instance
|
||||
* Gets all the qualities of an instance
|
||||
* @param inst The instance
|
||||
* @return The qualia
|
||||
* @return The qualities
|
||||
*/
|
||||
public static List<Node> getQualiaOfInstance(Node inst){
|
||||
return Globals.web.getRelationsOfChildNode(inst).stream().filter(relation -> relation.getName().equals(RelationTypes.QUALIA_OF)).map(relation -> relation.getParent()).collect(Collectors.toList());
|
||||
public static List<Node> getQualitiesOfInstance(Node inst){
|
||||
return Globals.web.getRelationsOfChildNode(inst).stream().filter(relation -> relation.getName().equals(RelationTypes.QUALITY_OF)).map(relation -> relation.getParent()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@ -16,7 +16,16 @@ public class NameQueryFilter {
|
||||
public static Node withNodeName(List<Node> nodes, String name){
|
||||
List<Node> filtered = nodes.stream().filter(node -> node.getName().equals(name)).collect(Collectors.toList());
|
||||
if(filtered.size() != 1){
|
||||
throw new UnsupportedOperationException("TODO: handle ambiguous case");
|
||||
String message = "TODO: handle ambiguous case\n" +
|
||||
"query: " + name + "\n" +
|
||||
filtered.size();
|
||||
if(filtered.size() > 0){
|
||||
message = message + "found:\n";
|
||||
for(Node node : filtered){
|
||||
message = message + "\n" + node.getName();
|
||||
}
|
||||
}
|
||||
throw new UnsupportedOperationException(message);
|
||||
}
|
||||
return filtered.get(0);
|
||||
}
|
||||
|
||||
@ -17,8 +17,8 @@ public class RelationTypes {
|
||||
public static final String POSSESSION_OF = "possessionOf";
|
||||
|
||||
/**
|
||||
* A qualia of instance relationship
|
||||
* A quality of instance relationship
|
||||
*/
|
||||
public static final String QUALIA_OF = "qualiaOf";
|
||||
public static final String QUALITY_OF = "qualityOf";
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user