src/main/java/be/fedict/lodtools/skosifier/Main.java
private static void writeSkos(File dir, RDFFormat fmt, String ext) 
			throws IOException {
		Model M = new LinkedHashModel();

		String vocab = baseURI.endsWith("/") 
				? baseURI.substring(0, baseURI.length()-1)
				: baseURI;	
		
		IRI scheme = F.createIRI(toId(vocab));
		M.add(scheme, RDF.TYPE, SKOS.CONCEPT_SCHEME);
		
		for(String[] row: rows) {
			String id = row[0].replaceAll("\\.", "_");
			IRI node = F.createIRI(baseURI, toId(id));
		
			// parent or not
			if (row[1].isEmpty()) {
				M.add(node, SKOS.TOP_CONCEPT_OF, scheme);
				M.add(scheme, SKOS.HAS_TOP_CONCEPT, node);
			} else { 
				IRI parent = F.createIRI(baseURI, toId(row[1]));
				M.add(node, SKOS.BROADER, parent);
				M.add(parent, SKOS.NARROWER, node);
			}
			
			M.add(node, RDF.TYPE, SKOS.CONCEPT);
			M.add(node, SKOS.IN_SCHEME, scheme);
			M.add(node, SKOS.NOTATION, F.createLiteral(row[0]));
			
			for (int i = 2; i < header.length; i++) {
				if (row[i].isEmpty()) {
					continue;
				}

				// pref labels in different languages
				if (LANGS.contains(header[i])) {
					Literal label = F.createLiteral(row[i], header[i]);
					M.add(node, SKOS.PREF_LABEL, label);
					continue;
				}
				// alt labels in different languages
				if (ALT_LANGS.contains(header[i])) {
					Literal label = F.createLiteral(row[i], header[i].replace("alt_", ""));
					M.add(node, SKOS.ALT_LABEL, label);
					continue;
				}
				// definition in different languages
				if (DEF_LANGS.contains(header[i])) {
					Literal label = F.createLiteral(row[i], header[i].replace("def_", ""));
					M.add(node, SKOS.DEFINITION, label);
					continue;
				}
                                // scope notes in different languages
				if (SCOPE_LANGS.contains(header[i])) {
					Literal label = F.createLiteral(row[i], header[i].replace("scope_", ""));
					M.add(node, SKOS.SCOPE_NOTE, label);
					continue;
				}
				// optional start / end date
				if (header[i].equals("start")) {
					try {
						Date start = df.parse(row[i]);
						Literal date = F.createLiteral(start);
						M.add(node, F.createIRI(START), date);
					} catch (ParseException pe) {
						//
					}
					continue;
				}
				if (header[i].equals("end")) {
					try {
						Date end = df.parse(row[i]);
						Literal date = F.createLiteral(end);
						M.add(node,  F.createIRI(END), date);
					} catch (ParseException pe) {
					//
					}
					continue;
				}
				
				// Check skos exact/narrow match etc
				for (String prop: PROPS.keySet()) {
					if (header[i].startsWith(prop)) {
						IRI ref = F.createIRI(row[i]);
						M.add(node, PROPS.get(prop), ref);
					}
					break;
				}
				
				if (header[i].startsWith("http")) {
					M.add(node, F.createIRI(header[i]), F.createLiteral(row[i]));
				}
			}
		}
		
		File index = new File(dir, "skos." + ext);
		writeFile(fmt, index, M);
	}
/**
	 * Write SKOS files to a directory.
	 * 
	 * @param dir top level directory
	 * @param fmt format
	 * @param ext file extension
	 * @throws IOException
	 */
Write SKOS files to a directory.

@param dir top level directory
@param fmt format
@param ext file extension
@throws IOException
Write SKOS files to a directory . @param dir top level directory @param fmt format @param ext file extension @throws IOException
private static void writeSkos(File dir, RDFFormat fmt, String ext) 
			throws IOException {
		Model M = new LinkedHashModel();
		String vocab = baseURI.endsWith("/") 
				? baseURI.substring(0, baseURI.length()-1)
				: baseURI;	
		IRI scheme = F.createIRI(toId(vocab));
		M.add(scheme, RDF.TYPE, SKOS.CONCEPT_SCHEME);
		for(String[] row: rows) {
			String id = row[0].replaceAll("\\.", "_");
			IRI node = F.createIRI(baseURI, toId(id));
			if (row[1].isEmpty()) {
				M.add(node, SKOS.TOP_CONCEPT_OF, scheme);
				M.add(scheme, SKOS.HAS_TOP_CONCEPT, node);
			} else { 
				IRI parent = F.createIRI(baseURI, toId(row[1]));
				M.add(node, SKOS.BROADER, parent);
				M.add(parent, SKOS.NARROWER, node);
			}
			M.add(node, RDF.TYPE, SKOS.CONCEPT);
			M.add(node, SKOS.IN_SCHEME, scheme);
			M.add(node, SKOS.NOTATION, F.createLiteral(row[0]));
			for (int i = 2; i < header.length; i++) {
				if (row[i].isEmpty()) {
					continue;
				}
				if (LANGS.contains(header[i])) {
					Literal label = F.createLiteral(row[i], header[i]);
					M.add(node, SKOS.PREF_LABEL, label);
					continue;
				}
				if (ALT_LANGS.contains(header[i])) {
					Literal label = F.createLiteral(row[i], header[i].replace("alt_", ""));
					M.add(node, SKOS.ALT_LABEL, label);
					continue;
				}
				if (DEF_LANGS.contains(header[i])) {
					Literal label = F.createLiteral(row[i], header[i].replace("def_", ""));
					M.add(node, SKOS.DEFINITION, label);
					continue;
				}
				if (SCOPE_LANGS.contains(header[i])) {
					Literal label = F.createLiteral(row[i], header[i].replace("scope_", ""));
					M.add(node, SKOS.SCOPE_NOTE, label);
					continue;
				}
				if (header[i].equals("start")) {
					try {
						Date start = df.parse(row[i]);
						Literal date = F.createLiteral(start);
						M.add(node, F.createIRI(START), date);
					} catch (ParseException pe) {
					}
					continue;
				}
				if (header[i].equals("end")) {
					try {
						Date end = df.parse(row[i]);
						Literal date = F.createLiteral(end);
						M.add(node,  F.createIRI(END), date);
					} catch (ParseException pe) {
					}
					continue;
				}
				 Check skos exact/narrow match etc
				for (String prop: PROPS.keySet()) {
					if (header[i].startsWith(prop)) {
						IRI ref = F.createIRI(row[i]);
						M.add(node, PROPS.get(prop), ref);
					}
					break;
				}
				if (header[i].startsWith("http")) {
					M.add(node, F.createIRI(header[i]), F.createLiteral(row[i]));
				}
			}
		}
		File index = new File(dir, "skos." + ext);
		writeFile(fmt, index, M);
	}
