private List<Thing> handlePrepositions(CSVEntry csvEntry) { List<Thing> entities = new ArrayList<>(); String key1 = getLeftHandSideOfPreposition(); entities.addAll(processIndividualWords(key1, csvEntry)); entities.addAll(handleElementOfPreposition(key1, csvEntry)); return entities; }
private List<Thing> processAnnotations(CSVEntry csvEntry) { List<Thing> newAnnotations = new ArrayList<>(); for (String annotation : csvEntry.getAnnotations()) { if (alreadyExistingElements.containsKey(getAnnotationName(annotation))) { continue; } Thing newAnnotation = new Annotation(annotationEntity, annotation); newAnnotations.add(newAnnotation); alreadyExistingElements.put(getAnnotationName(annotation), newAnnotation); } return newAnnotations; }
private void addTopLevelElements() { rdfElements.add(annotationEntity); rdfElements.add(classesEntity); rdfElements.add(disjointClasses); Property property = new Property.PropertyBuilder() .name("has_annotation") .functional() .domain(classesEntity) .range(annotationEntity) .build(); rdfElements.add(property); }
private List<Thing> processIndividualWords(String descriptions, CSVEntry csvEntry) { List<Thing> lineEntities = new ArrayList<>(); String lastWord = getLastWord(descriptions); if (!isPreposition(lastWord)) { if (!alreadyExistingElements.containsKey(lastWord)) { final Entity entity = new Entity(classesEntity, lastWord, getMatchingAnnotations(lastWord, csvEntry)); lineEntities.add(entity); alreadyExistingElements.put(lastWord, entity); } } return lineEntities; }
public void convert(List<CSVEntry> itemsToConvert) { rdfElements = new ArrayList<>(); addTopLevelElements(); for (CSVEntry csvEntry : itemsToConvert) { rdfElements.addAll(processAnnotations(csvEntry)); if (descriptionNeedsSpecialHandling(csvEntry)) { rdfElements.addAll(processSpecialCases(csvEntry)); } else { rdfElements.addAll(processCompoundWords(csvEntry)); rdfElements.addAll(processDescription(csvEntry)); } } }