示例#1
0
  public Map<String, String> read(String in) {
    List<String> result = new ArrayList<String>();
    HttpClient client = new HttpClient();
    //	client.getHostConfiguration().setProxy("wwwcache.open.ac.uk", 80);
    ModelFactory modelFactory = RDF2Go.getModelFactory();
    Model model = modelFactory.createModel();

    String serviceEndPoint = "http://ws.geonames.org/search?q=" + "London" + "&type=rdf";

    GetMethod geoNameSearch = new GetMethod(serviceEndPoint);

    String rdf = "";
    try {
      client.executeMethod(geoNameSearch);
      rdf = geoNameSearch.getResponseBodyAsString();
      String rdf8 = new String(rdf.getBytes(), "UTF-8");

      System.out.println(rdf8);

      String modelQueryString =
          "SELECT DISTINCT ?name ?country ?location ?map ?lat ?long WHERE { ?location <http://www.geonames.org/ontology#name> ?name ."
              + "?location <http://www.geonames.org/ontology#locationMap> ?map ."
              + "?location <http://www.geonames.org/ontology#countryCode> ?country ."
              + "?location <http://www.w3.org/2003/01/geo/wgs84_pos#lat> ?lat ."
              + "?location <http://www.w3.org/2003/01/geo/wgs84_pos#long> ?long}";

      model.open();

      model.readFrom(new ByteArrayInputStream(rdf8.getBytes()));

      QueryResultTable results = model.sparqlSelect(modelQueryString);
      System.out.println(results.toString());
      ClosableIterator<QueryRow> iter = results.iterator();
      while (iter.hasNext()) {
        QueryRow row = iter.next();
        String name = row.getValue("name").toString();
        String country = row.getValue("country").toString();
        String location = row.getValue("location").toString();
        String map = row.getValue("location").toString();
        String lat = row.getValue("lat").toString();
        String longatti = row.getValue("long").toString();
        result.add(
            name + " -> " + country + ";" + location + ";" + lat + ";" + longatti + ";" + name + ";"
                + name + ":" + country + ":" + location + ":" + map);
      }

    } catch (HttpException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    model.close();
    //	return result;
    return null;
  }
  @Test
  public void testFileMetadataExtraction() throws Exception {
    URI testUri = new URIImpl("urn:test");
    File file =
        new File(
            this.getClass()
                .getClassLoader()
                .getResource("Construction_plan_presentation.ppt")
                .toURI());
    Model fileModel = fileDataMining.extractFromContent(testUri, file);

    assertTrue(fileModel.contains(testUri, RDF.type, NFO.FileDataObject));
    assertTrue(fileModel.contains(testUri, RDF.type, NFO.FileDataObject));
    assertFalse(fileModel.contains(testUri, NIE.rootElementOf, Variable.ANY));
    assertTrue(fileModel.contains(testUri, NIE.plainTextContent, Variable.ANY));
    assertTrue(fileModel.contains(testUri, NFO.hasHash, Variable.ANY));
  }
 /**
  * Puts the CO ontology into the given model.
  *
  * @param model The model for the source ontology to be put into.
  * @throws Exception if something goes wrong.
  */
 public static void getCOOntology(Model model) {
   try {
     InputStream stream = ResourceUtil.getInputStream(CO_RESOURCE_PATH, CO.class);
     if (stream == null) {
       throw new FileNotFoundException("couldn't find resource " + CO_RESOURCE_PATH);
     }
     model.readFrom(stream, Syntax.RdfXml);
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
示例#4
0
  public Model toRDF2GoModel() {
    Model model = RDF2Go.getModelFactory().createModel();
    model.open();

    Resource sample = this.getUri();
    model.addStatement(sample, RDF.type, this.type);
    for (PropertyValue property : properties) {
      Node object;
      if (property.getLang() != null) {
        object = model.createLanguageTagLiteral(property.getValue(), property.getLang());
      } else if (property.getDatatype() != null) {
        object = model.createDatatypeLiteral(property.getValue(), property.getDatatype());
      } else {
        object = model.createPlainLiteral(property.getValue());
      }
      model.addStatement(sample, property.getUri(), object);
    }

    return model;
  }
示例#5
0
 /**
  * Returns a Java wrapper over an RDF object, identified by a randomly generated URI. Creating two
  * wrappers results in different URIs.
  *
  * @param model RDF2GO Model implementation, see http://rdf2go.ontoware.org
  * @param write if true, the statement (this, rdf:type, TYPE) is written to the model
  *     <p>[Generated from RDFReactor template rule #c9]
  */
 public ClassRole(Model model, boolean write) {
   super(model, RDFS_CLASS, model.newRandomUniqueURI(), write);
 }
 /**
  * Returns a Java wrapper over an RDF object, identified by a randomly generated URI. Creating two
  * wrappers results in different URIs.
  *
  * @param model RDF2GO Model implementation, see http://rdf2go.ontoware.org
  * @param write if true, the statement (this, rdf:type, TYPE) is written to the model
  *     <p>[Generated from RDFReactor template rule #c9]
  */
 public Property_to_Graphic_Object_to_Object_RelationMapping(Model model, boolean write) {
   super(model, RDFS_CLASS, model.newRandomUniqueURI(), write);
 }
示例#7
0
 public Node toNode(Model model, Object javaValue) {
   return model.createDatatypeLiteral("" + javaValue, XSD._byte);
 }
示例#8
0
 /**
  * Returns a Java wrapper over an RDF object, identified by a randomly generated URI. Creating two
  * wrappers results in different URIs.
  *
  * @param model RDF2GO Model implementation, see http://rdf2go.ontoware.org
  * @param write if true, the statement (this, rdf:type, TYPE) is written to the model
  *     <p>[Generated from RDFReactor template rule #c9]
  */
 public MediaList(Model model, boolean write) {
   super(model, RDFS_CLASS, model.newRandomUniqueURI(), write);
 }
 /**
  * Returns a Java wrapper over an RDF object, identified by a randomly generated URI. Creating two
  * wrappers results in different URIs.
  *
  * @param model RDF2GO Model implementation, see http://rdf2go.ontoware.org
  * @param write if true, the statement (this, rdf:type, TYPE) is written to the model
  *     <p>[Generated from RDFReactor template rule #c9]
  */
 public SynchronizedTextElement(Model model, boolean write) {
   super(model, RDFS_CLASS, model.newRandomUniqueURI(), write);
 }
示例#10
0
 /**
  * Returns a Java wrapper over an RDF object, identified by a randomly generated URI. Creating two
  * wrappers results in different URIs.
  *
  * @param model RDF2GO Model implementation, see http://rdf2go.ontoware.org
  * @param write if true, the statement (this, rdf:type, TYPE) is written to the model
  *     <p>[Generated from RDFReactor template rule #c9]
  */
 public DataObject(Model model, boolean write) {
   super(model, RDFS_CLASS, model.newRandomUniqueURI(), write);
 }
 /**
  * Returns a Java wrapper over an RDF object, identified by a randomly generated URI. Creating two
  * wrappers results in different URIs.
  *
  * @param model RDF2GO Model implementation, see http://rdf2go.ontoware.org
  * @param write if true, the statement (this, rdf:type, TYPE) is written to the model
  *     <p>[Generated from RDFReactor template rule #c9]
  */
 public WeightedPreference(Model model, boolean write) {
   super(model, RDFS_CLASS, model.newRandomUniqueURI(), write);
 }
 /**
  * Returns a Java wrapper over an RDF object, identified by a randomly generated URI. Creating two
  * wrappers results in different URIs.
  *
  * @param model RDF2GO Model implementation, see http://rdf2go.ontoware.org
  * @param write if true, the statement (this, rdf:type, TYPE) is written to the model
  *     <p>[Generated from RDFReactor template rule #c9]
  */
 public FunctionalProperty(Model model, boolean write) {
   super(model, RDFS_CLASS, model.newRandomUniqueURI(), write);
 }
示例#13
0
 /**
  * Returns a Java wrapper over an RDF object, identified by a randomly
  * pubmed.endNote.jaxb.generated URI. Creating two wrappers results in different URIs.
  *
  * @param model RDF2GO Model implementation, see http://rdf2go.ontoware.org
  * @param write if true, the statement (this, rdf:type, TYPE) is written to the model
  *     <p>[Generated from RDFReactor template rule #c9]
  */
 public Bodymatter(Model model, boolean write) {
   super(model, RDFS_CLASS, model.newRandomUniqueURI(), write);
 }
 /**
  * Returns a Java wrapper over an RDF object, identified by a randomly generated URI. Creating two
  * wrappers results in different URIs.
  *
  * @param model RDF2GO Model implementation, see http://rdf2go.ontoware.org
  * @param write if true, the statement (this, rdf:type, TYPE) is written to the model
  *     <p>[Generated from RDFReactor template rule #c9]
  */
 public PaginatedTextDocument(Model model, boolean write) {
   super(model, RDFS_CLASS, model.newRandomUniqueURI(), write);
 }
示例#15
0
 /**
  * Returns a Java wrapper over an RDF object, identified by a randomly generated URI. Creating two
  * wrappers results in different URIs.
  *
  * @param model RDF2GO Model implementation, see http://rdf2go.ontoware.org
  * @param write if true, the statement (this, rdf:type, TYPE) is written to the model
  *     <p>[Generated from RDFReactor template rule #c9]
  */
 public AccessSpace(Model model, boolean write) {
   super(model, RDFS_CLASS, model.newRandomUniqueURI(), write);
 }
示例#16
0
 /**
  * Returns a Java wrapper over an RDF object, identified by a randomly
  * pubmed.endNote.jaxb.generated URI. Creating two wrappers results in different URIs.
  *
  * @param model RDF2GO Model implementation, see http://rdf2go.ontoware.org
  * @param write if true, the statement (this, rdf:type, TYPE) is written to the model
  *     <p>[Generated from RDFReactor template rule #c9]
  */
 public Foreword(Model model, boolean write) {
   super(model, RDFS_CLASS, model.newRandomUniqueURI(), write);
 }
 /**
  * Returns a Java wrapper over an RDF object, identified by a randomly generated URI. Creating two
  * wrappers results in different URIs.
  *
  * @param model RDF2GO Model implementation, see http://rdf2go.ontoware.org
  * @param write if true, the statement (this, rdf:type, TYPE) is written to the model
  *     <p>[Generated from RDFReactor template rule #c9]
  */
 public RealPointValue(Model model, boolean write) {
   super(model, RDFS_CLASS, model.newRandomUniqueURI(), write);
 }