本文整理汇总了Java中gate.util.InvalidOffsetException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java InvalidOffsetException.printStackTrace方法的具体用法?Java InvalidOffsetException.printStackTrace怎么用?Java InvalidOffsetException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gate.util.InvalidOffsetException
的用法示例。
在下文中一共展示了InvalidOffsetException.printStackTrace方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertUpdate
import gate.util.InvalidOffsetException; //导入方法依赖的package包/类
@Override
public void insertUpdate(final javax.swing.event.DocumentEvent e) {
// propagate the edit to the document
try {
// deactivate our own listener so we don't get cycles
document.removeDocumentListener(gateDocListener);
document.edit(
new Long(e.getOffset()),
new Long(e.getOffset()),
new DocumentContentImpl(e.getDocument().getText(e.getOffset(),
e.getLength())));
} catch(BadLocationException ble) {
ble.printStackTrace(Err.getPrintWriter());
} catch(InvalidOffsetException ioe) {
ioe.printStackTrace(Err.getPrintWriter());
} finally {
// reactivate our listener
document.addDocumentListener(gateDocListener);
}
// //update the offsets in the list
// Component listView = annotationListView.getGUI();
// if(listView != null) listView.repaint();
}
示例2: removeUpdate
import gate.util.InvalidOffsetException; //导入方法依赖的package包/类
@Override
public void removeUpdate(final javax.swing.event.DocumentEvent e) {
// propagate the edit to the document
try {
// deactivate our own listener so we don't get cycles
// gateDocListener.setActive(false);
document.removeDocumentListener(gateDocListener);
document.edit(new Long(e.getOffset()),
new Long(e.getOffset() + e.getLength()),
new DocumentContentImpl(""));
} catch(InvalidOffsetException ioe) {
ioe.printStackTrace(Err.getPrintWriter());
} finally {
// reactivate our listener
// gateDocListener.setActive(true);
document.addDocumentListener(gateDocListener);
}
// //update the offsets in the list
// Component listView = annotationListView.getGUI();
// if(listView != null) listView.repaint();
}
示例3: doit
import gate.util.InvalidOffsetException; //导入方法依赖的package包/类
public void doit(
gate.Document doc,
Map<String, AnnotationSet> bindings,
gate.AnnotationSet annotations,
gate.AnnotationSet inputAS,
gate.AnnotationSet outputAS,
gate.creole.ontology.Ontology ontology) throws JapeException {
// your RHS Java code will be embedded here ...
Annotation lookup = tagAnnots.iterator().next();
Long end = tagAnnots.lastNode().getOffset();
Long start = tagAnnots.firstNode().getOffset();
AnnotationSet tokens = annotations.get("Token", start, end);
boolean noPunc=true; // check if a , or . is in the middle of the two lookup. power, consumption of water....
for(Annotation t:tokens){
if(t.getFeatures().get("kind").equals("punctuation")){
noPunc=false;
break;
}
}
System.out.println(noPunc);
if (noPunc) {
FeatureMap features = Factory.newFeatureMap();
features.put("class", lookup.getFeatures().get("URI"));
try {
outputAS.add(start, end, "FeatureSection", features);
} catch (InvalidOffsetException e) {
e.printStackTrace();
}
} else {
//ignore
}
}
示例4: updateStackView
import gate.util.InvalidOffsetException; //导入方法依赖的package包/类
public void updateStackView() {
if (textView == null) { return; }
int caretPosition = textView.getTextView().getCaretPosition();
// get the context around the annotation
int context = 40;
String text = "";
try {
text = document.getContent().getContent(
Math.max(0l, caretPosition - context),
Math.min(document.getContent().size(),
caretPosition + 1 + context)).toString();
} catch (InvalidOffsetException e) {
e.printStackTrace();
}
// initialise the annotation stack
stackPanel.setText(text);
stackPanel.setExpressionStartOffset(caretPosition);
stackPanel.setExpressionEndOffset(caretPosition + 1);
stackPanel.setContextBeforeSize(Math.min(caretPosition, context));
stackPanel.setContextAfterSize(Math.min(
document.getContent().size().intValue()-1-caretPosition, context));
stackPanel.setAnnotationMouseListener(annotationMouseListener);
stackPanel.setHeaderMouseListener(headerMouseListener);
stackPanel.clearAllRows();
// add stack rows and annotations for each selected annotation set
// in the annotation sets view
for(SetHandler setHandler : annotationSetsView.setHandlers) {
for(TypeHandler typeHandler: setHandler.typeHandlers) {
if (typeHandler.isSelected()) {
stackPanel.addRow(setHandler.set.getName(), typeHandler.name,
typesFeatures.get(typeHandler.name),
null, null, AnnotationStack.CROP_MIDDLE);
Set<Annotation> annotations = setHandler.set.get(typeHandler.name)
.get(Math.max(0l, caretPosition - context), Math.min(
document.getContent().size(), caretPosition + 1 + context));
for (Annotation annotation : annotations) {
stackPanel.addAnnotation(annotation);
}
}
}
}
stackPanel.drawStack();
}
示例5: annotatePhraseStructureConstituent
import gate.util.InvalidOffsetException; //导入方法依赖的package包/类
/**
* Record one constituent as an annotation.
*
* @param startOffset
* @param endOffset
* @param label
* @param consists
* @param depth
* @return
*/
private Annotation annotatePhraseStructureConstituent(
AnnotationSet annotationSet, Long startOffset, Long endOffset,
String label, List<Integer> consists, int depth) {
Annotation phrAnnotation = null;
Integer phrID;
try {
String cat;
if(useMapping && mappingLoaded) {
cat = translateTag(label);
} else {
cat = label;
}
if(addConstituentAnnotations) {
String text =
document.getContent().getContent(startOffset, endOffset).toString();
FeatureMap fm = gate.Factory.newFeatureMap();
fm.put(PHRASE_CAT_FEATURE, cat);
fm.put("text", text);
/* Ignore empty list features on the token-equivalent annotations. */
if(consists.size() > 0) {
fm.put("consists", consists);
}
phrID =
annotationSet.add(startOffset, endOffset, PHRASE_ANNOTATION_TYPE,
fm);
phrAnnotation = annotationSet.get(phrID);
recordID(annotationSet, phrID);
}
if(addPosTags && (depth == 1)) {
/* Expected to be a singleton set! */
AnnotationSet tokenSet =
annotationSet.get(inputTokenType, startOffset, endOffset);
if(tokenSet.size() == 1) {
Annotation token = tokenSet.iterator().next();
/*
* Add POS tag to token. (Note: GATE/Hepple uses "(" and ")" for
* Penn/Stanford's "-LRB-" and "-RRB-".
*/
String hepCat = StanfordSentence.unescapePosTag(cat);
token.getFeatures().put(POS_TAG_FEATURE, hepCat);
} else {
System.err.println("Found a tokenSet with " + tokenSet.size()
+ " members!");
}
}
} catch(InvalidOffsetException e) {
e.printStackTrace();
}
return phrAnnotation;
}
示例6: annotateDependencies
import gate.util.InvalidOffsetException; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void annotateDependencies(AnnotationSet annotationSet,
StanfordSentence stanfordSentence, Tree tree) {
GrammaticalStructure gs = gsf.newGrammaticalStructure(tree);
Collection<TypedDependency> dependencies =
DependencyMode.getDependencies(gs, dependencyMode,
includeExtraDependencies);
if(dependencies == null) {
if(debugMode) {
System.out.println("dependencies == null");
}
return;
}
String dependencyKind;
FeatureMap depFeatures;
Integer dependentTokenID, governorTokenID;
List<Integer> argList;
Long offsetLH0, offsetRH0, offsetLH1, offsetRH1, depLH, depRH;
Annotation governor, dependent;
for(TypedDependency dependency : dependencies) {
if(debugMode) {
System.out.println(dependency);
}
// Does not work in version 3.5.2 any more
// int governorIndex = dependency.gov().label().index() - 1;
int governorIndex = dependency.gov().index() - 1;
governor = stanfordSentence.startPos2token(governorIndex);
// int dependentIndex = dependency.dep().label().index() - 1;
int dependentIndex = dependency.dep().index() - 1;
dependent = stanfordSentence.startPos2token(dependentIndex);
dependencyKind = dependency.reln().toString();
governorTokenID = governor.getId();
dependentTokenID = dependent.getId();
if(addDependencyFeatures) {
List<DependencyRelation> depsForTok =
(List<DependencyRelation>)governor.getFeatures().get(
dependenciesFeature);
if(depsForTok == null) {
depsForTok = new ArrayList<DependencyRelation>();
governor.getFeatures().put(dependenciesFeature, depsForTok);
}
depsForTok
.add(new DependencyRelation(dependencyKind, dependentTokenID));
}
if(addDependencyAnnotations) {
depFeatures = gate.Factory.newFeatureMap();
argList = new ArrayList<Integer>();
argList.add(governorTokenID);
argList.add(dependentTokenID);
depFeatures.put(DEPENDENCY_ARG_FEATURE, argList);
depFeatures.put(DEPENDENCY_LABEL_FEATURE, dependencyKind);
offsetLH0 = governor.getStartNode().getOffset();
offsetRH0 = governor.getEndNode().getOffset();
offsetLH1 = dependent.getStartNode().getOffset();
offsetRH1 = dependent.getEndNode().getOffset();
depLH = Math.min(offsetLH0, offsetLH1);
depRH = Math.max(offsetRH0, offsetRH1);
try {
annotationSet.add(depLH, depRH, DEPENDENCY_ANNOTATION_TYPE,
depFeatures);
} catch(InvalidOffsetException e) {
e.printStackTrace();
}
}
}
}
示例7: annotatePhraseStructureConstituent
import gate.util.InvalidOffsetException; //导入方法依赖的package包/类
/**
* Record one constituent as an annotation.
*
* @param startOffset
* @param endOffset
* @param label
* @param consists
* @param depth
* @return
*/
private Annotation annotatePhraseStructureConstituent(AnnotationSet annotationSet, Long startOffset, Long endOffset, String label,
List<Integer> consists, int depth) {
Annotation phrAnnotation = null;
Integer phrID;
try {
String cat;
if (useMapping && mappingLoaded) {
cat = translateTag(label);
}
else {
cat = label;
}
if (addConstituentAnnotations) {
String text = document.getContent().getContent(startOffset, endOffset).toString();
FeatureMap fm = gate.Factory.newFeatureMap();
fm.put(PHRASE_CAT_FEATURE, cat);
fm.put("text", text);
/* Ignore empty list features on the token-equivalent annotations. */
if (consists.size() > 0) {
fm.put("consists", consists);
}
phrID = annotationSet.add(startOffset, endOffset, PHRASE_ANNOTATION_TYPE, fm);
phrAnnotation = annotationSet.get(phrID);
recordID(annotationSet, phrID);
}
if ( addPosTags && (depth == 1) ) {
/* Expected to be a singleton set! */
AnnotationSet tokenSet = annotationSet.get(inputTokenType, startOffset, endOffset);
if (tokenSet.size() == 1) {
Annotation token = tokenSet.iterator().next();
/* Add POS tag to token.
* (Note: GATE/Hepple uses "(" and ")" for Penn/Stanford's
* "-LRB-" and "-RRB-". */
String hepCat = StanfordSentence.unescapePosTag(cat);
token.getFeatures().put(POS_TAG_FEATURE, hepCat);
}
else {
System.err.println("Found a tokenSet with " + tokenSet.size() + " members!");
}
}
}
catch (InvalidOffsetException e) {
e.printStackTrace();
}
return phrAnnotation;
}
示例8: annotateDependencies
import gate.util.InvalidOffsetException; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void annotateDependencies(AnnotationSet annotationSet, StanfordSentence stanfordSentence, Tree tree) {
GrammaticalStructure gs = gsf.newGrammaticalStructure(tree);
Collection<TypedDependency> dependencies = DependencyMode.getDependencies(gs, dependencyMode, includeExtraDependencies);
if (dependencies == null) {
if (debugMode) {
System.out.println("dependencies == null");
}
return;
}
String dependencyKind;
FeatureMap depFeatures;
Integer dependentTokenID, governorTokenID;
List<Integer> argList;
Long offsetLH0, offsetRH0, offsetLH1, offsetRH1, depLH, depRH;
Annotation governor, dependent;
for(TypedDependency dependency : dependencies) {
if(debugMode) {
System.out.println(dependency);
}
int governorIndex = dependency.gov().label().index() - 1;
governor = stanfordSentence.startPos2token(governorIndex);
int dependentIndex = dependency.dep().label().index() - 1;
dependent = stanfordSentence.startPos2token(dependentIndex);
dependencyKind = dependency.reln().toString();
governorTokenID = governor.getId();
dependentTokenID = dependent.getId();
if (addDependencyFeatures) {
List<DependencyRelation> depsForTok =
(List<DependencyRelation>) governor.getFeatures().get(dependenciesFeature);
if(depsForTok == null) {
depsForTok = new ArrayList<DependencyRelation>();
governor.getFeatures().put(dependenciesFeature, depsForTok);
}
depsForTok.add(new DependencyRelation(dependencyKind, dependentTokenID));
}
if (addDependencyAnnotations) {
depFeatures = gate.Factory.newFeatureMap();
argList = new ArrayList<Integer>();
argList.add(governorTokenID);
argList.add(dependentTokenID);
depFeatures.put(DEPENDENCY_ARG_FEATURE, argList);
depFeatures.put(DEPENDENCY_LABEL_FEATURE, dependencyKind);
offsetLH0 = governor.getStartNode().getOffset();
offsetRH0 = governor.getEndNode().getOffset();
offsetLH1 = dependent.getStartNode().getOffset();
offsetRH1 = dependent.getEndNode().getOffset();
depLH = Math.min(offsetLH0, offsetLH1);
depRH = Math.max(offsetRH0, offsetRH1);
try {
annotationSet.add(depLH, depRH, DEPENDENCY_ANNOTATION_TYPE, depFeatures);
}
catch(InvalidOffsetException e) {
e.printStackTrace();
}
}
}
}
示例9: createSyntacticAnnotations
import gate.util.InvalidOffsetException; //导入方法依赖的package包/类
public void createSyntacticAnnotations(ArrayList synOut)
{
AnnotationSet theAnnotationSet=document.getAnnotations();
AnnotationSet theTokens=theAnnotationSet.get("Token");
ArrayList tokens=new ArrayList(theTokens);
Collections.sort(tokens,new OffsetComparator());
ArrayList synOut1;
synOut1=new ArrayList(synOut);
while(synOut.size()>0)
{
// System.out.println("creating the annotations");
SynTreeBack(synOut,theAnnotationSet,new Integer(0));
}
/* for tokens without STreeNode we should create one */
Annotation auxToken;
Long tokenStart,tokenEnd;
AnnotationSet auxSynSet;
FeatureMap auxfm;
String tokenCat;
for(int i=0;i<tokens.size();i++)
{
auxToken=(Annotation) tokens.get(i);
auxfm=auxToken.getFeatures();
tokenCat=auxfm.get("category").toString();
FeatureMap fm_token=Factory.newFeatureMap();
fm_token.put("father",new ArrayList());
fm_token.put("consists",new ArrayList());
fm_token.put("cat",tokenCat);
tokenStart=auxToken.getStartNode().getOffset();
tokenEnd =auxToken.getEndNode().getOffset();
auxSynSet=theAnnotationSet.get("SyntaxTreeNode",tokenStart,tokenEnd);
if(auxSynSet==null || auxSynSet.isEmpty())
{
// System.out.println("Token in " + tokenStart + " - " + tokenEnd + " without SyntaxTreeNode...");
try
{
theAnnotationSet.add(tokenStart,tokenEnd,"SyntaxTreeNode",fm_token);
}
catch(InvalidOffsetException ioe)
{
ioe.printStackTrace();
}
}
}
}