void VisualizeStatement(string statement) { Statement parsedStatement = new Statement(statement); if (parsedStatement.type == Statement.StatementType.Unsupported) { return; } //failed to create statement; unsupported statement SubjectPredicate subjectPredicate = parsedStatement.subjectPredicate; TruthValue truthValue = parsedStatement.truthValue; //visualize subject, predicate as terms QueueVisualizeNewConcept(subjectPredicate._subject); QueueVisualizeNewConcept(subjectPredicate._predicate); string statementKey = ""; //visualize inheritance relation if (parsedStatement.type == Statement.StatementType.Inheritance) { statementKey = GetInheritanceString(subjectPredicate); QueueVisualizeNewConcept(statementKey); if (inheritTable.ContainsKey(statementKey) && inheritTable[statementKey].GetTruthValue().GetHashCode() == truthValue.GetHashCode()) { return; } QueueVisualizeNewInherit(parsedStatement); } else if (parsedStatement.type == Statement.StatementType.Similarity) { statementKey = GetSimilarityString(subjectPredicate); QueueVisualizeNewConcept(statementKey); Statement parsedReverseStatement = NarseseParser.GetReverseStatement(statement); string forwardStatementKey = GetInheritanceString(subjectPredicate); string reverseStatementKey = GetInheritanceString(parsedReverseStatement.subjectPredicate); if (inheritTable.ContainsKey(forwardStatementKey) && inheritTable[forwardStatementKey].GetTruthValue().GetHashCode() == truthValue.GetHashCode()) { return; } QueueVisualizeNewInherit(parsedStatement); if (inheritTable.ContainsKey(reverseStatementKey) && inheritTable[reverseStatementKey].GetTruthValue().GetHashCode() == parsedReverseStatement.truthValue.GetHashCode()) { return; } QueueVisualizeNewInherit(parsedReverseStatement); } else { return; } }
public Statement(string statement) { int indexOfCopula = statement.IndexOf(NarseseParser.INHERITANCE_COPULA); // --> int copulaLength = NarseseParser.INHERITANCE_COPULA.Length; type = StatementType.Inheritance; if (indexOfCopula == -1) // not found, similarity statement { indexOfCopula = statement.IndexOf(NarseseParser.SIMILARITY_COPULA); // <-> copulaLength = NarseseParser.SIMILARITY_COPULA.Length; type = StatementType.Similarity; } if (indexOfCopula == -1) //not found, unsupported { type = StatementType.Unsupported; return; } ((string, string), (string, string))parsedStatement = ParseStatement(statement, indexOfCopula, copulaLength); subjectPredicate = new SubjectPredicate(parsedStatement.Item1.Item1, parsedStatement.Item1.Item2); truthValue = new TruthValue(parsedStatement.Item2.Item1, parsedStatement.Item2.Item2); }
private string GetSimilarityString(SubjectPredicate subjectPredicate) { return("<" + subjectPredicate._subject + NarseseParser.SIMILARITY_COPULA + subjectPredicate._predicate + ">"); }
private string GetInheritanceString(SubjectPredicate subjectPredicate) { return("<" + subjectPredicate._subject + NarseseParser.INHERITANCE_COPULA + subjectPredicate._predicate + ">"); }