private static void writeSkos ( File dir , RDFFormat fmt , String ext ) throws IOException { Model M = new LinkedHashModel ( ) ; String vocab = baseURI . endsWith ( "/" ) ? baseURI . substring ( 0 , baseURI . length ( ) - 1 ) : baseURI ; IRI scheme = F . createIRI ( toId ( vocab ) ) ; M . add ( scheme , RDF . TYPE , SKOS . CONCEPT_SCHEME ) ; for ( String [ ] row : rows ) { String id = row [ 0 ] . replaceAll ( "\\." , "_" ) ; IRI node = F . createIRI ( baseURI , toId ( id ) ) ; if ( row [ 1 ] . isEmpty ( ) ) { M . add ( node , SKOS . TOP_CONCEPT_OF , scheme ) ; M . add ( scheme , SKOS . HAS_TOP_CONCEPT , node ) ; } else { IRI parent = F . createIRI ( baseURI , toId ( row [ 1 ] ) ) ; M . add ( node , SKOS . BROADER , parent ) ; M . add ( parent , SKOS . NARROWER , node ) ; } M . add ( node , RDF . TYPE , SKOS . CONCEPT ) ; M . add ( node , SKOS . IN_SCHEME , scheme ) ; M . add ( node , SKOS . NOTATION , F . createLiteral ( row [ 0 ] ) ) ; for ( int i = 2 ; i < header . length ; i ++ ) { if ( row [ i ] . isEmpty ( ) ) { continue ; } if ( LANGS . contains ( header [ i ] ) ) { Literal label = F . createLiteral ( row [ i ] , header [ i ] ) ; M . add ( node , SKOS . PREF_LABEL , label ) ; continue ; } if ( ALT_LANGS . contains ( header [ i ] ) ) { Literal label = F . createLiteral ( row [ i ] , header [ i ] . replace ( "alt_" , "" ) ) ; M . add ( node , SKOS . ALT_LABEL , label ) ; continue ; } if ( DEF_LANGS . contains ( header [ i ] ) ) { Literal label = F . createLiteral ( row [ i ] , header [ i ] . replace ( "def_" , "" ) ) ; M . add ( node , SKOS . DEFINITION , label ) ; continue ; } if ( SCOPE_LANGS . contains ( header [ i ] ) ) { Literal label = F . createLiteral ( row [ i ] , header [ i ] . replace ( "scope_" , "" ) ) ; M . add ( node , SKOS . SCOPE_NOTE , label ) ; continue ; } if ( header [ i ] . equals ( "start" ) ) { try { Date start = df . parse ( row [ i ] ) ; Literal date = F . createLiteral ( start ) ; M . add ( node , F . createIRI ( START ) , date ) ; } catch ( ParseException pe ) { } continue ; } if ( header [ i ] . equals ( "end" ) ) { try { Date end = df . parse ( row [ i ] ) ; Literal date = F . createLiteral ( end ) ; M . add ( node , F . createIRI ( END ) , date ) ; } catch ( ParseException pe ) { } continue ; } for ( String prop : PROPS . keySet ( ) ) { if ( header [ i ] . startsWith ( prop ) ) { IRI ref = F . createIRI ( row [ i ] ) ; M . add ( node , PROPS . get ( prop ) , ref ) ; } break ; } if ( header [ i ] . startsWith ( "http" ) ) { M . add ( node , F . createIRI ( header [ i ] ) , F . createLiteral ( row [ i ] ) ) ; } } } File index = new File ( dir , "skos." + ext ) ; writeFile ( fmt , index , M ) ; }
Write SKOS files to a directory.
Write SKOS files to a directory .
// parent or not // pref labels in different languages // alt labels in different languages // definition in different languages // scope notes in different languages // optional start / end date // // // Check skos exact/narrow match etc