private double getDistance(Site site1, String rule1, Site site2, String rule2) { File fileR1 = new File(Paths.PATH_INTRASITE + "/" + site1.getPath() + "/extracted_values/" + rule1); DataType typeR1 = RuleDataType.getMostFrequentType(fileR1); Map<String, String> entityValuesR1 = Loader.loadEntityValues(fileR1, Loader.loadEntityID(site1)); File fileR2 = new File(Paths.PATH_INTRASITE + "/" + site2.getPath() + "/extracted_values/" + rule2); DataType typeR2 = RuleDataType.getMostFrequentType(fileR2); Map<String, String> entityValuesR2 = Loader.loadEntityValues(fileR2, Loader.loadEntityID(site2)); return TypeAwareDistance.typeDistance(entityValuesR1, typeR1, entityValuesR2, typeR2); }
// obter as masterRules de cada site para cada atributo private String getMasterRule(Site site, Attribute attribute) { try (Reader in = new FileReader(Paths.PATH_INTRASITE + "/" + site.getPath() + "/result.csv")) { try (CSVParser parser = new CSVParser(in, CSVFormat.EXCEL.withHeader())) { for (CSVRecord record : parser) { if (record.get("ATTRIBUTE").equals(attribute.getAttributeID())) { if (record.get("RULE").equals("Attribute not found")) { return null; } return record.get("RULE"); } } } } catch (FileNotFoundException ex) { Logger.getLogger(CheckDistanceExpectedMapping.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(CheckDistanceExpectedMapping.class.getName()).log(Level.SEVERE, null, ex); } return null; }