本文整理了Java中org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation.getCoveredText()
方法的一些代码示例,展示了IdentifiedAnnotation.getCoveredText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IdentifiedAnnotation.getCoveredText()
方法的具体详情如下:
包路径:org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation
类名称:IdentifiedAnnotation
方法名:getCoveredText
暂无
代码示例来源:origin: apache/tika
IdentifiedAnnotation annotation = iterator.next();
StringBuilder annotationBuilder = new StringBuilder();
annotationBuilder.append(annotation.getCoveredText());
if (annotationPros != null) {
for (CTAKESAnnotationProperty property : annotationPros) {
代码示例来源:origin: apache/ctakes
/**
* @param annotation -
* @return the covered text
*/
static private String getCoveredText( final IdentifiedAnnotation annotation ) {
return annotation.getCoveredText()
.replace( '\r', ' ' )
.replace( '\n', ' ' );
}
代码示例来源:origin: apache/ctakes
/**
* @param annotation -
* @return the covered text
*/
static private String getCoveredText( final IdentifiedAnnotation annotation ) {
return annotation.getCoveredText().replace( '\r', ' ' ).replace( '\n', ' ' );
}
代码示例来源:origin: apache/ctakes
/**
* Return true if pse belongs to side effects in the side-effect dictionary
*
* @param jcas
* @param pse potential side effect
* @return true if satisfies given conditions, else false
*/
private boolean isInDictionary(JCas jcas, PotentialSideEffect pse) {
String drug = pse.drug.getCoveredText().toLowerCase().trim();
if(keyDrugMap.containsKey(drug)) {
Set<String> seSet = sideEffectMap.get(keyDrugMap.get(drug));
String pseStr = pse.ne.getCoveredText().toLowerCase().trim();
//exact matching
if(seSet.contains(pseStr)) return true;
}
return false;
}
代码示例来源:origin: org.apache.ctakes/ctakes-side-effect
/**
* Return true if pse belongs to side effects in the side-effect dictionary
*
* @param jcas
* @param pse potential side effect
* @return true if satisfies given conditions, else false
*/
private boolean isInDictionary(JCas jcas, PotentialSideEffect pse) {
String drug = pse.drug.getCoveredText().toLowerCase().trim();
if(keyDrugMap.containsKey(drug)) {
Set<String> seSet = sideEffectMap.get(keyDrugMap.get(drug));
String pseStr = pse.ne.getCoveredText().toLowerCase().trim();
//exact matching
if(seSet.contains(pseStr)) return true;
}
return false;
}
代码示例来源:origin: org.apache.ctakes/ctakes-relation-extractor
static String format(IdentifiedAnnotation a) {
return a == null ? null : String.format("\"%s\"(type=%d)", a.getCoveredText(), a.getTypeID());
}
代码示例来源:origin: apache/ctakes
static String format(IdentifiedAnnotation a) {
return a == null ? null : String.format("\"%s\"(type=%d)", a.getCoveredText(), a.getTypeID());
}
代码示例来源:origin: org.apache.ctakes/ctakes-side-effect
/**
* Return true if pse is sideEffectWord and there is no other pse(s) in the pse.sentence
* but if the pse sentence contains certain word, return false
* - this is a naive rule
* - sideEffectWord must not be negated
*
* @param jcas
* @param pse potential side effect
* @param input modified SE sentence used for regular expression match
* @return true if finds a given pattern, else false
*/
private boolean hasSideEffectAsPse(JCas jcas, PotentialSideEffect pse, String input) {
//if the pse sentence contains certain word, return false
if(input.matches(".*(dicussed|concerned).*")) return false;
//if pse!=sideEffectWord, return false
String str = pse.ne.getCoveredText().replace('-', ' ').toLowerCase().trim();
if(!sideEffectWord.contains(str)) return false;
//if there is PSE, return false
if(input.matches(".*(<PSE>).*")) return false;
return true;
}
代码示例来源:origin: org.apache.ctakes/ctakes-core
/**
* I2b2 wants annotation begin and end offsets plus the covered text
* @param jcas in case the blob needs to obtain annotation information from the jcas
* @param annotation -
* @return a blob with encoded text span and covered text of the annotation
*/
protected String createBlob( final JCas jcas, final IdentifiedAnnotation annotation ) {
final StringBuilder sb = new StringBuilder();
sb.append( '<' ).append( SPAN_START_LABEL ).append( '>' );
sb.append( annotation.getBegin() );
sb.append( "</" ).append( SPAN_START_LABEL ).append( '>' );
sb.append( '<' ).append( SPAN_END_LABEL ).append( '>' );
sb.append( annotation.getEnd() );
sb.append( "</" ).append( SPAN_END_LABEL ).append( '>' );
sb.append( annotation.getCoveredText() );
return sb.toString();
}
代码示例来源:origin: apache/ctakes
/**
* I2b2 wants annotation begin and end offsets plus the covered text
* @param jcas in case the blob needs to obtain annotation information from the jcas
* @param annotation -
* @return a blob with encoded text span and covered text of the annotation
*/
protected String createBlob( final JCas jcas, final IdentifiedAnnotation annotation ) {
final StringBuilder sb = new StringBuilder();
sb.append( '<' ).append( SPAN_START_LABEL ).append( '>' );
sb.append( annotation.getBegin() );
sb.append( "</" ).append( SPAN_START_LABEL ).append( '>' );
sb.append( '<' ).append( SPAN_END_LABEL ).append( '>' );
sb.append( annotation.getEnd() );
sb.append( "</" ).append( SPAN_END_LABEL ).append( '>' );
sb.append( annotation.getCoveredText() );
return sb.toString();
}
代码示例来源:origin: apache/ctakes
static private String createBsvLine( final IdentifiedAnnotation annotation,
final UmlsConcept concept,
final String locationCuis ) {
final StringBuilder sb = new StringBuilder();
sb.append( concept.getCode() ).append( '|' )
.append( concept.getPreferredText() ).append( '|' )
.append( SemanticTui.getTuiFromCode( concept.getTui() ).getGroupName() ).append( '|' )
.append( annotation.getPolarity() == CONST.NE_POLARITY_NEGATION_PRESENT ? "true" : "false" ).append( '|' )
.append( annotation.getSubject().equals( CONST.ATTR_SUBJECT_FAMILY_MEMBER ) ? "true" : "false" ).append( '|' )
.append( locationCuis ).append( '|' )
.append( annotation.getCoveredText() );
return sb.toString();
}
代码示例来源:origin: org.apache.ctakes/ctakes-relation-extractor
@Override
public List<IdentifiedAnnotationPair> getCandidateRelationArgumentPairs(
JCas identifiedAnnotationView, Annotation sentence) {
List<IdentifiedAnnotationPair> pairs = super.getCandidateRelationArgumentPairs(identifiedAnnotationView, sentence);
// look for sentences with one entity and one modifier
List<IdentifiedAnnotationPair> result = new ArrayList<IdentifiedAnnotationPair>();
if (pairs.size() == 1) {
IdentifiedAnnotationPair pair = pairs.get(0);
if(Utils.validateDegreeOfArgumentTypes(pair)) {
System.out.println(sentence.getCoveredText());
System.out.println("arg1: " + pair.getArg1().getCoveredText());
System.out.println("arg2: " + pair.getArg2().getCoveredText());
System.out.println();
result.add(pair);
}
}
return result;
}
代码示例来源:origin: org.apache.ctakes/ctakes-coreference
private List<CollectionTextRelationIdentifiedAnnotationPair> getExactStringMatchPairs(
JCas jcas, IdentifiedAnnotation mention, int sentDist) {
List<CollectionTextRelationIdentifiedAnnotationPair> pairs = new ArrayList<>();
if(markableStrings.contains(mention.getCoveredText().toLowerCase())){
for(CollectionTextRelation cluster : JCasUtil.select(jcas, CollectionTextRelation.class)){
Annotation mostRecent = ClusterUtils.getMostRecent((NonEmptyFSList)cluster.getMembers(), mention);
if(mostRecent == null) continue;
for(Markable m : JCasUtil.select(cluster.getMembers(), Markable.class)){
if(m == mostRecent) break;
// see if any of the members of the cluster have the exact same string as this
if(m.getCoveredText().toLowerCase().equals(mention.getCoveredText().toLowerCase())){
pairs.add(new CollectionTextRelationIdentifiedAnnotationPair(cluster, mention));
break;
}
}
}
}
return pairs;
}
代码示例来源:origin: apache/ctakes
@Override
public List<IdentifiedAnnotationPair> getCandidateRelationArgumentPairs(
JCas identifiedAnnotationView, Annotation sentence) {
List<IdentifiedAnnotationPair> pairs = super.getCandidateRelationArgumentPairs(identifiedAnnotationView, sentence);
// look for sentences with one entity and one modifier
List<IdentifiedAnnotationPair> result = new ArrayList<IdentifiedAnnotationPair>();
if (pairs.size() == 1) {
IdentifiedAnnotationPair pair = pairs.get(0);
if(Utils.validateDegreeOfArgumentTypes(pair)) {
System.out.println(sentence.getCoveredText());
System.out.println("arg1: " + pair.getArg1().getCoveredText());
System.out.println("arg2: " + pair.getArg2().getCoveredText());
System.out.println();
result.add(pair);
}
}
return result;
}
代码示例来源:origin: apache/ctakes
private List<CollectionTextRelationIdentifiedAnnotationPair> getExactStringMatchPairs(
JCas jcas, IdentifiedAnnotation mention, int sentDist) {
List<CollectionTextRelationIdentifiedAnnotationPair> pairs = new ArrayList<>();
if(markableStrings.contains(mention.getCoveredText().toLowerCase())){
for(CollectionTextRelation cluster : JCasUtil.select(jcas, CollectionTextRelation.class)){
Annotation mostRecent = ClusterUtils.getMostRecent((NonEmptyFSList)cluster.getMembers(), mention);
if(mostRecent == null) continue;
for(Markable m : JCasUtil.select(cluster.getMembers(), Markable.class)){
if(m == mostRecent) break;
// see if any of the members of the cluster have the exact same string as this
if(m.getCoveredText().toLowerCase().equals(mention.getCoveredText().toLowerCase())){
pairs.add(new CollectionTextRelationIdentifiedAnnotationPair(cluster, mention));
break;
}
}
}
}
return pairs;
}
代码示例来源:origin: org.apache.ctakes/ctakes-assertion
private void printContext(String text, IdentifiedAnnotation mention, int radius) {
int mentionBegin = mention.getBegin();
int mentionEnd = mention.getEnd();
StringBuilder sb = new StringBuilder();
int snipBegin;
int snipEnd;
snipBegin = (mentionBegin-radius<0)? 0 : mentionBegin-radius;
snipEnd = (mentionEnd+radius>text.length()-1)? text.length()-1 : mentionEnd+radius;
String[] tmp = mention.getClass().getName().split("\\.");
String semGroup = tmp[tmp.length-1];
sb.append(text.substring(snipBegin, mentionBegin));
sb.append("[[["+mention.getCoveredText()+"]]]");
sb.append(text.substring(mentionEnd, snipEnd));
// sb.toString().replaceAll("\\n", "\\n| ");
System.out.println("| "+ sb.toString().replaceAll("\\n", "\n| "));
System.out.println(": "+ semGroup +
" : beg=" + mention.getBegin() + " : end=" + mention.getEnd() +
" : c=" + mention.getConditional() + " : g=" + mention.getGeneric() +
" : h=" + mention.getHistoryOf() + " : p=" + mention.getPolarity() +
" : s=" + mention.getSubject() + " : u=" + mention.getUncertainty());
}
代码示例来源:origin: apache/ctakes
private static String formatRelation(BinaryTextRelation relation) {
IdentifiedAnnotation arg1 = (IdentifiedAnnotation) relation.getArg1().getArgument();
IdentifiedAnnotation arg2 = (IdentifiedAnnotation) relation.getArg2().getArgument();
String text = arg1.getCAS().getDocumentText();
int begin = Math.min(arg1.getBegin(), arg2.getBegin());
int end = Math.max(arg1.getBegin(), arg2.getBegin());
begin = Math.max(0, begin - 50);
end = Math.min(text.length(), end + 50);
return String.format(
"%s(%s(type=%d), %s(type=%d)) in ...%s...",
relation.getCategory(),
arg1.getCoveredText(),
arg1.getTypeID(),
arg2.getCoveredText(),
arg2.getTypeID(),
text.substring(begin, end).replaceAll("[\r\n]", " "));
}
代码示例来源:origin: org.apache.ctakes/ctakes-relation-extractor
private static String formatRelation(BinaryTextRelation relation) {
IdentifiedAnnotation arg1 = (IdentifiedAnnotation) relation.getArg1().getArgument();
IdentifiedAnnotation arg2 = (IdentifiedAnnotation) relation.getArg2().getArgument();
String text = arg1.getCAS().getDocumentText();
int begin = Math.min(arg1.getBegin(), arg2.getBegin());
int end = Math.max(arg1.getBegin(), arg2.getBegin());
begin = Math.max(0, begin - 50);
end = Math.min(text.length(), end + 50);
return String.format(
"%s(%s(type=%d), %s(type=%d)) in ...%s...",
relation.getCategory(),
arg1.getCoveredText(),
arg1.getTypeID(),
arg2.getCoveredText(),
arg2.getTypeID(),
text.substring(begin, end).replaceAll("[\r\n]", " "));
}
代码示例来源:origin: org.apache.ctakes/ctakes-core
private Entity( final IdentifiedAnnotation annotation ) {
_begin = annotation.getBegin();
_end = annotation.getEnd();
_coveredText = annotation.getCoveredText();
_polarity = annotation.getPolarity();
_uncertainty = annotation.getUncertainty();
_conditional = annotation.getConditional();
_generic = annotation.getGeneric();
_subject = annotation.getSubject();
_historyOf = annotation.getHistoryOf();
}
代码示例来源:origin: apache/ctakes
private Entity( final IdentifiedAnnotation annotation ) {
_begin = annotation.getBegin();
_end = annotation.getEnd();
_coveredText = annotation.getCoveredText();
_polarity = annotation.getPolarity();
_uncertainty = annotation.getUncertainty();
_conditional = annotation.getConditional();
_generic = annotation.getGeneric();
_subject = annotation.getSubject();
_historyOf = annotation.getHistoryOf();
}
内容来源于网络,如有侵权,请联系作者删除!