|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.uchsc.ccp.knowtator.AnnotationUtil
public class AnnotationUtil
Authors: Philip V. Ogren Created: September, 2004 Description: This class aids in creating, editing and retrieving annotation intances as well as the supporting annotation classes. The annotation model is defined in annotations.pprj. This project must be included when the annotator plug-in is used. Todo: AnnotationUtil should really not have an instance of knowtator as a member variable. I need to create the appropriate listeners, so that Knowtator can take care of itself as it see fits. Changes: 02/28/2005 added annotation filter functionality 05/02/2005 package changed to ...knowtator 8/11/2005 pvo added getReferencedAnnotations method 10/04/2005 Changed signature of main createAnnotations method so that a string for the spanned text can be passed in. This removes the necessity of gathering the spanned text from the actual text source which may be an unnecessary task if you are copying an annotation (e.g. as in MergeAnnotations). This change had a small ripple effect on other methods: setSpans, updateAnnotationText 10/04/2005 Changed name of deleteAnnotationMention to deleteMention (I just didn't like the name!)
Constructor Summary | |
---|---|
AnnotationUtil(KnowtatorManager manager)
|
Method Summary | |
---|---|
boolean |
compareSpans(List<SimpleInstance> annotations)
|
boolean |
compareSpans(SimpleInstance annotation1,
SimpleInstance annotation2)
This method returns true if two annotations have exactly the same spans. |
SimpleInstance |
createAnnotation(Cls annotationCls,
List<Span> spans,
String spannedText,
String textSourceName)
|
SimpleInstance |
createAnnotation(Cls annotationCls,
List<Span> spans,
String spannedText,
String textSourceName,
SimpleInstance annotator,
SimpleInstance set)
|
SimpleInstance |
createAnnotation(SimpleInstance mention,
SimpleInstance annotator,
List<Span> spans,
SimpleInstance textSourceInstance,
SimpleInstance annotationSet)
|
SimpleInstance |
createAnnotation(SimpleInstance mention,
SimpleInstance annotator,
List<Span> spans,
String spannedText,
SimpleInstance textSourceInstance,
Collection<SimpleInstance> annotationSets)
|
SimpleInstance |
createAnnotation(SimpleInstance mention,
SimpleInstance annotator,
List<Span> spans,
String spannedText,
SimpleInstance textSourceInstance,
Collection<SimpleInstance> annotationSets,
String creationDate)
Creates an annotation. |
SimpleInstance |
createAnnotation(SimpleInstance mention,
SimpleInstance annotator,
List<Span> spans,
TextSource textSource,
SimpleInstance annotationSet)
If the textSource does not have a corresponding instance in the kb, then one will be created. |
void |
deleteMention(SimpleInstance annotation)
This method deletes the mention of annotation. |
Collection<SimpleInstance> |
getAnnotations(SimpleInstance textSourceInstance)
Does the work of finding all "annotation" instances that have the textSourceInstance as the value of "annotation_text_source" slot. |
Collection<SimpleInstance> |
getAnnotations(String textSourceName)
|
Collection<SimpleInstance> |
getAnnotations(TextSource textSource)
Returns the "annotation" instances associated with a TextSource if the TextSource does not have a corresponding "text source" instance in the knowledgebase, then null is returned. |
SimpleInstance |
getAnnotator(SimpleInstance annotation)
|
String |
getComment(SimpleInstance annotation)
|
String |
getCreationDate(SimpleInstance annotation)
|
SimpleInstance |
getMention(SimpleInstance annotation)
|
Set<SimpleInstance> |
getRelatedAnnotations(SimpleInstance annotation)
Returns all annotations that are related to the passed in annotation. |
Set<SimpleInstance> |
getSets(SimpleInstance annotation)
|
SimpleInstance |
getShortestAnnotation(Collection<SimpleInstance> annotations)
This method returns the shortest annotation - that is the annotation whose span is the shortest. |
int |
getSize(SimpleInstance annotation)
|
List<Span> |
getSpans(SimpleInstance annotation)
Returns a list of Span objects that correspond to the span values given to an annotation instance. |
List<Span> |
getSpans(SimpleInstance annotation,
boolean ignoreCache)
Returns a list of Span objects that correspond to the span values given to an annotation instance. |
String |
getText(SimpleInstance annotation)
|
SimpleInstance |
getTextSource(SimpleInstance annotation)
|
boolean |
hasTeamAnnotator(SimpleInstance annotation)
|
boolean |
isAnnotation(SimpleInstance annotation)
|
List<SimpleInstance> |
retrieveAllAnnotations()
|
void |
setAnnotator(SimpleInstance annotation,
SimpleInstance annotator)
|
void |
setComment(SimpleInstance annotation,
String comment)
|
void |
setCreationDate(SimpleInstance annotation,
String creationDate)
|
void |
setMention(SimpleInstance annotation,
SimpleInstance mention)
|
void |
setMentionUtil(MentionUtil mentionUtil)
|
void |
setProjectAnnotationSet(SimpleInstance annotation)
|
void |
setProjectAnnotator(SimpleInstance annotation)
|
void |
setSet(SimpleInstance annotation,
SimpleInstance set)
|
void |
setSets(SimpleInstance annotation,
Collection<SimpleInstance> sets)
|
void |
setSpans(SimpleInstance annotation,
List<Span> spans,
String spannedText)
Sets the spans slot for an annotation instance. |
void |
setText(SimpleInstance annotation,
String spannedText)
|
void |
setTextSource(SimpleInstance annotation,
SimpleInstance textSource)
|
void |
setTextSourceUtil(TextSourceUtil textSourceUtil)
|
void |
spanEditted(SpanEditEvent see)
To get the currently selected spans at any time call KnowtatorProjectUtil.getSelectedSpans() |
boolean |
spansOverlap(SimpleInstance annotation1,
SimpleInstance annotation2)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AnnotationUtil(KnowtatorManager manager)
Method Detail |
---|
public void setTextSourceUtil(TextSourceUtil textSourceUtil)
public void setMentionUtil(MentionUtil mentionUtil)
public void deleteMention(SimpleInstance annotation)
annotation
- the mention of this annotation will be deleted via
mentionUtil.deleteMention.public void spanEditted(SpanEditEvent see)
SpanEditListener
spanEditted
in interface SpanEditListener
KnowtatorManager.getSelectedSpans()
public List<Span> getSpans(SimpleInstance annotation) throws InvalidSpanException
annotation
- the spans for the annotation will be returned
InvalidSpanException
public List<Span> getSpans(SimpleInstance annotation, boolean ignoreCache) throws InvalidSpanException
annotation
- the spans for the annotation will be returned
InvalidSpanException
public void setSpans(SimpleInstance annotation, List<Span> spans, String spannedText) throws TextSourceAccessException
annotation
- set the span slot for the passed in annotationspans
- a list of spans for the annotation. This will typically be a
list of 1 span object, but may occasionally have a 2 or more
spans.spannedText
- if null, then the text from the text source for the annotation
will be used to determine the spannedText. If the spannedText
is already known, then it may be useful to pass in the
spannedText. Passing in an empty string will cause the
spannedText to be an empty string.
TextSourceAccessException
public Collection<SimpleInstance> getAnnotations(TextSource textSource)
public Collection<SimpleInstance> getAnnotations(String textSourceName)
public Collection<SimpleInstance> getAnnotations(SimpleInstance textSourceInstance)
public SimpleInstance createAnnotation(Cls annotationCls, List<Span> spans, String spannedText, String textSourceName) throws TextSourceAccessException
TextSourceAccessException
public SimpleInstance createAnnotation(Cls annotationCls, List<Span> spans, String spannedText, String textSourceName, SimpleInstance annotator, SimpleInstance set) throws TextSourceAccessException
TextSourceAccessException
public SimpleInstance createAnnotation(SimpleInstance mention, SimpleInstance annotator, List<Span> spans, TextSource textSource, SimpleInstance annotationSet) throws TextSourceAccessException
TextSourceAccessException
public SimpleInstance createAnnotation(SimpleInstance mention, SimpleInstance annotator, List<Span> spans, SimpleInstance textSourceInstance, SimpleInstance annotationSet) throws TextSourceAccessException
TextSourceAccessException
public SimpleInstance createAnnotation(SimpleInstance mention, SimpleInstance annotator, List<Span> spans, String spannedText, SimpleInstance textSourceInstance, Collection<SimpleInstance> annotationSets) throws TextSourceAccessException
TextSourceAccessException
public SimpleInstance createAnnotation(SimpleInstance mention, SimpleInstance annotator, List<Span> spans, String spannedText, SimpleInstance textSourceInstance, Collection<SimpleInstance> annotationSets, String creationDate) throws TextSourceAccessException
creationDate
- A String representation of the date (time stamp) the
annotation was created.
TextSourceAccessException
public boolean compareSpans(SimpleInstance annotation1, SimpleInstance annotation2)
public boolean compareSpans(List<SimpleInstance> annotations)
public boolean isAnnotation(SimpleInstance annotation)
public boolean hasTeamAnnotator(SimpleInstance annotation)
public void setProjectAnnotator(SimpleInstance annotation)
public void setProjectAnnotationSet(SimpleInstance annotation)
public Set<SimpleInstance> getRelatedAnnotations(SimpleInstance annotation)
public List<SimpleInstance> retrieveAllAnnotations()
public void setAnnotator(SimpleInstance annotation, SimpleInstance annotator)
public void setSet(SimpleInstance annotation, SimpleInstance set)
public void setSets(SimpleInstance annotation, Collection<SimpleInstance> sets)
public Set<SimpleInstance> getSets(SimpleInstance annotation)
public SimpleInstance getTextSource(SimpleInstance annotation)
public void setTextSource(SimpleInstance annotation, SimpleInstance textSource)
public String getText(SimpleInstance annotation)
public void setText(SimpleInstance annotation, String spannedText)
public boolean spansOverlap(SimpleInstance annotation1, SimpleInstance annotation2)
public int getSize(SimpleInstance annotation) throws InvalidSpanException
InvalidSpanException
- if the annotation has a badly formed span, then an exception
will be thrown.public SimpleInstance getShortestAnnotation(Collection<SimpleInstance> annotations)
annotations
-
public SimpleInstance getMention(SimpleInstance annotation)
public void setMention(SimpleInstance annotation, SimpleInstance mention)
public SimpleInstance getAnnotator(SimpleInstance annotation)
public String getComment(SimpleInstance annotation)
public void setComment(SimpleInstance annotation, String comment)
public String getCreationDate(SimpleInstance annotation)
public void setCreationDate(SimpleInstance annotation, String creationDate)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |