Set up OpenNLP: Text Detection using the Vision java API - java

Set up OpenNLP
Download Tokenizer data and save it to this directory.
wget http://opennlp.sourceforge.net/models-1.5/en-token.bin
This is what Google asks me at here
I got no clue what OpenNLP is so I google it.
This is what Apache says on their Setup OpenNLP page:
If you have an IDE installed such as NetBeans or Eclipse installed, it
will make your development easier. However, follow on for the brave.
I got Intellij NetBeans, how do I set it up?
When building with maven in Intellij and attempting to run this sample, this is the error that I get:
java.io.FileNotFoundException: en-token.bin (The system cannot find the file specified)
When I try to continue with Google doc I fail in this line:
java -cp target/vision-text-1.0-SNAPSHOT-jar-with-dependencies.jar com.google.cloud.vision.samples.text.TextApp data/
With an error:
Error: Could not find or load main class com.google.cloud.vision.samples.text.TextApp

It looks like all you need from OpenNLP is that Tokeniser .bin file - this is just a binary file that the library uses to tokeise text (e.g. split sentences into words). It would appear like there is nothing else you need from that library - If you look in the google vision pom file(https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/vision/text/pom.xml) you will see they have a dependency on the OpenNLP JAR, so here you are just grabbing the pre-trained resource for that library.
Assuming you have cloned that GitHub repo, and have successfuly run the maven command they mention:
mvn clean compile assembly:single
Then that downloaded file (en-token.bin) should be copied to the root of the project directory (the same location as the pom.xml and where you are running the java command).
If the setup is like that then it should work ok.

Related

No output build from gradle with third-party library

I'm having trouble using gradle to build some project files from over at https://github.com/Hopding/JRPiCam. I am forcing myself to start learning gradle this week, but so far my cursory internet searches have given me only a vague sense of what gradle even does. I'm assuming that it's used to help keep track of disparate files hosted at varying locations across the internet, and maybe with file versioning. Anyways, for right now I would just like to compile a class into a Jar file and begin using it in my code to automate the camera on my raspberry Pi. The directions say to clone the directory onto my local computer, change the directory to the download location, and then, from the Windows PowerShell, use the command: ./gradlew jar to output a build directory where the compiled jars will reside. I followed the instructions, and though I received no error message, I also received no output directories. Nothing at all. I have installed gradle 6.9 on Windows 10 and made sure the path variable is set appropriately. So here is my question: 1. If I have this directory structure: , can I just cd into there and use a gradle command to compile? Thanks in advance.

Can't install package in maven

I want to work with some audio analysis and want to use the Phash perceptual algorithm. Here's a Java implementation I want to use.
I'm having trouble adding this project as a dependency; I don't see how to run mvn package test install to get this project linked.
Similarly, this project needs this other project to read the audio files. When I try to install the library using the cmake commands I get errors like sndfile.h: No such file or directory. This Stackoverflow answer shows how to install it, but I still get the sndfile.h: No such file or directory error. I'm on a Mac, by the way. I found the sndfile.h file and copied it to the directory, but the build didn't work in the end anyway.
I feel like this isn't the right way to do this and things should "work" after doing the basic install commands listed in the repositories. What am I missing?

Opencv native location set up for java-eclipse linux based

I am trying to setup a java based opencv program to run on raspberry-pi.I installed opencv-2.4.8 on my raspberry-pi. I also installed eclipse to set up opencv.The problem is i am not able to link native libraries for my opencv-2.4.8 jar file in eclipse.
Eclipse is running fine with raspberry-pi and i am able to compile and run simple java programs.From where to link the native library for opencv2.4.8 jar file.
I checked my opencv folder and it is having the following structure.
MY OpenCV Folder
Opencv release folder
Found the following opencv .so files in usr/local/lib folder of my pi. Is this is what i should link to my native library. But there are many .so files also.
The output console with the error is as follows. sorry the screenshot skipped unsatisfied link error..
I had the same error which come up like this. I have an application that I have to run. I build and install opencv and try to run but I see that error like you. For solving this issue I replace old opencv_*jar with built one in opencv directory. You have to use jar file that you have just built.
..../opencv/build/bin/opencv-2410.jar
I thing old jar looks for different native path.
I had the same issue. I set my Native Lib Location to {OpenCV directory}/{Build directory}/lib and things worked fine.

Java project won't compile to a JAR correctly for Android

