public static int getLastSentenceAddress(JCas aJcas) { int lastSentenceAddress = -1; for (Sentence selectedSentence : select(aJcas, Sentence.class)) { lastSentenceAddress = selectedSentence.getAddress(); } return lastSentenceAddress; } /**
/** * Get the ordinal sentence number in the display window. This will be sent to brat so that it * will adjust the sentence number to display accordingly * */ public static int getFirstSentenceNumber(JCas aJcas, int aSentenceAddress) { int sentenceNumber = 0; for (Sentence sentence : select(aJcas, Sentence.class)) { if (sentence.getAddress() == aSentenceAddress) { break; } sentenceNumber++; } return sentenceNumber; }
/** * Get the internal address of the first sentence annotation from JCAS. This will be used as a * reference for moving forward/backward sentences positions * * @param aJcas * The CAS object assumed to contains some sentence annotations * @return the sentence number or -1 if aJcas don't have sentence annotation */ public static int getFirstSentenceAddress(JCas aJcas) { int firstSentenceAddress = -1; for (Sentence selectedSentence : select(aJcas, Sentence.class)) { firstSentenceAddress = selectedSentence.getAddress(); break; } return firstSentenceAddress; }
/** * Get Sentence address for this ordinal sentence number. Used to go to specific sentence number */ public static int getSentenceAddress(JCas aJcas, int aSentenceNumber) { int i = 1; int address = 0; if (aSentenceNumber <1){ return 0; } for (Sentence sentence : select(aJcas, Sentence.class)) { if (i == aSentenceNumber) { address = sentence.getAddress(); break; } address = sentence.getAddress(); i++; } if (aSentenceNumber > i) { return 0; } return address; }
/** * Returns the beginning address of all pages. This is used properly display<b> Page X of Y </b> */ public static List<Integer> getDisplayWindowBeginningSentenceAddresses(JCas aJcas, int aWindowSize) { List<Integer> beginningAddresses = new ArrayList<Integer>(); int j = 0; for (Sentence sentence : select(aJcas, Sentence.class)) { if (j % aWindowSize == 0) { beginningAddresses.add(sentence.getAddress()); } j++; } return beginningAddresses; }
private void setTokenSentenceAddress(JCas aJCas, Map<Integer, Integer> aTokenListInSentence) { for (Sentence sentence : select(aJCas, Sentence.class)) { for (Token token : selectCovered(Token.class, sentence)) { aTokenListInSentence.put(token.getAddress(), sentence.getAddress()); } } }
private void setTokenSentenceAddress(JCas aJCas, Map<Integer, Integer> aTokenListInSentence) { for (Sentence sentence : select(aJCas, Sentence.class)) { for (Token token : selectCovered(Token.class, sentence)) { aTokenListInSentence.put(token.getAddress(), sentence.getAddress()); } } }
/** * Get the sentence address of the next sentence * * @param aJcas * The CAS object * @param aRef * The address of the current sentence * @return address of the next sentence */ public static int getFollowingSentenceAddress(JCas aJcas, int aRef) { Sentence sentence = selectByAddr(aJcas, Sentence.class, aRef); List<Sentence> followingSentence = selectFollowing(aJcas, Sentence.class, sentence, 1); if (followingSentence.size() > 0) { return followingSentence.get(0).getAddress(); } else { return aRef; } }
i = precedingSentences.get(0).getAddress(); return precedingSentences.get(0).getAddress(); return precedingSentences.get(0).getAddress(); return sentence.getAddress();
/** * Get the sentence address for jCas from userJCas. */ private static int getSentenceAddress(BratAnnotatorModel aBratAnnotatorModel, JCas jCas, JCas userJCas) { int sentenceAddress = BratAjaxCasUtil.selectSentenceAt(userJCas, aBratAnnotatorModel.getSentenceBeginOffset(), aBratAnnotatorModel.getSentenceEndOffset()).getAddress(); Sentence sentence = selectByAddr(userJCas, Sentence.class, sentenceAddress); List<Sentence> sentences = JCasUtil.selectCovered(jCas, Sentence.class, sentence.getBegin(), sentence.getEnd()); return sentences.get(0).getAddress(); }
private static int getLastSentenceAddress(BratAnnotatorModel aBratAnnotatorModel, JCas jCas, JCas userJCas) { Sentence sentence = selectByAddr(userJCas, Sentence.class, aBratAnnotatorModel.getLastSentenceAddress()); List<Sentence> sentences = JCasUtil.selectCovered(jCas, Sentence.class, sentence.getBegin(), sentence.getEnd()); return sentences.get(0).getAddress(); }
Sentence.class, BratAjaxCasUtil.getLastSentenceAddressInDisplayWindow(jCas, firstSentence.getAddress(), windowSize)); sentenceNumber = BratAjaxCasUtil.getFirstSentenceNumber(jCas, firstSentence.getAddress()); segmentAdress.put(username, new HashMap<Integer, Integer>()); segmentText.put(sentence.getBegin(), sentence.getCoveredText().toString()); segmentNumber.put(sentence.getBegin(), sentenceNumber); segmentAdress.get(username).put(sentence.getBegin(), sentence.getAddress());
for (Sentence sentence : selectCovered(mergeJCas, Sentence.class, begin, end)) { segmentAdress.get(CurationPanel.CURATION_USER).put(sentence.getBegin(), sentence.getAddress());
private void updateSentenceAddressAndOffsets(JCas jCas, int start) { int address = BratAjaxCasUtil.selectSentenceAt(jCas, bratAnnotatorModel.getSentenceBeginOffset(), bratAnnotatorModel.getSentenceEndOffset()).getAddress(); bratAnnotatorModel.setSentenceAddress(BratAjaxCasUtil.getSentenceBeginAddress(jCas, address, start, bratAnnotatorModel.getProject(), bratAnnotatorModel.getDocument(), bratAnnotatorModel.getWindowSize())); Sentence sentence = selectByAddr(jCas, Sentence.class, bratAnnotatorModel.getSentenceAddress()); bratAnnotatorModel.setSentenceBeginOffset(sentence.getBegin()); bratAnnotatorModel.setSentenceEndOffset(sentence.getEnd()); }
private void updateSentenceAddressAndOffsets(JCas jCas, int start) { int address = BratAjaxCasUtil.selectSentenceAt(jCas, bratAnnotatorModel.getSentenceBeginOffset(), bratAnnotatorModel.getSentenceEndOffset()).getAddress(); bratAnnotatorModel.setSentenceAddress(BratAjaxCasUtil.getSentenceBeginAddress(jCas, address, start, bratAnnotatorModel.getProject(), bratAnnotatorModel.getDocument(), bratAnnotatorModel.getWindowSize())); Sentence sentence = selectByAddr(jCas, Sentence.class, bratAnnotatorModel.getSentenceAddress()); bratAnnotatorModel.setSentenceBeginOffset(sentence.getBegin()); bratAnnotatorModel.setSentenceEndOffset(sentence.getEnd()); }
firstSentence.getAddress(), aBratAnnotatorModel.getWindowSize()); firstSentence.getAddress()); aResponse.setSentenceNumberOffset(sentenceNumber);
aJCas, Sentence.class, BratAjaxCasUtil.getLastSentenceAddressInDisplayWindow(aJCas, sentence.getAddress(), aBratAnnotatorModel.getWindowSize())).getEnd(); if (crossMultipleSentence
firstSentence.getAddress(), aBratAnnotatorModel.getWindowSize());
firstSentence.getAddress(), aBratAnnotatorModel.getWindowSize());
int address = BratAjaxCasUtil.selectSentenceAt(clickedJCas, aBratAnnotatorModel.getSentenceBeginOffset(), aBratAnnotatorModel.getSentenceEndOffset()).getAddress(); aBratAnnotatorModel.setSentenceAddress(BratAjaxCasUtil .getSentenceBeginAddress(clickedJCas, address,