本文整理汇总了Java中alice.tuprolog.NoSolutionException类的典型用法代码示例。如果您正苦于以下问题:Java NoSolutionException类的具体用法?Java NoSolutionException怎么用?Java NoSolutionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NoSolutionException类属于alice.tuprolog包,在下文中一共展示了NoSolutionException类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: translate
import alice.tuprolog.NoSolutionException; //导入依赖的package包/类
/**
* Provides a Map with the next answer. This Map has the name of each variable
* indexing its value (the name is a String and the value may be null, String or
* List).
*
* @return Map with the variables indexing their values. Null is returned in the
* case of NO possible solution. A empty Map is returned in the case of YES
* without variables matching.
*/
private synchronized Map<String,Object> translate(SolveInfo solveInfo) {
try {
Map<String,Object> result = new HashMap<String,Object>();
for (Iterator iterator = solveInfo.getBindingVars().iterator(); iterator.hasNext();) {
Var var = (Var) iterator.next();
result.put(var.getName(), translate(var.getTerm()));
}
// for (Var var : solveInfo.toVarArray()) {
// result.put(var.getName(), translate(var.getTerm()));
// }
return result;
} catch (NoSolutionException e) {
return null;
}
}
开发者ID:dew-uff,项目名称:expline,代码行数:27,代码来源:InferenceMachine.java
示例2: infrastructureElementsCanBeFound
import alice.tuprolog.NoSolutionException; //导入依赖的package包/类
@Test
public void infrastructureElementsCanBeFound() throws IOException, MalformedGoalException, NoSolutionException,
InvalidTheoryException {
// Given
modelUtil.createElement(IArchimatePackage.eINSTANCE.getNode(), "N", "n");
modelUtil.createElement(IArchimatePackage.eINSTANCE.getInfrastructureInterface(), "II", "ii");
modelUtil.createElement(IArchimatePackage.eINSTANCE.getDevice(), "D", "d");
modelUtil.createElement(IArchimatePackage.eINSTANCE.getSystemSoftware(), "S", "s");
modelUtil.createElement(IArchimatePackage.eINSTANCE.getCommunicationPath(), "C", "c");
modelUtil.createElement(IArchimatePackage.eINSTANCE.getNetwork(), "N", "n");
modelUtil.createElement(IArchimatePackage.eINSTANCE.getArtifact(), "Ar", "ar");
modelUtil.createElement(IArchimatePackage.eINSTANCE.getInfrastructureService(), "Is", "is");
modelUtil.createElement(IArchimatePackage.eINSTANCE.getInfrastructureFunction(), "Is", "is");
exporter.export(model);
load();
// When
SolveInfo result = engine.solve("infrastructure(X).");
// Then
assertTrue(result.isSuccess());
checkThat(result).is("n,ii,is,d,s,c,n,ar");
}
开发者ID:fkoehne,项目名称:archi-prolog-exporter,代码行数:25,代码来源:TestVocabularyPredicates.java
示例3: shouldNotFindAppsWithInfrastructure
import alice.tuprolog.NoSolutionException; //导入依赖的package包/类
@Test
public void shouldNotFindAppsWithInfrastructure() throws IOException, MalformedGoalException, NoSolutionException,
InvalidTheoryException {
// Given ...
// the application component "a" from the test base class
modelUtil.createElement(IArchimatePackage.eINSTANCE.getNode(), "N", "n");
modelUtil.createRelationship(IArchimatePackage.eINSTANCE.getUsedByRelationship(), "usedBy", "n", "a");
exporter.export(model);
load();
// When
SolveInfo result = engine.solve("infrastructureless(X).");
// Then
assertFalse(result.isSuccess());
}
开发者ID:fkoehne,项目名称:archi-prolog-exporter,代码行数:17,代码来源:TestConsistencyPredicates.java
示例4: shouldFindRedundantRelationships
import alice.tuprolog.NoSolutionException; //导入依赖的package包/类
@Test
public void shouldFindRedundantRelationships() throws IOException, MalformedGoalException, NoSolutionException,
InvalidTheoryException {
// Given ...
// the application component "a" from the test base class
modelUtil.createElement(IArchimatePackage.eINSTANCE.getNode(), "N", "n");
modelUtil.createRelationship(IArchimatePackage.eINSTANCE.getUsedByRelationship(), "usedBy1", "n", "a");
modelUtil.createRelationship(IArchimatePackage.eINSTANCE.getUsedByRelationship(), "usedBy2", "n", "a");
exporter.export(model);
load();
// When
SolveInfo result = engine.solve("redundantRelationship(X,Y)."); // Source / Target
// Then
checkThat(result).is("n");
}
开发者ID:fkoehne,项目名称:archi-prolog-exporter,代码行数:18,代码来源:TestConsistencyPredicates.java
示例5: withoutGoalsDoesNotFindGoals
import alice.tuprolog.NoSolutionException; //导入依赖的package包/类
@Test
public void withoutGoalsDoesNotFindGoals() throws IOException, MalformedGoalException, NoSolutionException,
InvalidTheoryException {
// Given
exporter.export(model);
load();
// When
SolveInfo result = engine.solve("goal(X).");
// Then
assertFalse(result.isSuccess());
}
开发者ID:fkoehne,项目名称:archi-prolog-exporter,代码行数:14,代码来源:TestVocabularyPredicates.java
示例6: withGoalsShouldFindGoal
import alice.tuprolog.NoSolutionException; //导入依赖的package包/类
@Test
public void withGoalsShouldFindGoal() throws IOException, MalformedGoalException, NoSolutionException,
InvalidTheoryException {
// Given
modelUtil.createElement(IArchimatePackage.eINSTANCE.getGoal(), "G", "g");
exporter.export(model);
load();
// When
SolveInfo result = engine.solve("goal(X).");
// Then
checkThat(result).is("g");
}
开发者ID:fkoehne,项目名称:archi-prolog-exporter,代码行数:15,代码来源:TestVocabularyPredicates.java
示例7: elementsNameCanBeFoundViaId
import alice.tuprolog.NoSolutionException; //导入依赖的package包/类
@Test
public void elementsNameCanBeFoundViaId() throws IOException, MalformedGoalException, NoSolutionException,
InvalidTheoryException {
// Given
exporter.export(model);
load();
// When
SolveInfo result = engine.solve("named(X, 'A').");
// Then
checkThat(result).is("a");
}
开发者ID:fkoehne,项目名称:archi-prolog-exporter,代码行数:14,代码来源:TestVocabularyPredicates.java
示例8: elementsCanBeFoundViaName
import alice.tuprolog.NoSolutionException; //导入依赖的package包/类
@Test
public void elementsCanBeFoundViaName() throws IOException, MalformedGoalException, NoSolutionException,
InvalidTheoryException {
// Given
exporter.export(model);
load();
// When
SolveInfo result = engine.solve("named(X).");
// Then
checkThat(result).is("A");
}
开发者ID:fkoehne,项目名称:archi-prolog-exporter,代码行数:14,代码来源:TestVocabularyPredicates.java
示例9: shouldFindAppsWithoutInfrastructure
import alice.tuprolog.NoSolutionException; //导入依赖的package包/类
@Test
public void shouldFindAppsWithoutInfrastructure() throws IOException, MalformedGoalException, NoSolutionException,
InvalidTheoryException {
// Given ...
// the application component "a" from the test base class
exporter.export(model);
load();
// When
SolveInfo result = engine.solve("infrastructureless(X).");
// Then
checkThat(result).is("a");
}
开发者ID:fkoehne,项目名称:archi-prolog-exporter,代码行数:15,代码来源:TestConsistencyPredicates.java
示例10: getTerm
import alice.tuprolog.NoSolutionException; //导入依赖的package包/类
private Term getTerm() {
try {
return solveInfo.getVarValue(varName);
}
catch (NoSolutionException e) {
return null;
}
}
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:9,代码来源:SolveInfoLibrary.java
示例11: extract
import alice.tuprolog.NoSolutionException; //导入依赖的package包/类
/**
* Find simple statements of type in regular text, such as "Diabetes is a
* common disease"
*
* Subclasses are very similarly stated, such as "A hummingbird is a kind
* of bird." But we don't distinguish between these yet. We should though.
*
* @return Pairs of nouns and their types.
*/
public static List<Pair<String, String>> extract(Phrase p) {
List<Pair<String, String>> names_and_types = new ArrayList<>();
for (SemanticGraph graph: p.getGraphs()){
StringBuilder theory = new StringBuilder();
// Load data into a model
// Add all the edges
for (SemanticGraphEdge edge : graph.edgeIterable()) {
// I like the specific prepositions better
// so change them to match
GrammaticalRelation rel = edge.getRelation();
String relation_name = rel.getShortName();
if ( (rel.getShortName().equals("prep")
|| rel.getShortName().equals("conj"))
&& rel.getSpecific() != null
&& !rel.getSpecific().isEmpty()) {
relation_name = rel.getShortName() + "_" + CharSetUtils.keep(rel.getSpecific().toLowerCase(), "abcdefghijklmnopqrstuvwxyz");
}
theory.append(relation_name);
theory.append('(');
theory.append(wordID(edge.getGovernor()));
theory.append(',');
theory.append(wordID(edge.getDependent()));
theory.append(").\n");
}
// Index the words
for (IndexedWord word : graph.vertexSet()) {
theory.append("tag(");
theory.append(wordID(word));
theory.append(',');
String tag = clean(word.tag());
theory.append(tag.isEmpty() ? "misc" : tag);
theory.append(").\n");
}
Prolog engine = new Prolog();
try {
engine.setTheory(new Theory(
Files.toString(new File("src/main/parse.pl"), Charset.forName("UTF-8"))));
log.debug(theory);
engine.addTheory(new Theory(theory.toString()));
SolveInfo info = engine.solve("type_c(X, Y).");
// Get the resulting matches
while (info.isSuccess()) {
IndexedWord subj_idx = idWord(graph, info.getTerm("X").toString());
IndexedWord obj_idx = idWord(graph, info.getTerm("Y").toString());
if (subj_idx.tag().startsWith("NN")
&& obj_idx.tag().startsWith("NN")) {
String noun = Trees.concatNoun(graph, subj_idx);
String type = obj_idx.originalText(); //concatNoun(graph, obj_idx);
log.info("Discovered " + noun + " is a(n) " + type);
names_and_types.add(new Pair<>(noun,type));
}
if (engine.hasOpenAlternatives()) {
info = engine.solveNext();
} else {
break;
}
}
} catch (IOException | InvalidTheoryException
| MalformedGoalException | NoSolutionException
| NoMoreSolutionException | UnknownVarException e) {
System.out.println(theory);
e.printStackTrace();
}
}
return names_and_types;
}
开发者ID:SeanTater,项目名称:uncc2014watsonsim,代码行数:81,代码来源:SupportCandidateType.java
示例12: test
import alice.tuprolog.NoSolutionException; //导入依赖的package包/类
@Test
public void test() throws InvalidTheoryException, FileNotFoundException, IOException, MalformedGoalException, NoSolutionException, NoMoreSolutionException {
String kbfolder = "E:/sadl/workspace-sadl/Mobius2.new/OwlModels/";
String rdffile = "rdf.pl";
String stddecls = "tuprolog-custom-predicates.pl";
String entry = "PlanRecloserInstance.pl";
Prolog engine = new Prolog();
engine.clearTheory();
String fn = kbfolder + stddecls;
System.out.println("Loading " + fn);
engine.addTheory(createTheory(fn));
fn = kbfolder + entry;
System.out.println("Loading " + fn);
engine.addTheory(createTheory(fn));
fn = kbfolder + rdffile;
System.out.println("Loading " + fn);
engine.addTheory(createTheory(fn));
SolveInfo result = engine.solve("minSkillProficiency('http://www.mobius.illinois.edu/advise/ont/core/Attack#AdminModifyFWOpen',Sk,P).");
// SolveInfo result = engine.solve("preconditions(X,Y,Z).");
// SolveInfo result = engine.solve("holds(X,Y,Z).");
System.out.println(result.toString());
assertNotNull(result);
assertNotNull(result.getSolution());
int solution_count = 0;
List<String> solution_list = new ArrayList<String>();
while (result.isSuccess()) {
solution_count += 1;
List<Var> vars = result.getBindingVars();
StringBuilder sb = new StringBuilder();
for (Var var: vars){
sb.append(var.getName());
sb.append(": ");
sb.append(result.getVarValue(var.getName()).toString());
}
solution_list.add(sb.toString());
if (engine.hasOpenAlternatives())
result = engine.solveNext();
else
break;
}
for (int i = 0; i < solution_list.size(); i++) {
System.out.println("Solution " + i + ": " + solution_list.get(i));
}
}
开发者ID:crapo,项目名称:sadlos2,代码行数:45,代码来源:TestPrologMobius.java
示例13: test2
import alice.tuprolog.NoSolutionException; //导入依赖的package包/类
@Test
public void test2() throws InvalidTheoryException, FileNotFoundException, IOException, MalformedGoalException, NoSolutionException, NoMoreSolutionException {
String kbfolder = "E:/sadl/workspace-sadl/Mobius2.new/OwlModels";
Prolog engine = new Prolog();
engine.clearTheory();
File plFilesFolder = new File(kbfolder);
File[] files = plFilesFolder.listFiles();
// first load prolog files and then owl/rdf files
for (int i = 0; i < files.length; i++){
String fn = files[i].getName();
if (fn.endsWith(".pl") &&
(fn.startsWith("PlanR") || fn.startsWith("plann") || fn.startsWith("pr") || fn.startsWith("r") || fn.startsWith("b"))) {
System.out.println("Loading " + files[i].getAbsolutePath());
try {
engine.addTheory(createTheory(files[i].getAbsolutePath()));
} catch (InvalidTheoryException e) {
// TODO Auto-generated catch block
System.err.println("Syntax error: " + e.getMessage());
}
}
}
SolveInfo result = engine.solve("minSkillProficiency('http://www.mobius.illinois.edu/advise/ont/core/Attack#AdminModifyFWOpen',Sk,P).");
System.out.println(result.toString());
assertNotNull(result);
assertNotNull(result.getSolution());
int solution_count = 0;
List<String> solution_list = new ArrayList<String>();
while (result.isSuccess()) {
solution_count += 1;
List<Var> vars = result.getBindingVars();
for (Var var: vars){
solution_list.add(result.getVarValue(var.getName()).toString());
}
//System.out.println(solution.getBindingVars());
//System.out.println(solution.getSolution().toString());
if (engine.hasOpenAlternatives())
result = engine.solveNext();
else
break;
}
}
开发者ID:crapo,项目名称:sadlos2,代码行数:43,代码来源:TestPrologMobius.java
示例14: test3
import alice.tuprolog.NoSolutionException; //导入依赖的package包/类
@Test
public void test3() throws InvalidTheoryException, FileNotFoundException, IOException, MalformedGoalException, NoSolutionException, NoMoreSolutionException {
String kbfolder = "E:/sadl/workspace-sadl/Mobius2.new/OwlModels";
Prolog engine = new Prolog();
engine.clearTheory();
File plFilesFolder = new File(kbfolder);
File[] files = plFilesFolder.listFiles();
// first load prolog files and then owl/rdf files
for (int i = 0; i < files.length; i++){
String fn = files[i].getName();
if (fn.endsWith(".pl") &&
(fn.startsWith("PlanR") || fn.startsWith("plann") || fn.startsWith("pr") || fn.startsWith("r") || fn.startsWith("b"))) {
System.out.println("Loading " + files[i].getAbsolutePath());
try {
engine.addTheory(createTheory(files[i].getAbsolutePath()));
} catch (InvalidTheoryException e) {
// TODO Auto-generated catch block
System.err.println("Syntax error: " + e.getMessage());
}
}
}
SolveInfo result = engine.solve("preconditions(X,Y,Z).");
System.out.println(result.toString());
assertNotNull(result);
assertNotNull(result.getSolution());
int solution_count = 0;
List<String> solution_list = new ArrayList<String>();
while (result.isSuccess()) {
solution_count += 1;
List<Var> vars = result.getBindingVars();
for (Var var: vars){
solution_list.add(result.getVarValue(var.getName()).toString());
}
//System.out.println(solution.getBindingVars());
//System.out.println(solution.getSolution().toString());
if (engine.hasOpenAlternatives())
result = engine.solveNext();
else
break;
}
}
开发者ID:crapo,项目名称:sadlos2,代码行数:43,代码来源:TestPrologMobius.java
注:本文中的alice.tuprolog.NoSolutionException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论