Java Code Examples for org.openrdf.rio.RDFFormat#N3

The following examples show how to use org.openrdf.rio.RDFFormat#N3 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuickFVCheck.java    From mustard with MIT License 5 votes vote down vote up
/**
 * @param args
 */
public static void main(String[] args) {
	RDFDataSet tripleStore = new RDFFileDataSet(AIFB_FILE, RDFFormat.N3);
	ClassificationDataSet ds = new AIFBDataSet(tripleStore, true);
	ds.create();

	RDFRootWalkCountKernel k = new RDFRootWalkCountKernel(2, false, false);

	SparseVector[] fvs = k.computeFeatureVectors(ds.getRDFData());

	int lastIndex = fvs[0].getLastIndex();
	
	List<Integer> inds = new ArrayList<Integer>();
	for (int i = 0; i < lastIndex; i++) {
		inds.add(i);
	}
	List<String> labels = k.getFeatureDescriptions(inds);
	
	for (int i = 0; i < lastIndex; i++) {
		System.out.print(labels.get(i) + ", ");
	}
	System.out.print("\n");
	
	for (int j = 0; j < fvs.length; j++) {
		System.out.print(ds.getRDFData().getInstances().get(j) + ": ");
		for (int i = 0; i < lastIndex; i++) {
			System.out.print(fvs[j].getValue(i) + ", ");
		}
		System.out.print("\n");
	}

}
 
Example 2
Source File: ExampleFeatureInspectionExperiment.java    From mustard with MIT License 3 votes vote down vote up
/**
 * @param args
 */
public static void main(String[] args) {
	
	RDFDataSet tripleStore = new RDFFileDataSet(AIFB_FILE, RDFFormat.N3);
	ClassificationDataSet ds = new AIFBDataSet(tripleStore);
	ds.create();

	double[] cs = {1,10,100,1000};	

	LibLINEARParameters svmParms = new LibLINEARParameters(LibLINEARParameters.SVC_DUAL, cs);
	svmParms.setNumFolds(5);

	boolean reverseWL = true; // WL should be in reverse mode, which means regular subtrees
	boolean[] inference = {false};

	int[] depths = {2};
	
	int maxFeatures = 10;
	

	RDFData data = ds.getRDFData();
	List<Double> target = ds.getTarget();
	
	
	for (boolean inf : inference) {
		for (int d : depths) {
			List<RDFWLSubTreeKernel> kernels = new ArrayList<RDFWLSubTreeKernel>();	
			kernels.add(new RDFWLSubTreeKernel(d*2, d, inf, reverseWL, true, true));

			FeatureInspectionExperiment<RDFData,RDFWLSubTreeKernel> exp = new FeatureInspectionExperiment<RDFData,RDFWLSubTreeKernel>(kernels, data, target, svmParms, maxFeatures);
			exp.run();
		}
	}
}
 
Example 3
Source File: RDFUtilsTest.java    From mustard with MIT License 3 votes vote down vote up
@Test
public void test() {
	
	RDFDataSet tripleStore = new RDFFileDataSet(AIFB_FILE, RDFFormat.N3);
	
	
	DTGraph<String,String> graph = RDFUtils.statements2Graph(new HashSet<Statement>(tripleStore.getFullGraph()), RDFUtils.REGULAR_SPLIT_LITERALS);
	
	for (DTNode<String,String> n : graph.nodes()) {
		System.out.println(n);
	}
}