java sentence_Java Sentence類代碼示例

本文整理匯總了Java中aima.core.logic.propositional.parsing.ast.Sentence類的典型用法代碼示例。如果您正苦於以下問題:Java Sentence類的具體用法?Java Sentence怎麽用?Java Sentence使用的例子?那麽恭喜您, 這裏精選的類代碼示例或許可以為您提供幫助。

Sentence類屬於aima.core.logic.propositional.parsing.ast包,在下文中一共展示了Sentence類的16個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: mapAsComplexSentence

​點讚 3

import aima.core.logic.propositional.parsing.ast.Sentence; //導入依賴的package包/類

private static Sentence mapAsComplexSentence(Clause clause) {

ArrayList subSentences = new ArrayList();

for (ClauseNode clauseNode : clause.getSubClauses()) {

subSentences.add(map(clauseNode));

}

Connective connective;

switch (clause.getType()) {

case AND:

connective = Connective.AND;

break;

case OR:

connective = Connective.OR;

break;

case NOT:

connective = Connective.NOT;

break;

default:

connective = Connective.AND;

}

return bracketIfNecessary(connective, subSentences);

}

開發者ID:dbasedow,項目名稱:prospecter,代碼行數:24,

示例2: testFlattenOr

​點讚 3

import aima.core.logic.propositional.parsing.ast.Sentence; //導入依賴的package包/類

public void testFlattenOr() {

List conditionsA = new ArrayList();

conditionsA.add(new Condition("price", new Token(100, MatchCondition.GREATER_THAN_EQUALS)));

conditionsA.add(new Condition("floor", new Token(4, MatchCondition.LESS_THAN)));

Clause clauseA = new Clause(Clause.ClauseType.OR, conditionsA);

List conditionsB = new ArrayList();

conditionsB.add(new Condition("category", new Token("foo", MatchCondition.EQUALS)));

conditionsB.add(new Condition("category", new Token("bar", MatchCondition.EQUALS)));

Clause clauseB = new Clause(Clause.ClauseType.OR, conditionsB);

List clauses = new ArrayList();

clauses.add(clauseA);

clauses.add(clauseB);

Clause root = new Clause(Clause.ClauseType.OR, clauses);

Sentence sentence = PropositionalSentenceMapper.map(root);

assertEquals(Connective.OR, sentence.getConnective());

assertEquals(2, sentence.getNumberSimplerSentences());

Sentence cnf = Query.getCNF(sentence);

Conjunction conjunction = new Conjunction();

Query.flatten(conjunction, cnf);

assertEquals(1, conjunction.getNumberSimplerSentences());

assertEquals(4, conjunction.getSimplerSentence(0).getNumberSimplerSentences());

}

開發者ID:dbasedow,項目名稱:prospecter,代碼行數:27,

示例3: test

​點讚 3

import aima.core.logic.propositional.parsing.ast.Sentence; //導入依賴的package包/類

public void test() {

List conditionsA = new ArrayList();

conditionsA.add(new Condition("price", new Token(100, MatchCondition.GREATER_THAN_EQUALS)));

conditionsA.add(new Condition("floor", new Token(4, MatchCondition.LESS_THAN)));

Clause clauseA = new Clause(Clause.ClauseType.AND, conditionsA);

List conditionsB = new ArrayList();

conditionsB.add(new Condition("category", new Token("foo", MatchCondition.EQUALS)));

conditionsB.add(new Condition("category", new Token("bar", MatchCondition.EQUALS)));

Clause clauseB = new Clause(Clause.ClauseType.AND, conditionsB);

List clauses = new ArrayList();

clauses.add(clauseA);

clauses.add(clauseB);

Clause root = new Clause(Clause.ClauseType.OR, clauses);

Sentence sentence = PropositionalSentenceMapper.map(root);

assertEquals(Connective.OR, sentence.getConnective());

assertEquals(2, sentence.getNumberSimplerSentences());

Sentence cnf = Query.getCNF(sentence);

Conjunction conjunction = new Conjunction();

Query.flatten(conjunction, cnf);

assertEquals(4, conjunction.getNumberSimplerSentences());

}

開發者ID:dbasedow,項目名稱:prospecter,代碼行數:26,

示例4: myTest

​點讚 2

import aima.core.logic.propositional.parsing.ast.Sentence; //導入依賴的package包/類

@Test

public void myTest(){

Sentence nested = parser.parse("(A1 | A2 | A3) => (A1 & A4)");

Sentence transformed = ConvertToCNF.convert(nested);

System.out.println(transformed);

}

開發者ID:Vapsel,項目名稱:social-media-analytic-system,代碼行數:8,

示例5: main

​點讚 2

import aima.core.logic.propositional.parsing.ast.Sentence; //導入依賴的package包/類

public static void main(String args[]) {

PLParser parser = new PLParser();

Sentence symbol = parser.parse("(((A & ((((B)))))) | (C & D)) & E");

Sentence transformed = ConvertToDNF.convert(symbol);

System.out.println(transformed.toString());

//Assert.assertEquals("A", transformed.toString());

}

開發者ID:iluoyi,項目名稱:teo-library,代碼行數:8,

示例6: Query

​點讚 2

import aima.core.logic.propositional.parsing.ast.Sentence; //導入依賴的package包/類

public Query(int queryId, ClauseNode clauseNode) {

this.clauseNode = clauseNode;

this.queryId = queryId;

Sentence cnf = getCNF(clauseNode);

int tmpBits = 0;

for (int bit = 0; bit < cnf.getNumberSimplerSentences(); bit++) {

tmpBits++;

Sentence disjunction = cnf.getSimplerSentence(bit);

for (int p = 0; p < disjunction.getNumberSimplerSentences(); p++) {

Sentence sentence = disjunction.getSimplerSentence(p);

boolean isNegativeCondition = false;

if (sentence.isNotSentence()) {

sentence = sentence.getSimplerSentence(0);

isNegativeCondition = true;

}

Condition condition = ((PropositionSymbol) sentence).getCondition();

if (condition.getToken().getCondition() == MatchCondition.IN) {

//If this is an IN query we're dealing with a Token containing a List

Object t = condition.getToken().getToken();

if (t instanceof List) {

for (Token token : (List) t) {

Condition tmpCondition = new Condition(condition.getFieldName(), token, isNegativeCondition);

postings.put(tmpCondition, QueryPosting.pack(queryId, bit, isNegativeCondition));

}

}

} else {

condition.setNot(isNegativeCondition);

long posting = QueryPosting.pack(queryId, bit, isNegativeCondition);

if (isNegativeCondition) {

negativeMask.add(bit);

}

postings.put(condition, posting);

}

}

}

bits = tmpBits;

}

開發者ID:dbasedow,項目名稱:prospecter,代碼行數:40,

示例7: flatten

​點讚 2

import aima.core.logic.propositional.parsing.ast.Sentence; //導入依賴的package包/類

public static void flatten(Conjunction conjunctionCollector, Sentence sentence) {

if (sentence.getNumberSimplerSentences() > 0 && sentence.getConnective() == Connective.AND) {

for (int i = 0; i < sentence.getNumberSimplerSentences(); i++) {

flatten(conjunctionCollector, sentence.getSimplerSentence(i));

}

} else {

Disjunction disjunctionCollector = new Disjunction();

flatten(disjunctionCollector, sentence);

conjunctionCollector.add(disjunctionCollector);

}

}

開發者ID:dbasedow,項目名稱:prospecter,代碼行數:12,

示例8: map

​點讚 2

import aima.core.logic.propositional.parsing.ast.Sentence; //導入依賴的package包/類

public static Sentence map(ClauseNode clause) {

if (!clause.isLeaf()) {

return mapAsComplexSentence((Clause) clause);

} else {

return mapAsAtomicSentence((Condition) clause);

}

}

開發者ID:dbasedow,項目名稱:prospecter,代碼行數:8,

示例9: bracketIfNecessary

​點讚 2

import aima.core.logic.propositional.parsing.ast.Sentence; //導入依賴的package包/類

private static Sentence bracketIfNecessary(Connective connective, List sentences) {

if (connective == Connective.NOT && sentences.size() == 1) {

return new ComplexSentence(connective, sentences.get(0));

}

while (sentences.size() > 1) {

ComplexSentence newComplex = new ComplexSentence(

connective,

sentences.remove(sentences.size() - 1),

sentences.remove(sentences.size() - 1)

);

sentences.add(newComplex);

}

return sentences.get(0);

}

開發者ID:dbasedow,項目名稱:prospecter,代碼行數:15,

示例10: toCNF

​點讚 2

import aima.core.logic.propositional.parsing.ast.Sentence; //導入依賴的package包/類

/**

* Converts the formula into CNF.

*

* @param in the owner of the formula

* @param formula the formula to convert

* @return formula in CNF form

* @throws ContextClassifierException ContextClassifierException

*/

public static String toCNF(INode in, String formula) throws ContextClassifierException {

PEParser parser = new PEParser();

CNFTransformer transformer = new CNFTransformer();

String result = formula;

if ((formula.contains("&") && formula.contains("|")) || formula.contains("~")) {

String tmpFormula = formula;

tmpFormula = tmpFormula.trim();

tmpFormula = tmpFormula.replace("&", "AND");

tmpFormula = tmpFormula.replace("|", "OR");

tmpFormula = tmpFormula.replace("~", "NOT");

tmpFormula = "(" + tmpFormula + ")";

if (!tmpFormula.isEmpty()) {

tmpFormula = tmpFormula.replace('.', 'P');

Sentence f = (Sentence) parser.parse(tmpFormula);

Sentence cnf = transformer.transform(f);

tmpFormula = cnf.toString();

tmpFormula = tmpFormula.replace("AND", "&");

tmpFormula = tmpFormula.replace("OR", "|");

tmpFormula = tmpFormula.replace("NOT", "~");

result = tmpFormula.replace('P', '.');

} else {

result = tmpFormula;

}

}

return result;

}

開發者ID:opendatatrentino,項目名稱:s-match,代碼行數:41,

示例11: getSpecialDateInstances

​點讚 2

import aima.core.logic.propositional.parsing.ast.Sentence; //導入依賴的package包/類

/**

* This method outputs a list of dates for a given special date class (e.g. holiday) from the TEO and an extra constraint (e.g. the year).

*

* @param classIRIStr

* @param extraConstraint

* @return

* @throws TEOException

*/

public ArrayList getSpecialDateInstances(String classIRIStr, DateConstraint extraConstraint) throws TEOException{

OntClass testClass = model.getOntClass(classIRIStr);

if (testClass == null) throw new TEOException("Exception: Cannot find class \"" + classIRIStr + "\" in the ontology.");

ExtendedIterator eqClassItor = testClass.listEquivalentClasses(); // constraints

ArrayList dateClsConstraints = new ArrayList();

ArrayList results = new ArrayList();

String logicExpression = null;

OntClass eqClass = null;

while (eqClassItor.hasNext()) {

eqClass = eqClassItor.next();

logicExpression = getLogicAlgebra(eqClass);

System.out.println("Original:\t" + logicExpression);

PLParser parser = new PLParser();

Sentence symbol = parser.parse(logicExpression);

Sentence transformed = ConvertToDNF.convert(symbol);

System.out.println("Transformed:\t" + transformed.toString());

// parse all constraints

String[] disjSentences = transformed.toString().split("\\|");

for (int i = 0; i < disjSentences.length; i ++) {

dateClsConstraints.add(translateSimpleSentenceIntoRules(disjSentences[i].trim()));

//System.out.println(dateClsConstraints.get(dateClsConstraints.size() - 1));

}

}

if (!dateClsConstraints.isEmpty()) {

DateConstraint mergedConstraint = null;

for (DateConstraint eachConstraint : dateClsConstraints) {

mergedConstraint = DateConstraint.intersectionDateConstraint(eachConstraint, extraConstraint);

System.out.println(mergedConstraint);

results.addAll(DateConstraint.enumerateDates(mergedConstraint));

}

}

return results;

}

