I am using a channel adaptor and qmux to send iso8583 message to a socket server.
I write 2 maven project Jpos client & server in netbeans.
The server accepts the connection but doesnt receive the message (or the client doesnt send message) but when I cancel process of the client project, the server receives
Plz correct me if i wrong.
Following are my configuration files (Refered to http://jpos.org/doc/proguide-draft.pdf)
10_channel.xml
<?xml version="1.0" encoding="UTF-8"?>
<channel-adaptor name='test-channel'
class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2">
<channel class="org.jpos.iso.channel.ASCIIChannel" logger="Q2" realm="test-channel"
packager="org.jpos.iso.packager.GenericPackager">
<property name="packager-config" value="src/main/resources/iso8583.xml" />
<property name="host" value="127.0.0.1" />
<property name="port" value="9090" />
<property name="connection-timeout" value="15000" />
<property name="timeout" value="3000000" />
<property name="keep-alive" value="true" />
</channel>
<!-- <ignore-iso-exceptions>yes</ignore-iso-exceptions>-->
<in>client-send</in>
<out>client-receive</out>
<reconnect-delay>10000</reconnect-delay>
</channel-adaptor>
20_mux.xml
<?xml version="1.0" encoding="UTF-8"?>
<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="test-mux">
<in>client-receive</in>
<out>client-send</out>
<ready>test-channel.ready</ready>
<unhandled>myunhandledqueue</unhandled>
<key>2 7</key>
</mux>
JPos Client code
Q2 q2 = new Q2("src/main/deploy/");
q2.start();
QMUX mux = (QMUX)NameRegistrar.getIfExists("mux.test-mux");
if (mux != null && mux.isConnected()) {
ISOMsg request = new IsoMessage().build(); //dump iso message
ISOMsg response = mux.request(request, REQUEST_TIMEOUT);
if (response != null) {
ISOMsg receivedIsoMsg = new ISOMsg();
receivedIsoMsg.setPackager(new GenericPackager("path_to_file_xml"));
receivedIsoMsg.unpack(response.getBytes());
receivedIsoMsg.dump(System.out, "");
}
}
Socket Server Code
ServerSocket serverSocket;
try {
System.out.println("Binding to port " + SERVER_PORT + ", please wait ...");
serverSocket = new ServerSocket(SERVER_PORT);
System.out.println("Server started: " + serverSocket);
System.out.println("Waiting for a client ...");
while (true) {
try {
Socket socket = serverSocket.accept();
DataInputStream dis = new DataInputStream(socket.getInputStream());
String message = (String) dis.readLine();
System.out.println("Message Received: " + message);
ISOMsg receivedIsoMsg = new ISOMsg();
receivedIsoMsg.setPackager(new GenericPackager("path_to_file_xml"));
receivedIsoMsg.unpack(message.getBytes());
receivedIsoMsg.setMTI("0110");
receivedIsoMsg.set(39,"00");
receivedIsoMsg.dump(System.out, "");
DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
//write object to Socket
dos.writeUTF(new String(receivedIsoMsg.pack()));
} catch (IOException | ISOException ex) {
System.err.println(ex);
}
}
} catch (IOException e1) {
try {
serverSocket.close();
} catch (IOException ex) {
System.err.println(ex);
}
}
Trace log
Client:
--- exec-maven-plugin:1.2.1:exec (default-cli) # JposTest ---
<log realm="Q2.system" at="2020-07-30T10:45:25.638">
<info>
Q2 started, deployDir=/Users/lap/NetBeansProjects/JposTest/src/main/deploy, environment=default
</info>
</log>
<log realm="Q2.system" at="2020-07-30T10:45:26.160" lifespan="507ms">
<version>
jPOS 2.1.3 master/95b8dce (2019-06-16 15:16:57 ART)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
jPOS Community Edition, licensed under GNU AGPL v3.0.
This software is probably not suitable for commercial use.
Please see http://jpos.org/license for details.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)
iQEcBAEBAgAGBQJMolHDAAoJEOQyeO71nYtFv74H/3OgehDGEy1VXp2U3/GcAobg
HH2eZjPUz53r38ARPiU3pzm9LwDa3WZgJJaa/b9VrJwKvbPwe9+0kY3gScDE1skT
ladHt+KHHmGQArEutkzHlpZa73RbroFEIa1qmN6MaDEHGoxZqDh0Sv2cpvOaVYGO
St8ZaddLBPC17bSjAPWo9sWbvL7FgPFOHhnPmbeux8SLtnfWxXWsgo5hLBanKmO1
1z+I/w/6DL6ZYZU6bAJUk+eyVVImJqw0x3IEElI07Nh9MC6BA4iJ77ejobj8HI2r
q9ulRPEqH9NR79619lNKVUkE206dVlXo7xHmJS1QZy5v/GT66xBxyDVfTduPFXk=
=oP+v
-----END PGP SIGNATURE-----
</version>
</log>
<log realm="Q2.system" at="2020-07-30T10:45:26.168" lifespan="5ms">
<info>
deploy: /Users/lap/NetBeansProjects/JposTest/src/main/deploy/10_zp_channel.xml
</info>
</log>
<log realm="Q2.system" at="2020-07-30T10:45:26.199" lifespan="30ms">
<info>
deploy: /Users/lap/NetBeansProjects/JposTest/src/main/deploy/20_zp_qmux.xml
</info>
</log>
<log realm="Q2.system" at="2020-07-30T10:45:26.207" lifespan="8ms">
<info>
deploy: /Users/lap/NetBeansProjects/JposTest/src/main/deploy/99_sysmon.xml
</info>
</log>
<log realm="org.jpos.q2.qbean.SystemMonitor" at="2020-07-30T10:45:26.225">
<info>
Starting SystemMonitor
</info>
</log>
<log realm="org.jpos.q2.qbean.SystemMonitor" at="2020-07-30T10:45:26.225">
<info>
......
thread count: 10
peak threads: 10
user threads: 7
Thread[Reference Handler,10,system]
Thread[Finalizer,8,system]
Thread[Signal Dispatcher,9,system]
Thread[main,5,main]
Thread[pool-1-thread-1,5,main]
Thread[Q2-dd666708-34a1-46dc-9a10-4df253d9249a,5,main]
Thread[Thread-1,5,main]
Thread[channel-sender-client-send,5,main]
Thread[channel-receiver-client-receive,5,main]
Thread[SystemMonitor,5,main]
name-registrar:
tspace:default: org.jpos.space.TSpace
key-count: 0
gcinfo: 0,0
Q2: org.jpos.q2.Q2
test-channel: org.jpos.q2.iso.ChannelAdaptor
tx=0, rx=0, connects=0, last=0
logger.Q2: org.jpos.util.Logger
channel.test-channel: org.jpos.iso.channel.ASCIIChannel
mux.test-mux: org.jpos.q2.iso.QMUX
tx=0, rx=0, tx_expired=0, tx_pending=0, rx_expired=0, rx_pending=0, rx_unhandled=0, rx_forwarded=0, connected=false, last=0
logger.: org.jpos.util.Logger
</info>
</log>
<log realm="test-channel/127.0.0.1:9090" at="2020-07-30T10:45:36.309" lifespan="10084ms">
<connect>
Try 0 127.0.0.1:9090
</connect>
</log>
<log realm="test-channel/127.0.0.1:9090" at="2020-07-30T10:45:55.579" lifespan="1ms">
<send>
<isomsg direction="outgoing">
<!-- org.jpos.iso.packager.GenericPackager[src/main/resources/iso8583.xml] -->
<field id="0" value="0100"/>
<field id="2" value="123456"/>
<field id="3" value="000010"/>
<field id="4" value="1500"/>
<field id="7" value="1206041200"/>
<field id="11" value="000001"/>
<field id="41" value="12340001"/>
<field id="49" value="840"/>
</isomsg>
</send>
</log>
Server:
--- exec-maven-plugin:1.2.1:exec (default-cli) # AppTest ---
Binding to port 9090, please wait ...
Server started: ServerSocket[addr=0.0.0.0/0.0.0.0,localport=9090]
Waiting for a client ...
Client accepted: Socket[addr=/127.0.0.1,port=58902,localport=9090]
=> the Client cannot send message
But if I cancel process of client project, the Server receives message & print log:
Message Received: 00730100722000000080800006123456000010000000001500120604120000000112340001840
<isomsg>
<!-- org.jpos.iso.packager.GenericPackager -->
<field id="0" value="0110"/>
<field id="8" value="80000612"/>
<field id="18" value="3456"/>
<field id="19" value="000"/>
<field id="20" value="010"/>
<field id="23" value="000"/>
<field id="27" value="0"/>
<field id="39" value="00"/>
<field id="57" value=""/>
</isomsg>
Problem is you are trying to receive the message using readLine and iso messages are not strings ended with an EOL.
I believe what's happening is that when the client disconnects the readLine method returns, because the input stream is closed.
It would be better to use ISOServer on your server, or even better a full q2 to implement it.
Otherwise you should first read the message length and then read that amount of bytes from the input stream, instead of waiting for a new line character that may or may not be part of the message itself
You can follow the first two jpos tutorials here http://www.jpos.org/tutorials, to get an idea on how to configure a Server with a request listener to process requests.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xml>
<Settings version="3" xmlns="urn:Adapter-v3">
<Connections>
<Connection name ="A" description="DEV">
<SaveVersion version="M" siteURL="https://example.com" />
<Save>
<Id>id123</Id>
<Client>hello</Client>
</Save>
</Connection>
<Connection name ="B" description="DEV1">
<SaveVersion version="M" siteURL="https://example.com" />
<Auth>
<UserId>id123</UserId>
<Password>pass</Password>
</Auth>
</Connection>
</Connections>
<Mappings>
<Mapping cont="AA" auction="A1">
<Description>Desc</Description>
<Content
attr1="IO"
attr2="d"
attr3="Information"
attr4="false"
<Element enabled="false" count="200" prefix="DocLib_" itemPrefix="0" />
<Sub enabled="false" count="100" prefix="Folder_" itemPrefix="0" />
<FilenameA auction="N" delay="3" />
</Content>
</Mapping>
<Mapping cont="AB" auction="SharePointOLDev1">
<Description>Desc</Description>
<Content
attr1="IO"
attr2="d"
attr3="Information"
attr4="false"
<Element enabled="false" count="200" prefix="DocLib_" itemPrefix="0" />
<Sub enabled="false" count="100" prefix="1" itemPrefix="0" />
</Content>
</Mapping>
</Mappings>
<TypeMappings>
<TypeMapping Type="rfid" ext="msg" />
</TypeMappings>
</Settings>
Trying to unmarshal the above xml file to java objects.
Generated Settings.java and ObjectFactory.java file using xjc tool.These files are deployed in the src folder(along with other java files.)
WHen i unmarshal i get null valuues for Connections,Mappings and TypeMappings.
Is there any steps that i am missing?
public class JAXBImpl{
public static void main(String args[]){
JAXBContext jaxbContext;
Settings que= null;
jaxbContext = JAXBContext.newInstance(Settings.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
que= (Settings) jaxbUnmarshaller.unmarshal(file);
System.out.println(que.getConnections().getConnection());
}
}
Process Compilation error : org.drools.lang.descr.ProcessDescr#4c60d6e9
com/sample/Process_com_sample_ruleflowsample.java (21:862) : Type mismatch: cannot convert from int to String
com/sample/Process_com_sample_ruleflowsample.java (29:1151) : Type mismatch: cannot convert from int to String
This is my ruleflowsample.rf under src/main/rules that is throwing the above error.
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://drools.org/drools-5.0/process"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/process drools-processes-5.0.xsd"
type="RuleFlow" name="ruleflowsample" id="com.sample.ruleflowsample" package-name="com.sample" >
<header>
<imports>
<import name="com.sample.Employee" />
</imports>
<variables>
<variable name="caffeineIntake" >
<type name="org.drools.process.core.datatype.impl.type.FloatDataType" />
</variable>
</variables>
</header>
<nodes>
<start id="1" name="Start" x="12" y="129" width="48" height="48" />
<split id="2" name="Gateway" x="101" y="128" width="49" height="49" type="2" >
<constraints>
<constraint toNodeId="4" toType="DROOLS_DEFAULT" name="Coffee" priority="1" type="code" dialect="java" >return caffeineIntake>0.105F;</constraint>
<constraint toNodeId="5" toType="DROOLS_DEFAULT" name="Tea" priority="1" type="code" dialect="java" >return caffeineIntake>0.04F;</constraint>
</constraints>
</split>
<actionNode id="4" name="Coffee" x="198" y="205" width="80" height="48" >
<action type="expression" dialect="java" >String noOfCups = 1;
System.out.println("No of coffee cups = "+noOfCups);
System.out.println("caffeineIntake");</action>
</actionNode>
<actionNode id="5" name="Tea" x="196" y="61" width="80" height="48" >
<action type="expression" dialect="java" >String noOfCups = 1;
System.out.println("No of tea cups = "+noOfCups);
System.out.println("caffeineIntake");</action>
</actionNode>
<end id="6" name="End" x="386" y="127" width="48" height="48" />
<join id="7" name="Gateway" x="311" y="127" width="49" height="49" type="2" />
</nodes>
<connections>
<connection from="1" to="2" />
<connection from="2" to="4" />
<connection from="2" to="5" />
<connection from="7" to="6" />
<connection from="5" to="7" />
<connection from="4" to="7" />
</connections>
</process>
I know the error is occurring because of this line: System.out.println("caffeineIntake");
I want to access this input variable i.e. caffeineIntake to perform some operation on it.
The error is not occurring because of this line: System.out.println("caffeineIntake");
It is occurring because of the Dialect option selection:
Using this option as mvel rather than java resolved the issue.
Well,
from my point of view
String noOfCups = 1;
is the problem.
perhaps change it to
String noOfCups = "1";
I'm trying to add a new line of tag "" with different attributes. I'm able to edit an existing line but not able to add new tag having different attributes.
The XML file
<elementDefinitionPackage elementDefinitionPackageName="kohler-decisionmaker" elementDefinitionPackageVersion="3.2.0.42" elementLibraryFilename="libkohler-decisionmaker.so" elementLibraryVersion="3.2.0.42" minSupportedGDDVersion="1.0" minSupportedUMGFirmwareVersion="1.1.0.0" xmlns="http://xmlns.commonplatform.avocent.com/mss/ddt/template" xmlns:cm="http://xmlns.commonplatform.avocent.com/mss/ddt/common" xmlns:r="http://xmlns.commonplatform.avocent.com/mss/ddt/rules" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.commonplatform.avocent.com/mss/ddt/template XSD_ddt.xsd http://xmlns.commonplatform.avocent.com/mss/ddt/rules XSD_rules.xsd http://xmlns.commonplatform.avocent.com/mss/ddt/common XSD_common.xsd">
<elementDefinitionModel manufacturerInSymbol="KOHLER" minSupportedVersionInSymbol="1.4" modelInSymbol="DEC4000" modelQualifierInSymbol="DEC4000" symbolTag="KOHLERDEC4000DEC4000">
<supportedprotocols>
<supportedProtocol isSubscribable="false" protocolName="MODBUS/RS-485">
<properties>
<property category="EXTCOMM" defaultValue="502" definition="PORT" valueType="Integer" />
<property category="EXTCOMM" defaultValue="60" definition="TIMEOUT" valueType="Integer" />
<property category="EXTCOMM" defaultValue="1" definition="SLAVEID" valueType="Integer"/>
</properties>
<datapoints>
<datapoint division="COLL_COMP_CEP" nature="PARAMETRIC" programmaticName="t_val_calc_enrg_interval"/>
</datapoints>
<events>
<event address="3.{SLAVEID}.40259.1" programmaticName="t_evt_gen_mainTankAlarm" values="a:1 i:0" />
</events>
<commands>
<command access="RW" address="#RWDA 3.{SLAVEID}.61105 6.{SLAVEID}.61105" division="CONTROL" nature="ENUM" programmaticName="t_st_gen_setControl" valueTypeInDevice="DATA_POINT_VALUE_TYPE_INTEGER" />
</commands>
</supportedProtocol>
</supportedprotocols>
<rules>
</rules>
<similarModels>
<similarModel manufacturerInSymbol="KOHLER" minSupportedVersionInSymbol="1.4" modelInSymbol="KD440" modelQualifierInSymbol="KD440" symbolTag="KOHLERKD440KD440"/>
</similarModels>
</elementDefinitionModel>
Expected Output XML file
<elementDefinitionPackage elementDefinitionPackageName="kohler-decisionmaker" elementDefinitionPackageVersion="3.2.0.42" elementLibraryFilename="libkohler-decisionmaker.so" elementLibraryVersion="3.2.0.42" minSupportedGDDVersion="1.0" minSupportedUMGFirmwareVersion="1.1.0.0" xmlns="http://xmlns.commonplatform.avocent.com/mss/ddt/template" xmlns:cm="http://xmlns.commonplatform.avocent.com/mss/ddt/common" xmlns:r="http://xmlns.commonplatform.avocent.com/mss/ddt/rules" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.commonplatform.avocent.com/mss/ddt/template XSD_ddt.xsd http://xmlns.commonplatform.avocent.com/mss/ddt/rules XSD_rules.xsd http://xmlns.commonplatform.avocent.com/mss/ddt/common XSD_common.xsd">
<elementDefinitionModel manufacturerInSymbol="KOHLER" minSupportedVersionInSymbol="1.4" modelInSymbol="DEC4000" modelQualifierInSymbol="DEC4000" symbolTag="KOHLERDEC4000DEC4000">
<supportedprotocols>
<supportedProtocol isSubscribable="false" protocolName="MODBUS/RS-485">
<properties>
<property category="EXTCOMM" defaultValue="502" definition="PORT" valueType="Integer" />
<property category="EXTCOMM" defaultValue="60" definition="TIMEOUT" valueType="Integer" />
<property category="EXTCOMM" defaultValue="1" definition="SLAVEID" valueType="Integer"/>
</properties>
<datapoints>
<datapoint division="COLL_COMP_CEP" nature="PARAMETRIC" programmaticName="t_val_calc_enrg_interval"/>
</datapoints>
<events>
<event address="3.{SLAVEID}.40259.1" programmaticName="t_evt_gen_mainTankAlarm" values="a:1 i:0" />
</events>
<commands>
<command access="RW" address="#RWDA 3.{SLAVEID}.61105 6.{SLAVEID}.61105" division="CONTROL" nature="ENUM" programmaticName="t_st_gen_setControl" valueTypeInDevice="DATA_POINT_VALUE_TYPE_INTEGER" />
</commands>
</supportedProtocol>
</supportedprotocols>
<rules>
</rules>
<similarModels>
<similarModel manufacturerInSymbol="KOHLER" minSupportedVersionInSymbol="1.4" modelInSymbol="KD440" modelQualifierInSymbol="KD440" symbolTag="KOHLERKD440KD440"/>
<similarModel manufacturerInSymbol="KOHLER" minSupportedVersionInSymbol="1.4" modelInSymbol="A" modelQualifierInSymbol="B" symbolTag="C"/>
</similarModels>
</elementDefinitionModel>
Java Code
private static void updat() {
NodeList similarmodels = doc.getElementsByTagName("similarModels");
Element model = null;
for(int i=0; i<similarmodels.getLength();i++){
model = (Element) similarmodels.item(i);
String model = model.getElementsByTagName("similarModel").item(0).getFirstChild().getNodeValue();
if(model.equalsIgnoreCase("KD440")){
model.setAttribute("A");
}else{
model.setAttribute("B");
}
}
}
Is there a way of doing this in JAXB & xsd??
Should be no problem, neither with DOM nor with JAXB. In JAXB you should simply be able to create a new SimilarModel object which you then can add in the SimilarModels object's list.
I have a dictionary created from the DictionaryCreator from UIMA, I would like to annotate a piece of text using the DictionaryAnnotator and the aforementioned dictionary, I could not figure out how to get the annotated text. Please let me know if you do. Any help is appreciated. The code, the dictionary-file and the descriptor is mentioned below,
P.S. I'm new to Apache UIMA.
XMLInputSource xml_in = new XMLInputSource("DictionaryAnnotatorDescriptor.xml");
ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(xml_in);
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
JCas jCas = ae.newJCas();
String inputText = "Mark and John went down the rabbit hole to meet a wise owl and have curry with the owl.";
jCas.setDocumentText(inputText);
printResults(jCas);
public static void printResults(JCas jcas) {
FSIndex<Annotation> index = jcas.getAnnotationIndex();
for (Iterator<Annotation> it = index.iterator(); it.hasNext(); ) {
Annotation annotation = it.next();
List<Feature> features;
features = annotation.getType().getFeatures();
List<String> fasl = new ArrayList<String>();
for (Feature feature : features) {
try {
String name = feature.getShortName();
System.out.println(feature.getName());
String value = annotation.getStringValue(feature);
fasl.add(name + "=\"" + value + "\"");
System.out.println(value);
}catch (Exception e){
continue;
}
}
}
}
my_dictionary.xml
<?xml version="1.0" encoding="UTF-8"?>
<dictionary xmlns="http://incubator.apache.org/uima" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="dictionary.xsd">
<typeCollection>
<dictionaryMetaData caseNormalization="true" multiWordEntries="true" multiWordSeparator=" "/>
<languageId>en</languageId>
<typeDescription>
<typeName>org.apache.uima.DictionaryEntry</typeName>
</typeDescription>
<entries>
<entry>
<key>Mark</key>
</entry>
<entry>
<key>John</key>
</entry>
<entry>
<key>Rabbit</key>
</entry>
<entry>
<key>Owl</key>
</entry>
<entry>
<key>Curry</key>
</entry>
<entry>
<key>ATH-MX50</key>
</entry>
<entry>
<key>CC234</key>
</entry>
</entries>
</typeCollection>
</dictionary>
DictionaryAnnotatorDescriptor.xml
<?xml version="1.0" encoding="UTF-8"?>
<analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier">
<frameworkImplementation>org.apache.uima.java</frameworkImplementation>
<primitive>true</primitive>
<annotatorImplementationName>org.apache.uima.annotator.dict_annot.impl.DictionaryAnnotator</annotatorImplementationName>
<analysisEngineMetaData>
<name>GeneDictionaryAnnotator</name>
<description></description>
<version>0.1</version>
<vendor></vendor>
<configurationParameters>
<configurationParameter>
<name>DictionaryFiles</name>
<description>list of dictionary files to configure the annotator</description>
<type>String</type>
<multiValued>true</multiValued>
<mandatory>true</mandatory>
</configurationParameter>
<configurationParameter>
<name>InputMatchType</name>
<description></description>
<type>String</type>
<multiValued>false</multiValued>
<mandatory>true</mandatory>
</configurationParameter>
<configurationParameter>
<name>InputMatchFeaturePath</name>
<description></description>
<type>String</type>
<multiValued>false</multiValued>
<mandatory>false</mandatory>
</configurationParameter>
<configurationParameter>
<name>InputMatchFilterFeaturePath</name>
<description></description>
<type>String</type>
<multiValued>false</multiValued>
<mandatory>false</mandatory>
</configurationParameter>
<configurationParameter>
<name>FilterConditionOperator</name>
<description></description>
<type>String</type>
<multiValued>false</multiValued>
<mandatory>false</mandatory>
</configurationParameter>
<configurationParameter>
<name>FilterConditionValue</name>
<description></description>
<type>String</type>
<multiValued>false</multiValued>
<mandatory>false</mandatory>
</configurationParameter>
</configurationParameters>
<configurationParameterSettings>
<nameValuePair>
<name>DictionaryFiles</name>
<value>
<array>
<string>src/main/resources/my_dictionary.xml</string>
</array>
</value>
</nameValuePair>
<nameValuePair>
<name>InputMatchType</name>
<value>
<string>org.apache.uima.TokenAnnotation</string>
</value>
</nameValuePair>
</configurationParameterSettings>
<typeSystemDescription>
<types>
<typeDescription>
<name>org.apache.uima.DictionaryEntry</name>
<description></description>
<supertypeName>uima.tcas.Annotation</supertypeName>
</typeDescription>
<typeDescription>
<name>org.apache.uima.TokenAnnotation</name>
<description>Single token annotation</description>
<supertypeName>uima.tcas.Annotation</supertypeName>
<features>
<featureDescription>
<name>tokenType</name>
<description>token type</description>
<rangeTypeName>uima.cas.String</rangeTypeName>
</featureDescription>
</features>
</typeDescription>
<typeDescription>
<name>example.Name</name>
<description>A proper name.</description>
<supertypeName>uima.tcas.Annotation</supertypeName>
</typeDescription>
</types>
</typeSystemDescription>
<capabilities>
<capability>
<inputs/>
<outputs>
<type>example.Name</type>
</outputs>
<languagesSupported/>
</capability>
</capabilities>
<operationalProperties>
<modifiesCas>true</modifiesCas>
<multipleDeploymentAllowed>true</multipleDeploymentAllowed>
<outputsNewCASes>false</outputsNewCASes>
</operationalProperties>
</analysisEngineMetaData>
</analysisEngineDescription>
Alternatively, you could also use Apache Ruta, either with the workbench (recommended to get started) or with java code.
For the latter, I created an example project at https://github.com/renaud/annotate_ruta_example. The main parts are:
a list of names in src/main/resources/ruta/resources/names.txt (a plain text file)
Mark
John
Rabbit
Owl
Curry
ATH-MX50
CC234
a Ruta script in src/main/resources/ruta/scripts/Example.ruta
PACKAGE example.annotate; // optional package def
WORDLIST MyNames = 'names.txt'; // declare dictionary location
DECLARE Name; // declare an annotation
Document{-> MARKFAST(Name, MyNames)}; // annotate document
and some java boilerplate code to launch the annotator:
JCas jCas = JCasFactory.createJCas();
// the sample text to annotate
jCas.setDocumentText("Mark wants to buy CC234.");
// configure the engine with scripts and resources
AnalysisEngine rutaEngine = AnalysisEngineFactory.createEngine(
RutaEngine.class, //
RutaEngine.PARAM_RESOURCE_PATHS,
"src/main/resources/ruta/resources",//
RutaEngine.PARAM_SCRIPT_PATHS,
"src/main/resources/ruta/scripts",
RutaEngine.PARAM_MAIN_SCRIPT, "Example");
// run the script. instead of a jCas, you could also provide a UIMA collection reader to process many documents
SimplePipeline.runPipeline(jCas, rutaEngine);
// a simple select to print the matched Names
for (Name name : JCasUtil.select(jCas, Name.class)) {
System.out.println(name.getCoveredText());
}
there is also some UIMA type (annotation) definitions, check src/main/resources/desc/type/ExampleTypes.xml, src/main/resources/META-INF/org.apache.uima.fit/types.txt and src/main/java/example/annotate.
how to test it
git clone https://github.com/renaud/annotate_ruta_example.git
cd annotate_ruta_example
mvn clean install
mvn exec:java -Dexec.mainClass="example.Annotate"