Exemplo n.º 1
0
 private Thing getParentFromIndividualWords(String key) {
   for (String keyPart : key.split(SPACE)) {
     if (alreadyExistingElements.containsKey(keyPart)) {
       return alreadyExistingElements.get(keyPart);
     }
   }
   return new NullEntity();
 }
Exemplo n.º 2
0
 private List<Thing> handleElementOfPreposition(String key, CSVEntry csvEntry) {
   if (alreadyExistingElements.containsKey(key)) {
     return Collections.emptyList();
   }
   Thing possibleParent = getParentFromIndividualWords(key);
   Thing entity = new Entity(possibleParent, key, csvEntry.getAnnotations());
   alreadyExistingElements.put(key, entity);
   return Collections.singletonList(entity);
 }
Exemplo n.º 3
0
 private List<Thing> processDescription(CSVEntry csvEntry) {
   if (alreadyExistingElements.containsKey(csvEntry.getDescription())) {
     return Collections.emptyList();
   }
   Thing parent = getParent(csvEntry);
   Thing entity = new Entity(parent, csvEntry.getDescription(), csvEntry.getAnnotations());
   alreadyExistingElements.put(csvEntry.getDescription(), entity);
   return Collections.singletonList(entity);
 }
Exemplo n.º 4
0
 private Thing getParentUsingFullDescription(String description) {
   if (hasMultipleWordParent(description)) {
     return getMultipleWordParent(description);
   }
   String lastWord = getLastWord(description);
   if (alreadyExistingElements.containsKey(lastWord)) {
     return alreadyExistingElements.get(lastWord);
   }
   return new NullEntity();
 }
Exemplo n.º 5
0
 private Thing getParentAfterRemovingFirstWord(String parent) {
   String[] splitWords = parent.split(SPACE, 2);
   while (splitWords.length == 2) {
     if (alreadyExistingElements.containsKey(splitWords[1])) {
       return alreadyExistingElements.get(splitWords[1]);
     } else {
       splitWords = splitWords[1].split(SPACE, 2);
     }
   }
   return alreadyExistingElements.get(splitWords[0]);
 }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
 private boolean hasMultipleWordParent(String leftHandSideOfPreposition) {
   if (alreadyExistingElements.containsKey(leftHandSideOfPreposition)) {
     return true;
   }
   String[] headAndTail = leftHandSideOfPreposition.split(SPACE, 2);
   while (headAndTail.length == 2) {
     String tail = headAndTail[1];
     if (alreadyExistingElements.containsKey(tail)) {
       return true;
     }
     headAndTail = tail.split(SPACE, 2);
   }
   return false;
 }
Exemplo n.º 9
0
 private List<Thing> processSpecialCases(CSVEntry csvEntry) {
   Thing parent = getParentFromPreposition(csvEntry);
   Thing subClasses = new Entity(parent, csvEntry.getDescription(), csvEntry.getAnnotations());
   alreadyExistingElements.put(csvEntry.getDescription(), subClasses);
   return Arrays.asList(parent, subClasses);
 }
Exemplo n.º 10
0
 private Thing getMultipleWordParent(String parent) {
   if (alreadyExistingElements.containsKey(parent)) {
     return alreadyExistingElements.get(parent);
   }
   return getParentAfterRemovingFirstWord(parent);
 }
Exemplo n.º 11
0
 private Thing getParentFromPreposition(String description) {
   if (hasMultipleWordParent(description)) {
     return getMultipleWordParent(description);
   }
   return alreadyExistingElements.get(description);
 }