開發者ID:iluoyi,項目名稱:teo-library,代碼行數:49,

示例12: getCNF

​點讚 2

import aima.core.logic.propositional.parsing.ast.Sentence; //導入依賴的package包/類

public static Sentence getCNF(Sentence sentence) {

Conjunction conjunction = new Conjunction();

flatten(conjunction, ConvertToCNF.convert(sentence));

return conjunction;

}

開發者ID:dbasedow,項目名稱:prospecter,代碼行數:6,

示例13: getSimplerSentence

​點讚 2

import aima.core.logic.propositional.parsing.ast.Sentence; //導入依賴的package包/類

@Override

public Sentence getSimplerSentence(int i) {

return subSentences.get(i);

}

開發者ID:dbasedow,項目名稱:prospecter,代碼行數:5,

示例14: bracketSentenceIfNecessary

​點讚 2

import aima.core.logic.propositional.parsing.ast.Sentence; //導入依賴的package包/類

@Override

public String bracketSentenceIfNecessary(Connective connective, Sentence sentence) {

return null;

}

開發者ID:dbasedow,項目名稱:prospecter,代碼行數:5,

示例15: add

​點讚 2

import aima.core.logic.propositional.parsing.ast.Sentence; //導入依賴的package包/類

public void add(Sentence sentence) {

subSentences.add(sentence);

}

開發者ID:dbasedow,項目名稱:prospecter,代碼行數:4,

示例16: mapAsAtomicSentence

​點讚 2

import aima.core.logic.propositional.parsing.ast.Sentence; //導入依賴的package包/類

private static Sentence mapAsAtomicSentence(Condition clause) {

return new PropositionSymbol(clause);

}

開發者ID:dbasedow,項目名稱:prospecter,代碼行數:4,

注:本文中的aima.core.logic.propositional.parsing.ast.Sentence類示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/327822.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Redis在windows下的安装、启动、配置

Redis在windows下的安装、启动、配置 原创scorpio_meng 最后发布于2018-06-29 13:42:39 阅读数 9687 收藏 展开 1&#xff0c;下载地址&#xff1a;https://github.com/MicrosoftArchive/redis/releases 2&#xff0c;解压缩后在文件夹中创建两个文件夹dbcache、logs。 3&am…

在ASP.NET Core中使用Angular2,以及与Angular2的Token base身份认证

Angular2是对Angular1的一次彻底的&#xff0c;破坏性的更新。 相对于Angular1.x&#xff0c;借用某果的广告语&#xff0c;唯一的不同&#xff0c;就是处处都不同。 首先&#xff0c;推荐的语言已经不再是Javascript&#xff0c;取而代之的TypeScript&#xff0c;(TypeScript …

xml vs db.properties

xml vs db.properties <property name"url" value"jdbc:mysql://localhost:3306/mybatis?useSSLtrue&amp;useUnicodetrue&amp;characterEncodingUTF-8"/>urljdbc:mysql://localhost:3306/mybatis? useSSLtrue&useUnicodetrue&cha…

require.ensure与require AMD的区别

转载自 webpack: require.ensure与require AMD的区别 webpack: require.ensure与require AMD的区别 简介 require-ensure和require-amd的区别&#xff1a; require-amd 说明: 同AMD规范的require函数&#xff0c;使用时传递一个模块数组和回调函数&#xff0c;模块都被下载下来…

python django 是啥_python的django做什么的

Django是一个开放源代码的Web应用框架&#xff0c;由Python写成。采用了MTV的框架模式&#xff0c;即模型M&#xff0c;视图V和模版T。它最初是被开发来用于管理劳伦斯出版集团旗下的一些以新闻内容为主的网站的&#xff0c;即是CMS(内容管理系统)软件。并于2005年7月在BSD许可…

org.springframework.amqp.AmqpConnectException java.net.ConnectException的解决办法

一、报错信息 spring cloud集成rabbitmq时报错&#xff1a; org.springframework.amqp.AmqpTimeoutException: java.util.concurrent.TimeoutException at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptio…

