// Create a simple formula Formula anIsbn = SLPatternManip.fromFormula("(isbn \"ISBN 0439784549\")"); // Create formula patterns (see below) Formula ISBN_FORMULA = SLPatternManip.fromFormula ("(isbn ??isbn)"); Term SELL_ACTION_TERM = SLPatternManip.fromTerm("(SELL_BOOK :buyer ??buyer :isbn ??isbn :price ??price)"); ActionExpression SELL_ACTION_EXPRESSION = (ActionExpression) SLPatternManip.fromTerm("(action ??actor "+ SELL_ACTION_TERM +")"); Formula I_DONE_SELL_ACTION = SLPatternManip.fromFormula("(I ??buyer (done "+ SELL_ACTION_EXPRESSION +"))"); ====================================== Formula BOOK_FORMULA = SLPatterManip.fromFormula("(and (isbn ??isbn) (title ??isbn ??title))"); Formula aHarryPotterFormula = SLPatterManip.fromFormula("(and (isbn \"ISBN 0439784549\") (title \"ISBN 0439784549\" \"Harry Potter and the Half-Blood Prince\"))"); MatchResult result = BOOK_FORMULA.match(aHarryPotterFormula); if (result != null) { System.out.println("ISBN = " + result.getTerm("isbn")); System. out.println("Title = " + result.getTerm("title")); } ====================================== // Get the book ISBN and the seller AID from the agent’s arguments isbn = new StringConstantNode((String)getArgument()[0]); seller = Tools.AID2Term(new AID((String)getArgument()[1], AID.ISLOCALNAME)); // Create and instantiate the IRE pattern purchase_ire = (Identifying_Expression) SLPatternManip.fromTerm("(some ?x (selling_price ??isbn ?x ??seller)").instantiate("isbn", isbn).instantiate("seller", seller); // Use convenient methods of SemanticCapabilities to send the messages semanticCapabilities.queryRef(purchase_ire, seller); semanticCapabilities.subscribe(purchase_ire, seller);