Package org.aksw.qa.annotation.util
Class NifEverything
java.lang.Object
org.aksw.qa.annotation.util.NifEverything
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classWraps implementations ofMarking. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic StringWill be returned when given NIF via POST is not parsable or emptyprivate org.slf4j.Loggerprivate static NifEverythingMake this Singleton -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllMarkingsToDoc(org.aksw.gerbil.transfer.nif.Document doc, Collection<org.aksw.gerbil.transfer.nif.Marking> markings)Adds all givenMarkings to a givenDocumentNeeded, becauseDocumentdoes not have something like Document.addAll(Collection<Marking>)appendNIFResultFromComparisonUtils(String documentsString, ComparisonUtils comparison, NifEverything.NifProperty nif)Appends found properties(classes) annotations to given NIF.appendNIFResultFromIndexDBO(String documentsString, IndexDBO indexDBO, NifEverything.NifProperty nif)Appends found properties(classes) annotations to given NIF.appendNIFResultFromSpotters(String documentsString, ASpotter spotter)Appends found NEs as annotation to given NIF.createNIFResultFromComparisonUtils(String q, ComparisonUtils comparison, NifEverything.NifProperty nif)Creates a NIF with annotations respective to givenNifEverything.NifPropertyrespective to givenComparisonUtilscreateNIFResultFromIndexDBO(String q, IndexDBO indexDBO, NifEverything.NifProperty nif)Creates a NIF with annotations respective to givenNifEverything.NifPropertyrespective to givenIndexDBOcreateNIFResultFromSpotters(String q, ASpotter spotter)Creates a NIF with annotations respective to givenNifEverything.NifPropertyrespective to givenASpotterAnnotation will have the formNifEverything.NifProperty.TAIDENTREFSplits Sentence on whitespace (inserts whitespace before Punctuation).static NifEverythingList<org.aksw.gerbil.transfer.nif.Document>Extracts a List of NIFDocuments from given String.private List<org.aksw.gerbil.transfer.nif.Marking>stringToMarkingsComparison(String q, ComparisonUtils comparison, NifEverything.NifProperty nif)Here the actual annotation takes place.private List<org.aksw.gerbil.transfer.nif.Marking>stringToMarkingsIndexDBO(String q, IndexDBO indexDBO, NifEverything.NifProperty nif)Here the actual annotation takes place.private List<org.aksw.gerbil.transfer.nif.Marking>stringToMarkingsSpotters(String q, ASpotter spotter)Here the actual annoataion takes place.Creates a NIF String from given NIFDocumentlist.writeNIF(org.aksw.gerbil.transfer.nif.Document doc)
-
Field Details
-
logger
private final org.slf4j.Logger logger -
nif
Make this Singleton -
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
- 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 givenNifEverything.NifPropertyrespective to givenIndexDBO- Parameters:
q- The sentence to run IdexDBO onindexDBO- Choose implementation of @linkIndexDBOto find properties(classes) to store in nifnif- 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 StringindexDBO- Choose implementation ofIndexDBOto 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 givenNifEverything.NifPropertyrespective to givenComparisonUtils- Parameters:
q- The sentence to run ComparisonUtils onindexDBO- Choose implementation of @linkComparisonUtilsto find properties(classes) to store in nifnif- 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 Stringcomparison- Choose implementation ofComparisonUtilsto 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 givenMarkings to a givenDocumentNeeded, becauseDocumentdoes not have something like Document.addAll(Collection<Marking>)- Parameters:
doc- TheDocumentyou wish to addMarkings tomarkings- TheMarkings 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 ofMarkings you can add to aDocument- Parameters:
q- String to annotateindexDBO- Some Annotatornif- 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 ofMarkings you can add to aDocument- Parameters:
q- String to annotatecomparison- Some Annotatornif- Specify here which Style the Annotation should have:NifEverything.NifProperty- Returns:
- All found Annotations, ready to be added to a NIF
Document
-
appendNIFResultFromSpotters
Appends found NEs as annotation to given NIF. Annotation will have the formNifEverything.NifProperty.TAIDENTREF- Parameters:
documentsString- The NIF as Stringspotter- A NER tool to use to find named entities.- Returns:
- The given NIF, with added annoataions.
-
writeNIF
Creates a NIF String from given NIFDocumentlist.- Parameters:
docs- List ofDocuments to convert- Returns:
- NIF as String
-
createNIFResultFromSpotters
Creates a NIF with annotations respective to givenNifEverything.NifPropertyrespective to givenASpotterAnnotation will have the formNifEverything.NifProperty.TAIDENTREF- Parameters:
q- The sentence to run IdexDBO ospotter- 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 ofMarkings you can add to aDocument. Annotation will have the formNifEverything.NifProperty.TAIDENTREF- Parameters:
q- String to annotatespotter- Some NER tool- Returns:
- All found Annotations, ready to be added to a NIF
Document
-
writeNIF
- Parameters:
doc- ADocumentto vonvert to an NIF- Returns:
- NIF as String
-
parseNIF
public List<org.aksw.gerbil.transfer.nif.Document> parseNIF(String input) throws IllegalArgumentExceptionExtracts a List of NIFDocuments from given String.- Parameters:
input- String to be parsed- Returns:
- NIF as
Documentlist - Throws:
IllegalArgumentException- When input is empty or not parsable.
-