hibernate注解实体类(Dept.java)

Dept.java 部门信息表的实体类详情 package cn.bdqn.hibernate_Criteria.entity;import java.util.HashSet; import java.util.Set;import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; i…

.NET Core 1.1 升级公告

2016年11月16日发布.NET Core 1.1 。 它包括对其他Linux发行版的支持&#xff0c;有很多更新&#xff0c;是当前的第一个版本。 将在下面描述所有这些变化。 它是“Go Live”&#xff0c;可用于生产工作负载。 您可以立即下载版本&#xff1a;: Windows x64Windows x86macOS …

Java IO: InputStreamReader和OutputStreamWriter

转载自 Java IO: InputStreamReader和OutputStreamWriter作者: Jakob Jenkov 译者: 李璟(jlee381344197gmail.com) 本章节将简要介绍InputStreamReader和OutputStreamWriter。细心的读者可能会发现&#xff0c;在之前的文章中&#xff0c;IO中的类要么以Stream结尾&#xff0c…

java常用代码_Java 中常用代码 (欢迎补充)

//------------------------------------------------------------------------------------------------------生成四位随即验证码String str "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";StringBuilder s new StringBuilder();int len 4…

Intellij IDEA 重置所有工具栏 Intellij IDEA 中的 Debug 控制台输出窗口不见了的解决办法

Intellij IDEA 中的 Debug 控制台输出窗口不见了的解决办法 在 Debug 工具窗口&#xff0c;如图点击左侧重置布局图标&#xff0c;你的console窗口就还原了。

基于 .Net Core 的组件 Nuget 包制作 amp; 发布

微软的 ASP.Net Core 强化了 Nuget 的使用&#xff0c;所有的 .Net Core 组件均有 Nuget 管理&#xff0c;所以有必要探讨一下 .Net Core 组件制作 Nuget 包和发布。 之前 .Net Framework 程序集打包 Nuget 有以下方法&#xff1a; 1. 使用命令 nuget pack 详见博客园的一篇博…

#{} vs ${}

#{}: 是以预编译的形式&#xff0c;将参数设置到SQL语句中&#xff1b;PreparedStatement:防止SQL注入 ${}: 取出的值直接拼装在SQL语句中&#xff1b;会有安全问题 大多数情况下&#xff0c;我们去参数的值都应该使用#{}

Java IO: Reader和Writer

转载自 Java IO: Reader和Writer作者: Jakob Jenkov 译者: 李璟(jlee381344197gmail.com) Reader 原文链接 Reader是Java IO中所有Reader的基类。Reader与InputStream类似&#xff0c;不同点在于&#xff0c;Reader基于字符而非基于字节。换句话说&#xff0c;Reader用于读取…

idea新建module 后 mapper老是说mapper和xml没有绑定

20200225_005a 三层全部走通 上面走不出来应该是spingboot的版本太高了 选spring版本的时候选到最低版本 intian_talentapartment_api.zip repair

java线程的创建线程_多线程(Thread、线程创建、线程池)

第1章 多线程1.1 多线程介绍学习多线程之前&#xff0c;我们先要了解几个关于多线程有关的概念。进程&#xff1a;进程指正在运行的程序。确切的来说&#xff0c;当一个程序进入内存运行&#xff0c;即变成一个进程&#xff0c;进程是处于运行过程中的程序&#xff0c;并且具有…

hibernate注解实体类(Emp.java)

Emp.java 员工信息表的注解实体类详情&#xff1a; package cn.bdqn.hibernate_Criteria.entity;import java.util.Date; import javax.persistence.*;/*** Emp entity. author MyEclipse Persistence Tools*/Entity Table(name"EMP") public class Emp implements j…

MySQL在EF Core下的Scaffolding操作

Pomelo于2016年11月22日发布的MySQL for ef core中&#xff0c;增加了DbContext Scaffolding的支持&#xff0c;这项功能是让开发者可以从现有的数据库中提取表、列、索引及外键成为模型。这也是当前唯一一个支持Scaffolding的MySQL for EF Core Provider。 下面将演示如何使用…