in an app I'm working on I have an issue with a Java library which is here - https://github.com/kennydude/Boid-Twitter-API
When I run ant android which builds an Android package it builds fine and Eclipse can read the Jar fine.
But on my device it says that dalvik cannot locate any of the classes and eventually throws a ClassDef Exception.
I have used Jars before, so I'm wondering if it's my ant file that's broken
I would open your app project in eclipse (the one that depends on the Java library that is not found at run-time) and add the jar file the Java library produced to its build path. Then execute
android -s update project -p .
in the same directory as your apps' Manifest.xml file in order do generate ant build files.
After this, you should be able to build your app using ant by doing
ant debug
or
ant release
I fixed it by ensuring Ant was compiling to 1.6 of Java which is my target in Eclipse for the application.
Perhaps you're not placing your jar in the libs directory as opposed to lib directory? Here's a similar issue Java (Android) - class not found exception
First of all to build an apk with ant for Android you have to use ant debug or ant release, i don't know what ant android does and why you are using it but this command is not part of the standard approach to ant for Android, that's for sure.
Ant is just a building tools, if a developer provide a building solution in ant, does not mean that his application is for Android.
Under Android everything that is not a native library is converted in a DEX object, which is something similar to bytecode for the Dalvik, there is no jar or other container in your app.
This question may be helpful for you Adding a library/JAR to an Eclipse Android project .
There are a lot of conceptual errors in this topic, you probably want to study the Android platform before using it.

Missing ant-javamail.jar file on Macintosh

I've been running the built-in Ant from the command line on a Macintosh (10.5.5) and have run into some trouble with the Mail task. Running the Mail task produces the following message:
[mail] Failed to initialise MIME mail: org.apache.tools.ant.taskdefs.email.MimeMailer
This is most likely due to a missing ant-javamail.jar file in the /usr/share/ant/lib directory. I see a "ant-javamail-1.7.0.pom" file in this directory but not the appropriate jar file. Anyone know why this jar file might be missing and what the best way to resolve the problem is?
Here's what I ended up doing to resolve the problem:
Downloaded the latest version of Ant from http://ant.apache.org/
The "built-in" Ant is installed in /usr/share/ant; I didn't want to overwrite that version so I extracted the new, full version into /usr/local/share/apache-ant-1.7.1/
As npellow points out, the the Mac doesn't include mail.jar or activation.jar -- these files can be downloaded and extracted from JavaMail API and JavaBeans Activation Framework respectively and copied to the new ant lib folder (same folder as all the ant-*.jar files)
The ant command (/usr/bin/ant) is a symbolic link to /usr/share/ant/bin/ant; I updated this link to point to the new version (ln -s /usr/local/share/apache-ant-1.7.1/bin/ant /usr/bin/ant)
If for some reason you need to make the old version of Ant the default again, just use
ln -s /usr/share/ant/bin/ant /usr/bin/ant
Steps 2-4 were done at the command prompt as root. That's it -- the Mac now has the latest, complete version of Ant and the Mail task works just fine.
Download the Java Mail libraries from: http://java.sun.com/products/javamail/ .
You will also need http://java.sun.com/products/javabeans/glasgow/jaf.html
A list of all external dependencies required by Ant's optional tasks are outlined here http://ant.apache.org/manual/index.html .
Another way to get dependencies for Ant very easily, is to run:
ant -f fetch all
from $ANT_HOME. You can also run -projecthelp for a full list of targets:
all load all the libraries
antlr load antlr libraries
bcel load bcel libraries
beanshell load beanshell support
bsf load bsf libraries
debugging internal ant debugging
get-m2 Download the Maven2 Ant tasks
jdepend load jdepend libraries
jruby load jruby
junit load junit libraries
jython load jython
logging load logging libraries
networking load networking libraries (commons-net; jsch)
regexp load regexp libraries
rhino load rhino
script load script languages
xerces load an updated version of Xerces
xml load full XML libraries (xalan, resolver)
I also got this working a slightly different way:
Created directory ~/.ant/lib.
Downloaded JavaMail API and copied the jars into that directory.
Downloaded JavaBeans Activation Framework and copied the jars into that directory.
Downloaded Apache Ant 1.7.0 (not the latest, matches the installed version) and copied the apache-ant-1.7.0/lib/ant-javamail.jar file into that directory.
This only solves the problem for a single user account, but that was fine for my purposes and saved me the hassle of having two separate ant installations on my machine.

Categories