def testRequire(self): require("commons-lang:commons-lang:2.6") from org.apache.commons.lang import StringUtils self.assertEquals(StringUtils.removeStart("jip rocks", "jip"), " rocks") self.assertEquals(StringUtils.reverse("jip rocks"), "skcor pij")
#!/usr/bin/env jython # Fix classpath scanning - otherise uimaFIT will not find the UIMA types from java.lang import Thread from org.python.core.imp import * Thread.currentThread().contextClassLoader = getSyspathJavaLoader() # Dependencies and imports for DKPro modules from jip.embed import require require('de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.opennlp-asl:1.6.1') from de.tudarmstadt.ukp.dkpro.core.opennlp import * from de.tudarmstadt.ukp.dkpro.core.api.segmentation.type import * from de.tudarmstadt.ukp.dkpro.core.api.syntax.type import * # uimaFIT imports from org.apache.uima.fit.util.JCasUtil import * from org.apache.uima.fit.pipeline.SimplePipeline import * from org.apache.uima.fit.factory.AnalysisEngineFactory import * from org.apache.uima.fit.factory import JCasFactory # First, define a class which helps us to create an own document reader class MyDocumentReader(object): def internalReadDocument(self): """ Implement here your document reader. This example returns sentences from a defined array with sentences. Returns: A list, first element is the document language, second is the document text """ documents = ['This is a test.', 'To test my first own reader.', 'This function returns each sentence as a new jcas. This jcas is then processed by different engines. The output is written to the console.'] documentLanguage = "en" for documentText in documents: yield documentLanguage, documentText
""" Reads in a specific text file and runs first the OpenNlpSegmenter and then the OpenNlpPosTagger. Run by: jython pos.py <filename> <language-code> """ # Fix classpath scanning - otherise uimaFIT will not find the UIMA types from java.lang import Thread from org.python.core.imp import * Thread.currentThread().contextClassLoader = getSyspathJavaLoader() # Dependencies and imports for DKPro modules from jip.embed import require # Text Reader require( 'de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.io.text-asl:1.6.1' ) from de.tudarmstadt.ukp.dkpro.core.io.text import * # OpenNLP require( 'de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.opennlp-asl:1.6.1' ) from de.tudarmstadt.ukp.dkpro.core.opennlp import * # Dependencies for selecting specific annotations like sentences/tokens from de.tudarmstadt.ukp.dkpro.core.api.segmentation.type import * from de.tudarmstadt.ukp.dkpro.core.api.syntax.type import * # uimaFIT imports from org.apache.uima.fit.util.JCasUtil import *
""" Reads in a specific text file and runs the different existent segmenter for this file. Run by: jython segmentation.py <filename> <language-code> """ # Fix classpath scanning - otherise uimaFIT will not find the UIMA types from java.lang import Thread from org.python.core.imp import * Thread.currentThread().contextClassLoader = getSyspathJavaLoader() # Dependencies and imports for DKPro modules from jip.embed import require # Text Reader require( 'de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.io.text-asl:1.6.1' ) from de.tudarmstadt.ukp.dkpro.core.io.text import * # BreakIteratorSegmenter require( 'de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.tokit-asl:1.6.1' ) from de.tudarmstadt.ukp.dkpro.core.tokit import * # OpenNlp require( 'de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.opennlp-asl:1.6.1' ) from de.tudarmstadt.ukp.dkpro.core.opennlp import *
""" Reads in a specific text file and prints a parse tree following the conventions of Penn TreeBank Run by: jython parsing_constituency.py <filename> <language-code> """ # Fix classpath scanning - otherise uimaFIT will not find the UIMA types from java.lang import Thread from org.python.core.imp import * Thread.currentThread().contextClassLoader = getSyspathJavaLoader() # Dependencies and imports for DKPro modules from jip.embed import require # Text Reader require( 'de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.io.text-asl:1.6.1' ) from de.tudarmstadt.ukp.dkpro.core.io.text import * # OpenNlp require( 'de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.opennlp-asl:1.6.1' ) from de.tudarmstadt.ukp.dkpro.core.opennlp import * # StanfordNlp require( 'de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.stanfordnlp-gpl:1.6.1' ) from de.tudarmstadt.ukp.dkpro.core.stanfordnlp import *
""" Reads in a specific text file Run by: jython text_reader.py <filename> <language-code> """ # Fix classpath scanning - otherise uimaFIT will not find the UIMA types from java.lang import Thread from org.python.core.imp import * Thread.currentThread().contextClassLoader = getSyspathJavaLoader() # Dependencies and imports for DKPro modules from jip.embed import require require("de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.io.text-asl:1.6.1") from de.tudarmstadt.ukp.dkpro.core.io.text import * # uimaFIT imports from org.apache.uima.fit.util.JCasUtil import * from org.apache.uima.fit.pipeline.SimplePipeline import * from org.apache.uima.fit.factory.CollectionReaderFactory import * from org.apache.uima.fit.factory.AnalysisEngineFactory import * # Access to commandline arguments import sys # Check that all necessary arguments have been passed to the program if len(sys.argv) < 3:
""" Reads in a specific text file and runs first the OpenNlpSegmenter and then the SnowballStemmer. Run by: jython stemming.py <filename> <language-code> """ # Fix classpath scanning - otherise uimaFIT will not find the UIMA types from java.lang import Thread from org.python.core.imp import * Thread.currentThread().contextClassLoader = getSyspathJavaLoader() # Dependencies and imports for DKPro modules from jip.embed import require # Text Reader require('de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.io.text-asl:1.6.1') from de.tudarmstadt.ukp.dkpro.core.io.text import * # OpenNlp require('de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.opennlp-asl:1.6.1') from de.tudarmstadt.ukp.dkpro.core.opennlp import * # Snowball require('de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.snowball-asl:1.6.1') from de.tudarmstadt.ukp.dkpro.core.snowball import * # Dependencies for selecting specific annotations like sentences/tokens from de.tudarmstadt.ukp.dkpro.core.api.segmentation.type import * from de.tudarmstadt.ukp.dkpro.core.api.syntax.type import * # uimaFIT imports
from jip.embed import require require('org.piccolo2d:piccolo2d-core:1.3.1') require('org.piccolo2d:piccolo2d-extras:1.3.1') import java.awt.BasicStroke import java.awt.Color from java.awt.event import KeyEvent, InputEvent from edu.umd.cs.piccolo import PCanvas from edu.umd.cs.piccolo.event import PBasicInputEventHandler from edu.umd.cs.piccolo.event import PInputEvent, PInputEventFilter from edu.umd.cs.piccolo.nodes import PPath from edu.umd.cs.piccolox import PFrame class InteractionFrame(PFrame): def initialize(self): # Remove the pan event handler that is installed by default so that it # does not conflict with our new squiggle handler. self.canvas.panEventHandler = None # Create a squiggle handler and register it with the Canvas. squiggleHandler = SquiggleHandler(self.canvas) self.canvas.addInputEventListener(squiggleHandler) # Create a green rectangle node. nodeGreen = PPath.createRectangle(0, 0, 100, 100) nodeGreen.paint = java.awt.Color.GREEN self.canvas.layer.addChild(nodeGreen) # Attach event handler directly to the node.
""" Reads in a specific text file and prints a parse tree following the conventions of Penn TreeBank Run by: jython parsing_constituency.py <filename> <language-code> """ # Fix classpath scanning - otherise uimaFIT will not find the UIMA types from java.lang import Thread from org.python.core.imp import * Thread.currentThread().contextClassLoader = getSyspathJavaLoader() # Dependencies and imports for DKPro modules from jip.embed import require # Text Reader require('de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.io.text-asl:1.6.1') from de.tudarmstadt.ukp.dkpro.core.io.text import * # OpenNlp require('de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.opennlp-asl:1.6.1') from de.tudarmstadt.ukp.dkpro.core.opennlp import * # StanfordNlp require('de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.stanfordnlp-gpl:1.6.1') from de.tudarmstadt.ukp.dkpro.core.stanfordnlp import * # Berkeley require('de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.berkeleyparser-gpl:1.6.1') from de.tudarmstadt.ukp.dkpro.core.berkeleyparser import * # Dependencies for selecting specific annotations like sentences/tokens
#!/usr/bin/env jython """ Reads in a specific text file and runs first the OpenNlpSegmenter and then the TreeTagger for POS-tagging and lemmatisation. Run by: jython pos.py <filename> <language-code> """ # Fix classpath scanning - otherise uimaFIT will not find the UIMA types from java.lang import Thread from org.python.core.imp import * Thread.currentThread().contextClassLoader = getSyspathJavaLoader() # Dependencies and imports for DKPro modules from jip.embed import require require('de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.opennlp-asl:1.6.1') require('de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.treetagger-asl:1.6.1') require('de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.io.text-asl:1.6.1') from de.tudarmstadt.ukp.dkpro.core.opennlp import * from de.tudarmstadt.ukp.dkpro.core.treetagger import * from de.tudarmstadt.ukp.dkpro.core.io.text import * from de.tudarmstadt.ukp.dkpro.core.api.segmentation.type import * # uimaFIT imports from org.apache.uima.fit.util.JCasUtil import * from org.apache.uima.fit.pipeline.SimplePipeline import * from org.apache.uima.fit.factory.CollectionReaderFactory import * from org.apache.uima.fit.factory.AnalysisEngineFactory import * # Access to commandline arguments import sys # Check that all necessary arguments have been passed to the program
from jip.embed import require require('org.simplericity.macify:macify:1.6') from java.lang import Runnable, System from org.simplericity.macify.eawt import DefaultApplication from .core import Nengo class RunWrapper(Runnable): def __init__(self, func, *args, **kwargs): self.func = func self.args = args self.kwargs = kwargs def run(self): self.func(*self.args, **self.kwargs) def start(): System.setProperty("apple.laf.useScreenMenuBar", "true") System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Nengo") application = DefaultApplication() nengo = Nengo() nengo.application = application if __name__ == '__main__': start() """Consider!!
""" Reads in a specific text file and runs the different existent segmenter for this file. Run by: jython segmentation.py <filename> <language-code> """ # Fix classpath scanning - otherise uimaFIT will not find the UIMA types from java.lang import Thread from org.python.core.imp import * Thread.currentThread().contextClassLoader = getSyspathJavaLoader() # Dependencies and imports for DKPro modules from jip.embed import require # Text Reader require('de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.io.text-asl:1.6.1') from de.tudarmstadt.ukp.dkpro.core.io.text import * # BreakIteratorSegmenter require('de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.tokit-asl:1.6.1') from de.tudarmstadt.ukp.dkpro.core.tokit import * # OpenNlp require('de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.opennlp-asl:1.6.1') from de.tudarmstadt.ukp.dkpro.core.opennlp import * # ClearNlp require('de.tudarmstadt.ukp.dkpro.core:de.tudarmstadt.ukp.dkpro.core.clearnlp-asl:1.6.1') from de.tudarmstadt.ukp.dkpro.core.clearnlp import * # StanfordNlp