Examples of RDFFileDataSet


Examples of org.data2semantics.tools.rdf.RDFFileDataSet

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

    boolean inference = true;

    dataset = new RDFFileDataSet("C:\\Users\\Gerben\\Dropbox\\data_bgs_ac_uk_ALL", RDFFormat.NTRIPLES);

    createGeoDataSet(10, 0.1, 1, "http://data.bgs.ac.uk/ref/Lexicon/hasUnitClass");
    List<Double> target = EvaluationUtils.createTarget(labels);

View Full Code Here

Examples of org.data2semantics.tools.rdf.RDFFileDataSet

*/
public class ExamplePair {

  public static void main(String[] args) {
    // Read in data set
    RDFFileDataSet dataset = new RDFFileDataSet("src/test/resources/aifb-fixed_complete.n3", RDFFormat.N3);

    // Random settings
    long seed = 1;
    Random rand = new Random(seed);
    double fraction = 0.2;

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

    Set<Resource> instA = new HashSet<Resource>();
    Set<Resource> instB = new HashSet<Resource>();
    Set<Pair<Resource>> posSet = new HashSet<Pair<Resource>>();
    Set<Pair<Resource>> negSet = new HashSet<Pair<Resource>>();

    // Get all the positive examples and put them in the set, store the elements of the pairs to generate negative examples
    for (Statement stmt : stmts) {
      instA.add(stmt.getSubject());
      if (stmt.getObject() instanceof Resource) {
        instB.add((Resource) stmt.getObject());
        posSet.add(new Pair<Resource>(stmt.getSubject(), (Resource) stmt.getObject()));
      }
    }

    // Generate the negative examples
    for (Resource a : instA) {
      for (Resource b : instB) {
        Pair<Resource> pair = new Pair<Resource>(a,b);
        if (!posSet.contains(pair)) {
          negSet.add(pair);
        }
      }
    }
   
    // initialize the lists of instances and labels
    List<Pair<Resource>> instances = new ArrayList<Pair<Resource>>();
    List<Value> labels = new ArrayList<Value>();
    List<Pair<Resource>> allInstances = new ArrayList<Pair<Resource>>();
    allInstances.addAll(posSet);
    allInstances.addAll(negSet);
   
    for (Pair<Resource> pair : posSet) {
      if (rand.nextDouble() <= fraction) {
        instances.add(pair);
        labels.add(dataset.createLiteral("true"));
      }
    }
   
    for (Pair<Resource> pair : negSet) {
      if (rand.nextDouble() <= fraction) {
        instances.add(pair);
        labels.add(dataset.createLiteral("false"));
      }
    }
   
    // Shuffle, since we had a perfectly ordered set
    Collections.shuffle(instances, new Random(seed));
    Collections.shuffle(labels, new Random(seed));
 
    // Create the blacklist
    List<Statement> blacklist = new ArrayList<Statement>();
    for (int i = 0; i < allInstances.size(); i++) {
      blacklist.addAll(dataset.getStatements(allInstances.get(i).getFirst(), null, allInstances.get(i).getSecond(), true));
      blacklist.addAll(dataset.getStatements(allInstances.get(i).getSecond(), null, allInstances.get(i).getFirst(), true));   
    }
 
    // create a list of doubles as train target
    List<Double> target = EvaluationUtils.createTarget(labels);

View Full Code Here

Examples of org.data2semantics.tools.rdf.RDFFileDataSet

 

  public static void main(String[] args) {
   
    // Read in data set
    RDFFileDataSet dataset = new RDFFileDataSet(dataDir, RDFFormat.NTRIPLES);
    System.out.println("Files read.");

    // Extract all triples with the lithogenesis predicate
    List<Statement> stmts = dataset.getStatementsFromStrings(null, "http://data.bgs.ac.uk/ref/Lexicon/hasLithogenesis", null, true);
   
    // initialize the lists of instances and labels
    List<Resource> instances = new ArrayList<Resource>();
    List<Value> labels = new ArrayList<Value>();

    // The subjects of the 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));

    List<Statement> blackList = new ArrayList<Statement>();
   
    // Create the blackList, we contains all triples giving information about the label of instances
    for (int i = 0; i < instances.size(); i++) {
      blackList.addAll(dataset.getStatements(instances.get(i), null, labels.get(i), true));
      if (labels.get(i) instanceof Resource) {
        blackList.addAll(dataset.getStatements((Resource) labels.get(i), null, instances.get(i), true));
      }
    }
   
    // We remove classes with fewer than 5 instances
    EvaluationUtils.removeSmallClasses(instances, labels, 5);
View Full Code Here

Examples of org.data2semantics.tools.rdf.RDFFileDataSet

public class Example {
 
  public static void main(String[] args) {
   
    // 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
    Map<Resource, List<Statement>> blackLists = new HashMap<Resource, List<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) {
      List<Statement> bl = new ArrayList<Statement>();
      bl.addAll(dataset.getStatementsFromStrings(instance.toString(), "http://swrc.ontoware.org/ontology#affiliation", null));
      bl.addAll(dataset.getStatementsFromStrings(null, "http://swrc.ontoware.org/ontology#employs", instance.toString()));
      blackLists.put(instance, bl);
    }

    // Create a new SVM property predictor
    SVMPropertyPredictor pred = new SVMPropertyPredictor();
View Full Code Here

Examples of org.data2semantics.tools.rdf.RDFFileDataSet

public class GraphClassificationDataSetTest {

  @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);
   
    //RDFDataSet testSetB = new RDFFileDataSet("D:\\workspaces\\eclipse_workspace\\rdfgraphlearning\\src\\main\\resources\\aifb-fixed_no_schema.n3", RDFFormat.N3);
   
   
    /*
 
View Full Code Here

Examples of org.data2semantics.tools.rdf.RDFFileDataSet

  public void test() {
    List<String> bl = new ArrayList<String>();
    bl.add("http://swrc.ontoware.org/ontology#affiliation");
    bl.add("http://swrc.ontoware.org/ontology#employs");
   
    RDFDataSet testSet = new RDFFileDataSet("D:\\workspaces\\datasets\\aifb\\aifb-fixed_complete.rdf", RDFFormat.RDFXML);
    LinkPredictionDataSet set = DataSetFactory.createLinkPredictonDataSet(testSet, "http://swrc.ontoware.org/ontology#Person", "http://swrc.ontoware.org/ontology#ResearchGroup", "http://swrc.ontoware.org/ontology#affiliation", bl, 2, false, false);
    System.out.println(set.getLabel());
    System.out.println(set.getLabels().size());
  }
View Full Code Here

Examples of org.data2semantics.tools.rdf.RDFFileDataSet

    List<PropertyPredictionDataSetParameters> dataSetsParams = new ArrayList<PropertyPredictionDataSetParameters>();
    //List<BinaryPropertyPredictionDataSetParameters> dataSetsParams = new ArrayList<BinaryPropertyPredictionDataSetParameters>();

   
    RDFDataSet testSetA = new RDFFileDataSet("D:\\workspaces\\datasets\\aifb\\aifb-fixed_complete.rdf", RDFFormat.RDFXML);
    RDFDataSet testSetB = new RDFFileDataSet("D:\\workspaces\\datasets\\aifb\\aifb-fixed_no_schema.n3", RDFFormat.N3);
    RDFDataSet testSetC = new RDFFileDataSet("D:\\workspaces\\datasets\\eswc-2012-complete.rdf", RDFFormat.RDFXML)
   


    List<String> bl = new ArrayList<String>();
    bl.add("http://swrc.ontoware.org/ontology#affiliation");
View Full Code Here

Examples of org.data2semantics.tools.rdf.RDFFileDataSet

   
    List<String> bl = new ArrayList<String>();
    bl.add("http://swrc.ontoware.org/ontology#affiliation");
    bl.add("http://swrc.ontoware.org/ontology#employs");
   
    RDFDataSet testSet = new RDFFileDataSet("D:\\workspaces\\datasets\\aifb\\aifb-fixed_complete.rdf", RDFFormat.RDFXML);
    LinkPredictionDataSet set = DataSetFactory.createLinkPredictonDataSet(testSet, "http://swrc.ontoware.org/ontology#Person", "http://swrc.ontoware.org/ontology#ResearchGroup", "http://swrc.ontoware.org/ontology#affiliation", bl, 2, false, false);
   
   
   
   
View Full Code Here

Examples of org.lilian.graphs.data.RDFFileDataSet

    RDFFormat format = RDFFormat.forFileName(file);
   
    if(format == null)
      throw new RuntimeException("RDF file "+file+" not recognized");
     
    RDFDataSet testSet = new RDFFileDataSet(file, format);

    List<Statement> triples = testSet.getFullGraph()
   
    return RDF.createDirectedGraph(triples, null, null);
   
  }
View Full Code Here

Examples of org.lilian.graphs.data.RDFFileDataSet

      environment = new File(out);
     
      Graph<String> graph = null;
      if(type == Type.RDFXML)
      {
        RDFDataSet testSet = new RDFFileDataSet(data, RDFFormat.RDFXML);

        List<Statement> triples = testSet.getFullGraph()
       
        graph = RDF.createDirectedGraph(triples, null, null);
       
      } else if(type == Type.TURTLE)
      {
        RDFDataSet testSet = new RDFFileDataSet(data, RDFFormat.TURTLE);

        List<Statement> triples = testSet.getFullGraph()
       
        graph = RDF.createDirectedGraph(triples, null, null);
      }
     
      Clusterer<String> cl = new GraphKMedoids<String>(NUM_CLUSTERS);
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.