Code Search for Developers
 
 
  

OWLGoalCase.java from Citizen Privacy Service at Krugle


Show OWLGoalCase.java syntax highlighted

/**
 * @(#) OWLGoalCase.java
 * @author <a href:mailto="rick@rickmurphy.org">Rick Murphy</a>
 * @version 0.1
 * @see <a href="http://www.rickmurphy.org/cps-license.html">Citizen Privacy Service License</a>
 */

package org.rickmurphy.unit;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.net.URL;

import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;

import java.util.ArrayList;
import java.util.Collection;

import jtp.ReasoningStep;
import jtp.ReasoningStepIterator;

import jtp.context.owl.OWLReasoningContext;

import jtp.fol.kif.KIF2CNF;

import jtp.fol.parser.ParserBasedTranslator;

import jtp.modelim.AskingQueryProcessor;

import jtp.ui.RDFQueryUtils;

import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;

import jtp.fol.DefaultCNFSentence;
import jtp.fol.SubstUtils;
import jtp.fol.Literal;

import junit.framework.TestCase;

/**
 */

public class OWLGoalCase extends TestCase {

  /**
   */
  private static KIF2CNF kifParser = new KIF2CNF();
  private static OWLReasoningContext context = new OWLReasoningContext();
  private static AskingQueryProcessor queryProcessor = new AskingQueryProcessor();

  /**
   */
  protected void setUp() throws Exception{
    
    //    System.setProperty("jtp.fol.rdf.RDFParser.printDebugTriples", "true");

    kifParser.setCaseSensitiveSymbols(true);
    kifParser.addNamespaceMapping("owl", "http://www.w3.org/2002/07/owl#");
    kifParser.addNamespaceMapping("daml", "http://www.daml.org/2001/03/daml+oil#");
    kifParser.addNamespaceMapping("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
    kifParser.addNamespaceMapping("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
    
    context.setUp();
    
    Model model = ModelFactory.createDefaultModel();
    
    URL pubLocURL = new URL("http://localhost/kb");
    model.read(new BufferedReader(new InputStreamReader(new URL("http://www.osera.gov/privacy.owl").openStream())), pubLocURL.toString());
    
    ((OWLReasoningContext)context).loadRDFKB(model, pubLocURL);
    
    HashMap nsToUriMap = new HashMap();
    RDFQueryUtils.addNamespaceMappingsFromKb(pubLocURL.toString(), model, nsToUriMap);
    for (Iterator it = nsToUriMap.entrySet().iterator(); it.hasNext();){
      Map.Entry ent = (Map.Entry)it.next();
      kifParser.addNamespaceMapping((String)ent.getKey(),(String)ent.getValue());
    }    
    context.add(kifParser);
    
    queryProcessor.setTranslator((ParserBasedTranslator)kifParser.createTranslator());
    context.add(queryProcessor);    

  }//setUp

  /**
   */
  public void testSentenceOneQueryAcceptable() throws Exception{
    
    assertFalse(queryProcessor.acceptable("(holds |http://www.w3.org/2000/01/rdf-schema#|::|subClassOf| |http://www.osera.gov/owl/2005/12/privacy.owl#|::|CourtOrderedRequest| |http://www.osera.gov/owl/2005/12/privacy.owl#|::|GrantedRequest|)"));

  }//testSentenceOneQueryAcceptable

  /**
   */
  public void testSentenceOneGoal() throws Exception{
 
    assertNotNull(context.ask("( holds |http://www.w3.org/2000/01/rdf-schema#|::|subClassOf| |http://www.osera.gov/owl/2005/12/privacy.owl#|::|CourtOrderedRequest| |http://www.osera.gov/owl/2005/12/privacy.owl#|::|GrantedRequest|)"));
    
  }//testSentenceOneGoal  

}//OWLGoalCase




See more files for this project here

Citizen Privacy Service

The Citizen Privacy Service is an asynchronous component using artificial intelligence capabilities including DL decidability and first order logic provenance that provide policy decision and policy enforcement points based on the US Privacy Act of 1974.

Project homepage: http://sourceforge.net/projects/us-privacy
Programming language(s): Java,XML
License: bsd

  KIFGoalCase.java
  OWLEntailmentCase.java
  OWLGoalCase.java