Package org.data2semantics.tools.rdf

Examples of org.data2semantics.tools.rdf.RDFFileDataSet$RDFFileFilter


  private static void createAffiliationPredictionDataSet(String dataFile, double frac) {
    Random rand = new Random(1);

    // Read in data set
    dataset = new RDFFileDataSet(dataFile, RDFFormat.N3);

    // Extract all triples with the affiliation predicate
    List<Statement> stmts = dataset.getStatementsFromStrings(null, "http://swrc.ontoware.org/ontology#affiliation", null);

    // initialize the lists of instances and labels
View Full Code Here


    System.out.println(LibSVM.computeClassCounts(LibSVM.createTargets(labels, labelMap)));
    System.out.println(labelMap);
  }

  private static void createCommitteeMemberPredictionDataSet() {
    RDFFileDataSet testSetA = new RDFFileDataSet(ISWC_FOLDER + "iswc-2011-complete.rdf", RDFFormat.RDFXML);
    //testSetA.addFile("datasets/eswc-2011-complete.rdf", RDFFormat.RDFXML);
    //testSetA.addFile("datasets/eswc-2012-complete.rdf", RDFFormat.RDFXML);
    //testSetA.addFile("datasets/eswc-2008-complete.rdf", RDFFormat.RDFXML);
    //testSetA.addFile("datasets/eswc-2009-complete.rdf", RDFFormat.RDFXML);
    //testSetA.addFile("datasets/iswc-2012-complete.rdf", RDFFormat.RDFXML);
    //testSetA.addFile("datasets/iswc-2011-complete.rdf", RDFFormat.RDFXML);
    testSetA.addFile(ISWC_FOLDER + "iswc-2010-complete.rdf", RDFFormat.RDFXML);
    //testSetA.addFile("datasets/iswc-2009-complete.rdf", RDFFormat.RDFXML);
    //testSetA.addFile("datasets/iswc-2008-complete.rdf", RDFFormat.RDFXML);

    RDFFileDataSet testSetB = new RDFFileDataSet(ISWC_FOLDER + "iswc-2012-complete.rdf", RDFFormat.RDFXML);

    instances = new ArrayList<Resource>();
    List<Resource> instancesB = new ArrayList<Resource>();
    labels = new ArrayList<Value>();
    List<Statement> stmts = testSetA.getStatementsFromStrings(null, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://xmlns.com/foaf/0.1/Person");
    for (Statement stmt : stmts) {
      instancesB.add(stmt.getSubject());
   

    int pos = 0, neg = 0;
    for (Resource instance : instancesB) {
      if (!testSetB.getStatements(instance, null, null).isEmpty()) {
        instances.add(instance);
        if (testSetB.getStatementsFromStrings(instance.toString(), "http://data.semanticweb.org/ns/swc/ontology#holdsRole", "http://data.semanticweb.org/conference/iswc/2012/pc-member/research", false).size() > 0) {
          labels.add(testSetA.createLiteral("true"));
          pos++;
        } else {
          labels.add(testSetA.createLiteral("false"));
          neg++;
View Full Code Here

    System.out.println("Pos and Neg: " + pos + " " + neg);
    System.out.println("Baseline acc: " + Math.max(pos, neg) / ((double)pos+neg));
  }

  private static void createTask2DataSet(String dataFile, double fraction, long seed) {
    RDFFileDataSet d = new RDFFileDataSet(dataFile, RDFFormat.TURTLE);

    dataset = d;

    Random rand = new Random(seed);
View Full Code Here

  private final static String DATA_DIR = "C:\\eclipse\\workspace\\datasets\\";
  private final static int NUMBER_OF_PROC = 6;


  public static void main(String[] args) {
    RDFFileDataSet testSetA = new RDFFileDataSet(DATA_DIR + "eswc-2011-complete.rdf", RDFFormat.RDFXML);
    testSetA.addFile(DATA_DIR + "eswc-2010-complete.rdf", RDFFormat.RDFXML);
    //testSetA.addFile(DATA_DIR + "eswc-2011-complete.rdf", RDFFormat.RDFXML);
    //testSetA.addFile(DATA_DIR + "eswc-2010-complete.rdf", RDFFormat.RDFXML);


    RDFFileDataSet testSetB = new RDFFileDataSet(DATA_DIR + "eswc-2012-complete.rdf", RDFFormat.RDFXML);

    List<URI> instances = new ArrayList<URI>();
    List<URI> instancesB = new ArrayList<URI>();
    List<String> labels = new ArrayList<String>();
    List<Statement> stmts = testSetA.getStatementsFromStrings(null, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://xmlns.com/foaf/0.1/Person");
    for (Statement stmt : stmts) {
      if (stmt.getSubject() instanceof URI) {
        instances.add((URI) stmt.getSubject());
      }
    } 

    int pos = 0, neg = 0;
    for (URI instance : instances) {
      if (!testSetB.getStatements(instance, null, null).isEmpty()) {
        instancesB.add(instance);
        if (testSetB.getStatementsFromStrings(instance.toString(), "http://data.semanticweb.org/ns/swc/ontology#holdsRole", "http://data.semanticweb.org/conference/eswc/2012/research-track-committee-member", false).size() > 0) {
          labels.add("true");
          pos++;
        } else {
          labels.add("false");
          neg++;
View Full Code Here

public class GraphFactoryTest {

  @Ignore
  public void test() {
    RDFFileDataSet testSetA = new RDFFileDataSet("D:\\workspaces\\datasets\\bible\\NTN-individuals.owl", RDFFormat.RDFXML);
    testSetA.addFile("D:\\workspaces\\datasets\\bible\\NTNames.owl", RDFFormat.RDFXML);
   
      //org.openrdf.model.Graph triples = testSet.getStatements(null, "http://swrc.ontoware.org/ontology#affiliation", null, true);
    List<Statement> triples = testSetA.getStatementsFromStrings("http://semanticbible.org/ns/2006/NTNames#Christianity", null,null, true);

    for (Statement triple : triples) {
      System.out.println(triple);
    }
    //System.out.println("Total humans: " + triples.size());
   
   
    List<Statement> triples2 = testSetA.getStatementsFromStrings(null, "http://semanticbible.org/ns/2006/NTNames#ethnicity", "http://semanticbible.org/ns/2006/NTNames#Jewish", true);     
    for (Statement triple2: triples2) {
      //System.out.println(triple2.getSubject() + " " + triple2.getPredicate() + " " + triple2.getObject());
     
      List<Statement> triples3 = testSetA.getStatementsFromStrings(triple2.getSubject().toString(), "http://semanticbible.org/ns/2006/NTNames#religiousBelief", "http://semanticbible.org/ns/2006/NTNames#Christianity", true);
     
      for (Statement triple3 : triples3) {
        System.out.println(triple3.getSubject() + " " + triple3.getPredicate() + " " + triple3.getObject());
      }
     
View Full Code Here

  private static void createAffiliationPredictionDataSet(double frac) {
    Random rand = new Random(1);

    // Read in data set
    dataset = new RDFFileDataSet(dataFile, RDFFormat.N3);

    // Extract all triples with the affiliation predicate
    List<Statement> stmts = dataset.getStatementsFromStrings(null, "http://swrc.ontoware.org/ontology#affiliation", null);

    // initialize the lists of instances and labels
View Full Code Here

    saveResults(resTable.toString(), "cmp_full.txt");
   
  }
 
  private static void createCommitteeMemberPredictionDataSet() {
    RDFFileDataSet testSetA = new RDFFileDataSet("datasets/eswc-2010-complete.rdf", RDFFormat.RDFXML);
    testSetA.addFile("datasets/eswc-2011-complete.rdf", RDFFormat.RDFXML);
    testSetA.addFile("datasets/eswc-2012-complete.rdf", RDFFormat.RDFXML);
    //testSetA.addFile("datasets/eswc-2008-complete.rdf", RDFFormat.RDFXML);
    //testSetA.addFile("datasets/eswc-2009-complete.rdf", RDFFormat.RDFXML);
    //testSetA.addFile("datasets/iswc-2012-complete.rdf", RDFFormat.RDFXML);
    testSetA.addFile("datasets/iswc-2011-complete.rdf", RDFFormat.RDFXML);
    testSetA.addFile("datasets/iswc-2010-complete.rdf", RDFFormat.RDFXML);
    //testSetA.addFile("datasets/iswc-2009-complete.rdf", RDFFormat.RDFXML);
    //testSetA.addFile("datasets/iswc-2008-complete.rdf", RDFFormat.RDFXML);

    RDFFileDataSet testSetB = new RDFFileDataSet("datasets/iswc-2012-complete.rdf", RDFFormat.RDFXML);

    instances = new ArrayList<Resource>();
    List<Resource> instancesB = new ArrayList<Resource>();
    labels = new ArrayList<Value>();
    List<Statement> stmts = testSetA.getStatementsFromStrings(null, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://xmlns.com/foaf/0.1/Person");
    for (Statement stmt : stmts) {
      instancesB.add(stmt.getSubject());
   

    int pos = 0, neg = 0;
    for (Resource instance : instancesB) {
      if (!testSetB.getStatements(instance, null, null).isEmpty()) {
        instances.add(instance);
        if (testSetB.getStatementsFromStrings(instance.toString(), "http://data.semanticweb.org/ns/swc/ontology#holdsRole", "http://data.semanticweb.org/conference/iswc/2012/pc-member/research", false).size() > 0) {
          labels.add(testSetA.createLiteral("true"));
          pos++;
        } else {
          labels.add(testSetA.createLiteral("false"));
          neg++;
View Full Code Here

public class FullClassRunningTimeExperiment extends FullClassExperiment {

  public static void main(String[] args) {
    String dataDir = "C:\\Users\\Gerben\\Dropbox\\data_bgs_ac_uk_ALL";
    dataset = new RDFFileDataSet(dataDir, RDFFormat.NTRIPLES);
    long seed = 11;
    long tic, toc;

    double[] fractions = {0.2, 0.4, 0.6, 0.8, 1};
    double[] fractionsSlow = {0.2, 0.4, 0.6, 0.8, 1};
View Full Code Here

      File rdfFile,
      RDFFormat format,
      List<String> vWhiteList,
      List<String> eWhiteList)
  {   
    RDFSingleDataSet testSet = new RDFFileDataSet(rdfFile, format);

    //org.openrdf.model.Graph triples = testSet.getStatements(null, "http://swrc.ontoware.org/ontology#affiliation", null, true);
    List<Statement> triples = testSet.getFullGraph();
     
    DirectedGraph<Vertex<String>, Edge<String>> jungGraph = GraphFactory.createDirectedGraph(triples, vWhiteList, eWhiteList);
       
    return jungGraph;
  }
View Full Code Here

    for (int i = 0; i < 3; i++) {
      switch (i) {
      case 0: createAffiliationPredictionDataSet(AIFB, 1); experiment(true); break;
      case 1: createCommitteeMemberPredictionDataSet(); experiment(true); break;
      case 2: dataset = new RDFFileDataSet(BGS_FOLDER, RDFFormat.NTRIPLES);
      createGeoDataSet(1, 1, "http://data.bgs.ac.uk/ref/Lexicon/hasLithogenesis"); experiment(false); break;
      case 3: createTask2DataSet(TASK2, 1,11); experiment(false); break;
      }

    }
View Full Code Here

TOP

Related Classes of org.data2semantics.tools.rdf.RDFFileDataSet$RDFFileFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.