Examples of RDFFileDataSet


Examples of org.data2semantics.tools.rdf.RDFFileDataSet

  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

Examples of org.data2semantics.tools.rdf.RDFFileDataSet

    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

Examples of org.data2semantics.tools.rdf.RDFFileDataSet

    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

Examples of org.data2semantics.tools.rdf.RDFFileDataSet

  }
 
  @Main
  public RDFFileDataSet getDataSet(){
    LOG.info("In module, creating dataset");
    dataset=new RDFFileDataSet(dataDirectory, RDFFormat.NTRIPLES);
    createGeoDataSet(10,fraction,123, predicateFilter2);
    LOG.info("In module, done creating dataset");
    return dataset;
  }
View Full Code Here

Examples of org.data2semantics.tools.rdf.RDFFileDataSet

public class RDFIntersectionSubTreeKernelTest {

  @Ignore
  public void test() {
    // Read in data set
    RDFFileDataSet dataset = new RDFFileDataSet("src/test/resources/aifb-fixed_complete.n3", RDFFormat.N3);
    System.out.println("File read.");

    // 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
    List<Resource> instances = new ArrayList<Resource>();
    List<Value> labels = new ArrayList<Value>();

    // The subjects of the affiliation triples will we our instances and the objects our labels
    for (Statement stmt : stmts) {
      instances.add(stmt.getSubject());
      labels.add(stmt.getObject());
    }
    // Shuffle them, just to be sure
    Collections.shuffle(instances, new Random(1));
    Collections.shuffle(labels, new Random(1));

    // the blackLists data structure
    List<Statement> blackList = new ArrayList<Statement>();

    // For each instance we add the triples that give the label of the instance (i.e. the URI of the affiliation)
    // In this case this is the affiliation triple and the reverse relation triple, which is the employs relation.
    for (Resource instance : instances) {
      blackList.addAll(dataset.getStatementsFromStrings(instance.toString(), "http://swrc.ontoware.org/ontology#affiliation", null));
      blackList.addAll(dataset.getStatementsFromStrings(null, "http://swrc.ontoware.org/ontology#employs", instance.toString()));
    }
    RDFIntersectionPartialSubTreeKernel kernel = new RDFIntersectionPartialSubTreeKernel();
    double[][] matrix = kernel.compute(dataset, instances, blackList);
   
    for (int i = 0; i < matrix.length; i++) {
View Full Code Here

Examples of org.data2semantics.tools.rdf.RDFFileDataSet

public class RDFWLSubTreeKernelTest {

  @Ignore
  public void test() {
    // Read in data set
    RDFFileDataSet dataset = new RDFFileDataSet("src/test/resources/aifb-fixed_complete.n3", RDFFormat.N3);
    System.out.println("File read.");

    // 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
    List<Resource> instances = new ArrayList<Resource>();
    List<Value> labels = new ArrayList<Value>();

    // The subjects of the affiliation triples will we our instances and the objects our labels
    for (Statement stmt : stmts) {
      instances.add(stmt.getSubject());
      labels.add(stmt.getObject());
    }
    // Shuffle them, just to be sure
    Collections.shuffle(instances, new Random(1));
    Collections.shuffle(labels, new Random(1));

    // the blackLists data structure
    List<Statement> blackList = new ArrayList<Statement>();

    // For each instance we add the triples that give the label of the instance (i.e. the URI of the affiliation)
    // In this case this is the affiliation triple and the reverse relation triple, which is the employs relation.
    for (Resource instance : instances) {
      blackList.addAll(dataset.getStatementsFromStrings(instance.toString(), "http://swrc.ontoware.org/ontology#affiliation", null));
      blackList.addAll(dataset.getStatementsFromStrings(null, "http://swrc.ontoware.org/ontology#employs", instance.toString()));
    }
   
    new RDFWLSubTreeKernel().compute(dataset, instances, blackList);
  }
View Full Code Here

Examples of org.data2semantics.tools.rdf.RDFFileDataSet

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

    // Read in data set
    dataset = new RDFFileDataSet("datasets/aifb-fixed_complete.n3", 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

Examples of org.data2semantics.tools.rdf.RDFFileDataSet

public class FullThemeRunningTimeExperiment extends FullThemeExperiment {

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

    double[] fractions = {0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1};
    double[] fractionsSlow = {0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1};
View Full Code Here

Examples of org.data2semantics.tools.rdf.RDFFileDataSet

    long[] seeds = {11, 21, 31, 41, 51, 61, 71, 81, 91, 101};
    double[] cs = {0.001, 0.01, 0.1, 1, 10, 100, 1000}

    int[] depths = {1, 2, 3};
    int[] iterations = {0, 2, 4, 6};
    dataset = new RDFFileDataSet(dataDir, RDFFormat.NTRIPLES);

    ResultsTable resTable = new ResultsTable();
    resTable.setManWU(0.05);

    boolean inference = false;
View Full Code Here

Examples of org.data2semantics.tools.rdf.RDFFileDataSet

    int[] depths = {1,2,3};
    int[] iterations = {0};

    double fraction = 0.1;

    dataset = new RDFFileDataSet("datasets\\Stadsverkeer.ttl", RDFFormat.TURTLE);

    List<EvaluationFunction> evalFuncs = new ArrayList<EvaluationFunction>();
    evalFuncs.add(new Accuracy());
    evalFuncs.add(new F1());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.