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;未經允許,請勿轉載。
java sentence_Java Sentence類代碼示例相关推荐
- java uiautomation_Java UiAutomation類代碼示例
本文整理匯總了Java中android.app.UiAutomation類的典型用法代碼示例.如果您正苦於以下問題:Java UiAutomation類的具體用法?Java UiAutomation怎 ...
- java nifty_Java NiftyDialogBuilder類代碼示例
本文整理匯總了Java中com.gitonway.lee.niftymodaldialogeffects.NiftyDialogBuilder類的典型用法代碼示例.如果您正苦於以下問題:Java Ni ...
- java intfunction_Java IntFunction類代碼示例
本文整理匯總了Java中java.util.function.IntFunction類的典型用法代碼示例.如果您正苦於以下問題:Java IntFunction類的具體用法?Java IntFunct ...
- java scene_Java Scene類代碼示例
本文整理匯總了Java中com.sun.j3d.loaders.Scene類的典型用法代碼示例.如果您正苦於以下問題:Java Scene類的具體用法?Java Scene怎麽用?Java Scene ...
- java notifier_Java Notifier類代碼示例
本文整理匯總了Java中org.apache.maven.model.Notifier類的典型用法代碼示例.如果您正苦於以下問題:Java Notifier類的具體用法?Java Notifier怎麽 ...
- java bidi_Java Bidi類代碼示例
本文整理匯總了Java中java.text.Bidi類的典型用法代碼示例.如果您正苦於以下問題:Java Bidi類的具體用法?Java Bidi怎麽用?Java Bidi使用的例子?那麽恭喜您, 這 ...
- java linest_Java STLineSpacingRule類代碼示例
本文整理匯總了Java中org.docx4j.wml.STLineSpacingRule類的典型用法代碼示例.如果您正苦於以下問題:Java STLineSpacingRule類的具體用法?Java ...
- java datarow_Java DataRow類代碼示例
本文整理匯總了Java中org.apache.cayenne.DataRow類的典型用法代碼示例.如果您正苦於以下問題:Java DataRow類的具體用法?Java DataRow怎麽用?Java ...
- java hessian2_Java Hessian2Output類代碼示例
本文整理匯總了Java中com.caucho.hessian.io.Hessian2Output類的典型用法代碼示例.如果您正苦於以下問題:Java Hessian2Output類的具體用法?Java ...
最新文章
- 老实工作没有其他收入,为什么还要补缴个税?
- 获取项目文件在服务器的真实路径
- .NET Core实战项目之CMS 第十五章 各层联动工作实现增删改查业务
- Linux下安装nginx, php, php-fpm并配置
- Nature拳头综述(IF=71)| 上海科技大学钟超等人系统介绍合成生物学及未来潜在应用...
- 关于Linux服务器改变为普通用户进行运维的操作手记
- java hasnextdouble_scanner.nextInt()与scanner.nextDouble
- 关于web项目跨域问题详解
- 优化理论19----DNRTR无约束优化的对角拟牛顿修正方法
- 每个python文件就是一个模块、模块的名字就是_Python-模块和包
- 关于composer安装插件时候提示找不到fxp插件时候的解决办法
- python搭建微信小程序卖货要收费用吗_开发一个微信小程序需要多少钱?
- yamlip 安装_SpringBoot中yaml配置对象
- QPushButton去掉虚线框(焦点框)
- PNAS:大脑区域间耦合的增加和减少会相应增加和减少人类大脑中的振荡活动
- 一篇文带你使用vue完成一个完整后台
- idea 启动时怎么选择工作空间
- hive之窗口函数理解与实践
- Single SPI、Dual SPI、Qaud SPI
- vue中axios利用blob实现文件浏览器下载
热门文章
- 命令行操作mysql
- P3435 [POI2006]OKR-Periods of Words kmp + fail指针
- UOJ#191. 【集训队互测2016】Unknown
- P5540-[BalkanOI2011]timeismoney|最小乘积生成树【最小生成树,凸壳】
- NOI.AC-random【期望概率,统计】
- Loj2687,jzoj3320-文本编辑器【线头dp】
- P1156-垃圾陷阱【dp】
- 【树形区间DP】加分二叉树(ssl 1033/luogu 1040)
- HDU6223 - Infinite Fraction Path
- Juice Extractor dp