Class NifEverything

java.lang.Object
org.aksw.qa.annotation.util.NifEverything

public class NifEverything extends Object
  • Field Details

    • logger

      private final org.slf4j.Logger logger
    • nif

      private static NifEverything nif
      Make this Singleton
    • INPUT_NOT_PARSABLE

      public static final String INPUT_NOT_PARSABLE
      Will be returned when given NIF via POST is not parsable or empty
      See Also:
      Constant Field Values
  • Constructor Details

    • NifEverything

      private NifEverything()
      Singleton
  • Method Details

    • getInstance

      public static NifEverything getInstance()
      Returns:
      the only possible instance (Singleton)
    • extractSplitQuestion

      private List<org.apache.commons.lang3.tuple.ImmutablePair<String,​Integer>> extractSplitQuestion(String q)
      Splits Sentence on whitespace (inserts whitespace before Punctuation). Words appear in List in same order as they are in given Sentence. The Integer-Part of ImmutablePair stores the offset of this word relative to begin of the sentence. (first word has offset 0)
      Parameters:
      q - a string to split and calculate Offset on.
      Returns:
      Words with their respective offset.
    • createNIFResultFromIndexDBO

      public String createNIFResultFromIndexDBO(String q, IndexDBO indexDBO, NifEverything.NifProperty nif)
      Creates a NIF with annotations respective to given NifEverything.NifProperty respective to given IndexDBO
      Parameters:
      q - The sentence to run IdexDBO on
      indexDBO - Choose implementation of @link IndexDBO to find properties(classes) to store in nif
      nif - The kind of Annotation how found properties(classes) should be represented in NIF (e.g. taIdentRef,taClassRef)
      Returns:
      Created NIF
    • appendNIFResultFromIndexDBO

      public String appendNIFResultFromIndexDBO(String documentsString, IndexDBO indexDBO, NifEverything.NifProperty nif)
      Appends found properties(classes) annotations to given NIF.
      Parameters:
      documentsString - The NIF as String
      indexDBO - Choose implementation of IndexDBO to find properties(classes) to store in nif.
      nif - The kind of Annotation how found properties(classes) should be represented in NIF (e.g. taIdentRef,taClassRef)
      Returns:
      The given NIF, with added annotations.
    • createNIFResultFromComparisonUtils

      public String createNIFResultFromComparisonUtils(String q, ComparisonUtils comparison, NifEverything.NifProperty nif)
      Creates a NIF with annotations respective to given NifEverything.NifProperty respective to given ComparisonUtils
      Parameters:
      q - The sentence to run ComparisonUtils on
      indexDBO - Choose implementation of @link ComparisonUtils to find properties(classes) to store in nif
      nif - The kind of Annotation how found properties(classes) should be represented in NIF (e.g. taIdentRef,taClassRef)
      Returns:
      Created NIF
    • appendNIFResultFromComparisonUtils

      public String appendNIFResultFromComparisonUtils(String documentsString, ComparisonUtils comparison, NifEverything.NifProperty nif)
      Appends found properties(classes) annotations to given NIF.
      Parameters:
      documentsString - The NIF as String
      comparison - Choose implementation of ComparisonUtils to find properties(classes) to store in nif.
      nif - The kind of Annotation how found properties(classes) should be represented in NIF (e.g. taIdentRef,taClassRef)
      Returns:
      The given NIF, with added annotations.
    • addAllMarkingsToDoc

      public void addAllMarkingsToDoc(org.aksw.gerbil.transfer.nif.Document doc, Collection<org.aksw.gerbil.transfer.nif.Marking> markings)
      Adds all given Markings to a given Document Needed, because Document does not have something like Document.addAll(Collection<Marking>)
      Parameters:
      doc - The Document you wish to add Markings to
      markings - The Markings you want to add.
    • stringToMarkingsIndexDBO

      private List<org.aksw.gerbil.transfer.nif.Marking> stringToMarkingsIndexDBO(String q, IndexDBO indexDBO, NifEverything.NifProperty nif)
      Here the actual annotation takes place. Takes some String, annotates it, and returns a List of Markings you can add to a Document
      Parameters:
      q - String to annotate
      indexDBO - Some Annotator
      nif - Specify here which Style the Annotation should have: NifEverything.NifProperty
      Returns:
      All found Annotations, ready to be added to a NIF Document
    • stringToMarkingsComparison

      private List<org.aksw.gerbil.transfer.nif.Marking> stringToMarkingsComparison(String q, ComparisonUtils comparison, NifEverything.NifProperty nif)
      Here the actual annotation takes place. Takes some String, annotates it, and returns a List of Markings you can add to a Document
      Parameters:
      q - String to annotate
      comparison - Some Annotator
      nif - Specify here which Style the Annotation should have: NifEverything.NifProperty
      Returns:
      All found Annotations, ready to be added to a NIF Document
    • appendNIFResultFromSpotters

      public String appendNIFResultFromSpotters(String documentsString, ASpotter spotter)
      Appends found NEs as annotation to given NIF. Annotation will have the form NifEverything.NifProperty.TAIDENTREF
      Parameters:
      documentsString - The NIF as String
      spotter - A NER tool to use to find named entities.
      Returns:
      The given NIF, with added annoataions.
    • writeNIF

      public String writeNIF(List<org.aksw.gerbil.transfer.nif.Document> docs)
      Creates a NIF String from given NIF Document list.
      Parameters:
      docs - List of Documents to convert
      Returns:
      NIF as String
    • createNIFResultFromSpotters

      public String createNIFResultFromSpotters(String q, ASpotter spotter)
      Creates a NIF with annotations respective to given NifEverything.NifProperty respective to given ASpotter Annotation will have the form NifEverything.NifProperty.TAIDENTREF
      Parameters:
      q - The sentence to run IdexDBO o
      spotter - A spotter to find named entities
      Returns:
      Created NIF
    • stringToMarkingsSpotters

      private List<org.aksw.gerbil.transfer.nif.Marking> stringToMarkingsSpotters(String q, ASpotter spotter)
      Here the actual annoataion takes place. Takes some String, annotates it, and returns a List of Markings you can add to a Document. Annotation will have the form NifEverything.NifProperty.TAIDENTREF
      Parameters:
      q - String to annotate
      spotter - Some NER tool
      Returns:
      All found Annotations, ready to be added to a NIF Document
    • writeNIF

      public String writeNIF(org.aksw.gerbil.transfer.nif.Document doc)
      Parameters:
      doc - A Document to vonvert to an NIF
      Returns:
      NIF as String
    • parseNIF

      public List<org.aksw.gerbil.transfer.nif.Document> parseNIF(String input) throws IllegalArgumentException
      Extracts a List of NIF Documents from given String.
      Parameters:
      input - String to be parsed
      Returns:
      NIF as Document list
      Throws:
      IllegalArgumentException - When input is empty or not parsable.