scriptators/python/ae.py [37:77]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def typeSystemInit(ts):
  global source
  global debug
  global ac
  if debug > 10:
    print(source + ": Type sytem init called")
  global keywordtype
  keywordtype =ts.getType('com.ibm.uima.examples.keyword')
  if not keywordtype.isValid():
    error = source + ": com.ibm.uima.examples.keyword is NOT found in type system!"
    ac.logError(error)
    raise Exception(error)

#
# the process method is passed two parameters, the CAS and
# the ResultsSpecification
def process(tcas, rs):
  global keywordtype
  global source
  global debug
  global ac
  if debug > 10:
    print(source + ": This is a process function")
    ac.logMessage("process called")
  text = tcas.getDocumentText()
  index = tcas.getIndexRepository()
  iterator = pattern.finditer(text)
  annotCount = 0
  for match in iterator:
    fs = tcas.createAnnotation(keywordtype, match.start(), match.end())
    index.addFS(fs)
    annotCount += 1
  if debug > 0:
    print(source + ": created " + str(annotCount) + " annotations")
  if debug > 20:
    annots = 0
    iterator = tcas.getAnnotationIndex(keywordtype).iterator()
    while iterator.isValid():
      annots += 1
      iterator.moveToNext()
    print(source + ": found " + str(annots) + " annotations")
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



scriptators/python/sample.py [36:76]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def typeSystemInit(ts):
  global source
  global debug
  global ac
  if debug > 10:
    print(source + ": Type sytem init called")
  global keywordtype
  keywordtype =ts.getType('com.ibm.uima.examples.keyword')
  if not keywordtype.isValid():
    error = source + ": com.ibm.uima.examples.keyword is NOT found in type system!"
    ac.logError(error)
    raise Exception(error)

#
# the process method is passed two parameters, the CAS and
# the ResultsSpecification
def process(tcas, rs):
  global keywordtype
  global source
  global debug
  global ac
  if debug > 10:
    print(source + ": This is a process function")
    ac.logMessage("process called")
  text = tcas.getDocumentText()
  index = tcas.getIndexRepository()
  iterator = pattern.finditer(text)
  annotCount = 0
  for match in iterator:
    fs = tcas.createAnnotation(keywordtype, match.start(), match.end())
    index.addFS(fs)
    annotCount += 1
  if debug > 0:
    print(source + ": created " + str(annotCount) + " annotations")
  if debug > 20:
    annots = 0
    iterator = tcas.getAnnotationIndex(keywordtype).iterator()
    while iterator.isValid():
      annots += 1
      iterator.moveToNext()
    print(source + ": found " + str(annots) + " annotations")
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



