/** * * @param id * @param prefix */ public void addMapping(int id, String prefix) { if (prefix == null) { prefix = ""; } mappings.put(id, new CSV_Mapping(id, prefix)); }
/** * * @param src_id * @param target_id * @param predicate_URI */ public void addStatementTemplate(int src_id, int target_id, URI predicate_URI) { assert predicate_URI != null; statementTemplates.put(src_id, new CSV_StatementTemplate(src_id, target_id, predicate_URI)); }
@Override public void populate(GDataConf conf, G g) throws SLIB_Exception { logger.info("-------------------------------------"); logger.info("Loading CSV."); logger.info("-------------------------------------"); this.g = g; loadConf(conf); loadCSV(conf.getLoc()); logger.info("CSV specification loaded."); logger.info("-------------------------------------"); }
CSV_Mapping m = new CSV_Mapping(field, prefix); mappings.put(field, m); CSV_StatementTemplate m = new CSV_StatementTemplate(s_id, o_id, p); CSV_StatementTemplate_Constraint constraint = new CSV_StatementTemplate_Constraint(elem, type); m.addConstraint(constraint);
private void loadCSV(String filepath) throws SLIB_Exception { long evaluated = 0; // number of statements evaluated according to the templates defined long rejected = 0; // those excluded due to specified constraints. try { FileInputStream fstream = new FileInputStream(filepath); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String line; String[] data; while ((line = br.readLine()) != null) { if (skipHeader) { skipHeader = false; continue; } line = line.trim(); data = pattern.split(line); for (CSV_StatementTemplate t : statementTemplates.values()) { if (!buildStatement(t, data)) { rejected++; } evaluated++; } } in.close(); } catch (IOException e) { throw new SLIB_Ex_Critic(e.getMessage()); } logger.info("Number of statements rejected due to constraint: " + rejected + "/" + evaluated); logger.info("CSV Loading ok."); }
return new RDFLoader(RDFFormat.TURTLE); } else if (data.getFormat() == GFormat.CSV) { return new GraphLoader_CSV(); } else if (data.getFormat() == GFormat.SNOMED_CT_RF2) { return new GraphLoaderSnomedCT_RF2();
CSV_Mapping m = new CSV_Mapping(field, prefix); mappings.put(field, m); CSV_StatementTemplate m = new CSV_StatementTemplate(s_id, o_id, p); CSV_StatementTemplate_Constraint constraint = new CSV_StatementTemplate_Constraint(elem, type); m.addConstraint(constraint);
/** * * @param id * @param prefix */ public void addMapping(int id, String prefix) { if (prefix == null) { prefix = ""; } mappings.put(id, new CSV_Mapping(id, prefix)); }
/** * * @param src_id * @param target_id * @param predicate_URI */ public void addStatementTemplate(int src_id, int target_id, URI predicate_URI) { assert predicate_URI != null; statementTemplates.put(src_id, new CSV_StatementTemplate(src_id, target_id, predicate_URI)); }
@Override public void populate(GDataConf conf, G g) throws SLIB_Exception { logger.info("-------------------------------------"); logger.info("Loading CSV."); logger.info("-------------------------------------"); this.g = g; loadConf(conf); loadCSV(conf.getLoc()); logger.info("CSV specification loaded."); logger.info("-------------------------------------"); }
private void loadCSV(String filepath) throws SLIB_Exception { long evaluated = 0; // number of statements evaluated according to the templates defined long rejected = 0; // those excluded due to specified constraints. try { FileInputStream fstream = new FileInputStream(filepath); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String line; String[] data; while ((line = br.readLine()) != null) { if (skipHeader) { skipHeader = false; continue; } line = line.trim(); data = pattern.split(line); for (CSV_StatementTemplate t : statementTemplates.values()) { if (!buildStatement(t, data)) { rejected++; } evaluated++; } } in.close(); } catch (IOException e) { throw new SLIB_Ex_Critic(e.getMessage()); } logger.info("Number of statements rejected due to constraint: " + rejected + "/" + evaluated); logger.info("CSV Loading ok."); }
return new RDFLoader(RDFFormat.TURTLE); } else if (data.getFormat() == GFormat.CSV) { return new GraphLoader_CSV(); } else if (data.getFormat() == GFormat.SNOMED_CT_RF2) { return new GraphLoaderSnomedCT_RF2();