• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Prolog类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中alice.tuprolog.Prolog的典型用法代码示例。如果您正苦于以下问题:Java Prolog类的具体用法?Java Prolog怎么用?Java Prolog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Prolog类属于alice.tuprolog包,在下文中一共展示了Prolog类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setup

import alice.tuprolog.Prolog; //导入依赖的package包/类
@Before
public void setup() throws FileNotFoundException, IOException, InvalidTheoryException {
    // Create a dummy model
    model = ArchimateFactory.init().createArchimateModel();
    modelUtil = new ModelUtil(model);
    modelUtil.createElement(IArchimatePackage.eINSTANCE.getApplicationComponent(), "A", "a");

    // Set up the engine with the predicates under test
    engine = new Prolog();
    Theory vocTheory = new Theory(new FileInputStream("prolog/vocabulary.pl"));
    Theory consistencyTheory = new Theory(new FileInputStream("prolog/consistency.pl"));
    engine.addTheory(vocTheory);
    engine.addTheory(consistencyTheory);

    // We will need the exporter to create .pl-Files of the dummy model but don't do that
    // yet, in order to allow individual tests to modify the model before exporting.
    exporter = new PrologExporter(new MockFileChooser());
}
 
开发者ID:fkoehne,项目名称:archi-prolog-exporter,代码行数:19,代码来源:AbstractBaseTest.java


示例2: solve

import alice.tuprolog.Prolog; //导入依赖的package包/类
public void solve(Prolog engine, SolveInfoLibrary solveInfoLibrary, EvaluationContext evalCtx, Element elt) throws PrologException {
	SolveInfo solveInfo = engine.solve(goal);
	while (solveInfo.isSuccess()) {
		solveInfoLibrary.setSolveInfo(solveInfo);
		Iterators.deplete(resolvedAction.evaluateElements(evalCtx, elt));
		if (solveInfo.hasOpenAlternatives())
			solveInfo = engine.solveNext();
		else
			break;
	}
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:12,代码来源:GoalDefinition.java


示例3: PrologAgentMind

import alice.tuprolog.Prolog; //导入依赖的package包/类
/**
 * Create a mind with a custom Prolog theory
 *
 * @param theory
 */
public PrologAgentMind(String theory){
    Log.i(TAG, "Theory loaded:\n" + theory);

    try {
        prolog = new Prolog();
        prolog.addTheory(new Theory(theory));
    } catch (InvalidTheoryException ex) {
        Log.e(TAG, "Prolog theory is not valid: " + ex.getMessage());
    }

    startPrologOutput();
}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:18,代码来源:PrologAgentMind.java


示例4: InferenceMachine

import alice.tuprolog.Prolog; //导入依赖的package包/类
/**
 * Constructs the inference machine
 */
public InferenceMachine() {
	inferenceMachine = new Prolog();
}
 
开发者ID:dew-uff,项目名称:expline,代码行数:7,代码来源:InferenceMachine.java


示例5: extract

import alice.tuprolog.Prolog; //导入依赖的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


示例6: test

import alice.tuprolog.Prolog; //导入依赖的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


示例7: test2

import alice.tuprolog.Prolog; //导入依赖的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


示例8: test3

import alice.tuprolog.Prolog; //导入依赖的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.Prolog类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RcInspectionActivity类代码示例发布时间:2022-05-22
下一篇:
Java SmoothBrick类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap