/** @generated * @param jcas JCas to which this Feature Structure belongs * @param begin offset to the begin spot in the SofA * @param end offset to the end spot in the SofA */ public Chunk(JCas jcas, int begin, int end) { super(jcas); setBegin(begin); setEnd(end); readObject(); }
@Override public void process( JCas jCas ) throws AnalysisEngineProcessException { for ( Chunk chunk : JCasUtil.select( jCas, Chunk.class ) ) { if ( chunk.getChunkType().equals( "NP" ) ) { new LookupWindowAnnotation( jCas, chunk.getBegin(), chunk.getEnd() ).addToIndexes(); } } } }
/** * Update the end value for the chunk to have the new value * * @param chunk * The chunk to update * @param newEnd * The new end value for the chunk. * @return The updated Chunk * @throws AnnotatorProcessException */ private static Chunk extendChunk(Chunk chunk, int newEnd) throws AnalysisEngineProcessException { if (newEnd < chunk.getBegin()) { Exception e; e = new Exception("New end offset (" + newEnd + ") < begin offset (" + chunk.getBegin() + ")."); throw new AnalysisEngineProcessException(e); } // logger.info("Extending chunk end from " +chunk.getEnd()+ " to " + // newEnd + "."); // logger.info("For chunk " + chunk.getChunkType()); // logger.info(" text = '" + chunk.getCoveredText() + "'."); chunk.setEnd(newEnd); // logger.info(" new text = '" + chunk.getCoveredText() + "'."); return chunk; }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { ArrayList<Annotation> la = AnnotationSelector.selectNE(aJCas); for (int i = 0; i < la.size(); ++i) { Annotation a = la.get(i); NEMarkable m = new NEMarkable(aJCas, a.getBegin(), a.getEnd()); m.setContent(a); m.setId(nextID + i); m.addToIndexes(); } nextID += la.size(); ArrayList<WordToken> lw = AnnotationSelector.selectPronoun(aJCas, modalAdj, cogved, otherVerb, logger); for (int i = 0; i < lw.size(); ++i) { WordToken t = lw.get(i); PronounMarkable m = new PronounMarkable(aJCas, t.getBegin(), t.getEnd()); m.setContent(t); m.setId(nextID + i); m.addToIndexes(); } nextID += lw.size(); ArrayList<Chunk> lc = AnnotationSelector.selectDemonAndRelative(aJCas); for (int i = 0; i < lc.size(); ++i) { Chunk c = lc.get(i); DemMarkable m = new DemMarkable(aJCas, c.getBegin(), c.getEnd()); m.setContent(c); m.setId(nextID + i); m.addToIndexes(); } nextID += lc.size(); }
/** Internal - constructor used by generator * @generated * @param addr low level Feature Structure reference * @param type the type of this Feature Structure */ public Chunk(int addr, TOP_Type type) { super(addr, type); readObject(); }
protected void annotateSentence(JCas jcas, Sentence sent) throws AnalysisEngineProcessException{ List<Chunk> chunkList = new ArrayList<>(JCasUtil.selectCovered(jcas, Chunk.class, sent)); // For each chunk in the Sentence, see if the chunk is the start of a // matching pattern // If so, extend the end offset of the <code>i</code> + // <code>indexOfTokenToInclude</code> for (int i = 0; i < chunkList.size(); i++) { boolean matches = true; Chunk chunk = chunkList.get(i); while (matches == true) { matches = compareToPattern(chunkList, i); if (matches) { extendChunk(chunk, chunkList.get(i + indexOfTokenToInclude) .getEnd()); removeEnvelopedChunks(chunkList, i); // to check again on next // iteration of while loop } } } }
/** * Compares the chunks at index i to the 1st element on the pattern, i+1 to * the 2nd element, etc and returns true if the chunks starting at i fit the * pattern * * @param list * the list of chunks * @param i * the position within the list to compare to the pattern * @return true if the pattern is matched by the chunks starting with * element <code>i</code> in the list. Note if there aren't enough * chunks in the list starting at i to match the pattern, returns * false. * @throws AnnotatorProcessException */ private boolean compareToPattern(List<Chunk> list, int i) { boolean match = true; int len = list.size(); for (int j = 0; j < chunksTypesInPattern.length; j++) { if (i + j >= len || !list.get(i + j).getChunkType() .equals(chunksTypesInPattern[j])) { match = false; // some part of pattern doesn't match chunks // starting at i break; } } return match; }
public static ArrayList<Chunk> selectDemonAndRelative (JCas jcas) { ArrayList<Chunk> ret = new ArrayList<Chunk>(); FSIterator<Annotation> iter = jcas.getJFSIndexRepository().getAnnotationIndex(Chunk.type).iterator(); while (iter.hasNext()) { Chunk c = (Chunk)iter.next(); if (c.getChunkType().equals("NP")) { String s = c.getCoveredText().toLowerCase(); if (s.startsWith("these") || s.startsWith("those") || s.startsWith("this") || s.startsWith("that") || s.startsWith("which")) ret.add(c); } } java.util.Collections.sort(ret, new AnnotOffsetComparator()); return ret; } }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { ArrayList<Annotation> la = AnnotationSelector.selectNE(aJCas); for (int i = 0; i < la.size(); ++i) { Annotation a = la.get(i); NEMarkable m = new NEMarkable(aJCas, a.getBegin(), a.getEnd()); m.setContent(a); m.setId(nextID + i); m.addToIndexes(); } nextID += la.size(); ArrayList<WordToken> lw = AnnotationSelector.selectPronoun(aJCas, modalAdj, cogved, otherVerb, logger); for (int i = 0; i < lw.size(); ++i) { WordToken t = lw.get(i); PronounMarkable m = new PronounMarkable(aJCas, t.getBegin(), t.getEnd()); m.setContent(t); m.setId(nextID + i); m.addToIndexes(); } nextID += lw.size(); ArrayList<Chunk> lc = AnnotationSelector.selectDemonAndRelative(aJCas); for (int i = 0; i < lc.size(); ++i) { Chunk c = lc.get(i); DemMarkable m = new DemMarkable(aJCas, c.getBegin(), c.getEnd()); m.setContent(c); m.setId(nextID + i); m.addToIndexes(); } nextID += lc.size(); }
/** * Update the end value for the chunk to have the new value * * @param chunk * The chunk to update * @param newEnd * The new end value for the chunk. * @return The updated Chunk * @throws AnnotatorProcessException */ private static Chunk extendChunk(Chunk chunk, int newEnd) throws AnalysisEngineProcessException { if (newEnd < chunk.getBegin()) { Exception e; e = new Exception("New end offset (" + newEnd + ") < begin offset (" + chunk.getBegin() + ")."); throw new AnalysisEngineProcessException(e); } // logger.info("Extending chunk end from " +chunk.getEnd()+ " to " + // newEnd + "."); // logger.info("For chunk " + chunk.getChunkType()); // logger.info(" text = '" + chunk.getCoveredText() + "'."); chunk.setEnd(newEnd); // logger.info(" new text = '" + chunk.getCoveredText() + "'."); return chunk; }
/** Internal - constructor used by generator * @generated * @param addr low level Feature Structure reference * @param type the type of this Feature Structure */ public Chunk(int addr, TOP_Type type) { super(addr, type); readObject(); }
protected void annotateSentence(JCas jcas, Sentence sent) throws AnalysisEngineProcessException{ List<Chunk> chunkList = new ArrayList<>(JCasUtil.selectCovered(jcas, Chunk.class, sent)); // For each chunk in the Sentence, see if the chunk is the start of a // matching pattern // If so, extend the end offset of the <code>i</code> + // <code>indexOfTokenToInclude</code> for (int i = 0; i < chunkList.size(); i++) { boolean matches = true; Chunk chunk = chunkList.get(i); while (matches == true) { matches = compareToPattern(chunkList, i); if (matches) { extendChunk(chunk, chunkList.get(i + indexOfTokenToInclude) .getEnd()); removeEnvelopedChunks(chunkList, i); // to check again on next // iteration of while loop } } } }
/** * Compares the chunks at index i to the 1st element on the pattern, i+1 to * the 2nd element, etc and returns true if the chunks starting at i fit the * pattern * * @param list * the list of chunks * @param i * the position within the list to compare to the pattern * @return true if the pattern is matched by the chunks starting with * element <code>i</code> in the list. Note if there aren't enough * chunks in the list starting at i to match the pattern, returns * false. * @throws AnnotatorProcessException */ private boolean compareToPattern(List<Chunk> list, int i) { boolean match = true; int len = list.size(); for (int j = 0; j < chunksTypesInPattern.length; j++) { if (i + j >= len || !list.get(i + j).getChunkType() .equals(chunksTypesInPattern[j])) { match = false; // some part of pattern doesn't match chunks // starting at i break; } } return match; }
public static ArrayList<Chunk> selectDemonAndRelative (JCas jcas) { ArrayList<Chunk> ret = new ArrayList<Chunk>(); FSIterator<Annotation> iter = jcas.getJFSIndexRepository().getAnnotationIndex(Chunk.type).iterator(); while (iter.hasNext()) { Chunk c = (Chunk)iter.next(); if (c.getChunkType().equals("NP")) { String s = c.getCoveredText().toLowerCase(); if (s.startsWith("these") || s.startsWith("those") || s.startsWith("this") || s.startsWith("that") || s.startsWith("which")) ret.add(c); } } java.util.Collections.sort(ret, new AnnotOffsetComparator()); return ret; } }
/** @generated * @param jcas JCas to which this Feature Structure belongs * @param begin offset to the begin spot in the SofA * @param end offset to the end spot in the SofA */ public Chunk(JCas jcas, int begin, int end) { super(jcas); setBegin(begin); setEnd(end); readObject(); }
@Override public void process( JCas jCas ) throws AnalysisEngineProcessException { for ( Chunk chunk : JCasUtil.select( jCas, Chunk.class ) ) { if ( chunk.getChunkType().equals( "NP" ) ) { new LookupWindowAnnotation( jCas, chunk.getBegin(), chunk.getEnd() ).addToIndexes(); } } } }
/** @generated * @param jcas JCas to which this Feature Structure belongs */ public Chunk(JCas jcas) { super(jcas); readObject(); }
/** * A utility method that annotates a given range. */ protected void annotateRange(JCas jcas, int rangeBegin, int rangeEnd) throws AnalysisEngineProcessException { // logger.info("Adjuster: from " + rangeBegin + " to " + rangeEnd); // Find the Chunks in this Sentence // For each Chunk, there is a corresponding more specific such as NP, // PP, etc List<Chunk> chunkList = new ArrayList<>(JCasUtil.selectCovered(jcas, Chunk.class, rangeBegin, rangeEnd)); // For each chunk in the Sentence, see if the chunk is the start of a // matching pattern // If so, extend the end offset of the <code>i</code> + // <code>indexOfTokenToInclude</code> for (int i = 0; i < chunkList.size(); i++) { boolean matches = true; Chunk chunk = chunkList.get(i); while (matches == true) { matches = compareToPattern(chunkList, i); if (matches) { extendChunk(chunk, chunkList.get(i + indexOfTokenToInclude) .getEnd()); removeEnvelopedChunks(chunkList, i); // to check again on next // iteration of while loop } } } }
((Chunk) mc).getChunkType().equals("NP")){ String s = mc.getCoveredText().toLowerCase(); if (s.startsWith("this") ||