rosnode
's.rosjava
is the Java interface to ROS.public class MyAnnotator extends JCasAnnotator_ImplBase { @Override public void process(JCas cas) throws AnalysisEngineProcessException { String docText = cas.getDocumentText(); int location; if ((location = docText.indexOf("purple")) != -1) { Color color = new Color(cas); color.setBegin(location); color.setEnd(location + "purple".length()); color.setColorName("purple"); color.addToIndexes(cas); } } }
{ "my_string_annotation": [ { "begin": 0, "end": 3, "my_string_field": "bar" }, { "begin": 5, "end": 10, "my_string_field": "foo" } ], "my_int_annotation": [ { "my_int_field": 5, "my_other_string_field": "foobar" } ] }
{ "annotator.class_name": { "address": "123.45.67.89", "port": 1234 }, "other_annotator.class_name": { "address": "123.45.67.80", "port": 4321 } }
public class ColorsAnnotator extends HttpAnnotator { }
class Color(Annotation): def __init__(self, color, start, end): self.color = color self.begin = start self.end = end
class ColorAnnotator(Annotator): def initialize(self): super().initialize() self.color_words = ['red', 'blue', 'yellow'] self.annotation_types.append(Color) def process(self, data): sofa_string = data['_referenced_fss']['1']['sofaString'] for word in self.color_words: if word in sofa_string: self.add_annotation(Color(word, -1, -1))
Controller
for
demonstration purposes.python ColorAnnotator.py &
roscore &
rosrun edu_rosehulman_aixprize pipeline \
edu.rosehulman.aixprize.pipeline.core.Controller