Connecting to GoogleRefine using Java program - java

This question is similar to the posting 'Script-driven automation of Google refine with ruby python perl java or otherwise': Script-driven automation of Google refine with ruby python perl java or otherwise
I have a lengthy JSON Script that I created in GoogleRefine and I am using it to clean several individual text files. Currently, I need to load each file manually into GoogleRefine and run the JSON script.
Is there a Java code/library that I can use to connect to GoogleRefine and pass on my JSON script and text file locations in order to speedily clean all of my files? I don't know Python and since the post above is dated 2011, I am wondering if a Java libray/program has been written since then.

Today there is no Java library. You can find them in following languages:
python
ruby
JavaScript
You can read more about the OpenRefine API here: https://github.com/OpenRefine/refine-python/wiki/Refine-API

Related

Execute Python script from Android app in Java?

I am trying to find a way to execute a Python script from my Java code in Android. I did a research on this matter but the only thing I found is, how I can convert python scripts in APK for android (Kivy e.t.c.).
More specifically I have a script which contains a lot of functions.What i want to do is to create an object based on this python script inside my java code and via this object to call my functions.
I can't convert my Python code into Java, because I use various libraries that exists only in python.
Any advice would be helpful and deeply appreciated.
The following a snippet of my Python script. I use the library charm for cryptography.
from charm.core.math.integer import integer,serialize,deserialize
class serializeClass:
def __init__(self)
...
def serialize(self, charm_object):
assert type(charm_object) == integer, "required type is integer, not: ", type(charm_object)
return serialize(charm_object)
def deserialize(self, object):
assert type(object) == bytes, "required type is bytes, not: ", type(object)
return deserialize(object)
One option would be to create a Web Service API to allow your python results be served up over HTTP. Then it's just a matter of Android communicating with an HTTP web service which is simple.
You might find some python to java bridge out there but in my experience these things always have limitations in practice and seem great in theory but don't end up working correctly.
You can use SL4A project which would allow you run your Python code on Android.
Github: https://github.com/damonkohler/sl4a
Tutorials: https://github.com/damonkohler/sl4a/blob/wiki/Tutorials.md
Check out Qpython, could be an easy solution. You can run your python script against the Qpython android python core, or deploy yours.
Checkout this repository: https://github.com/qpython-android/app-call-qpython-api

Is there any way to execute a JRuby script within my Java application for Android?

I want to run a JRuby script in my Java application in Android.
javax.script is not included in Android. You can try to import the package manually, but when you try to obtain the JRuby engine, it returns null.
Apache BSF can't load the engine either. You get an error related to "privileged exception: cannot load class file" - I imagine that Android doesn't allow this sort of loading, so you can't dynamically load JRuby with BSF.
SL4A doesn't make any sense at all. Besides the fact that they don't have clear instructions on how to use it for running JRuby, the last time it was updated was like 4 years ago.
Ruboto is used for writing Android applications with Ruby. That's not what I want. I just want to run a Ruby snippet in my Java application.
Is there any way you can run JRuby scripts in a Java application in Android? Are there clear instructions anywhere?
Apparently, you can use the --java flag with jrubyc to generate java source code from jruby code.
If you don't have an absolute requirement to retain the jruby script at runtime, I'd do that, and then put the java code into the Android app.
Of course, you'll still need the jruby jar file in your Android app.
See https://github.com/jruby/jruby/wiki/GeneratingJavaClasses#user-content-generating-java-classes-ahead-of-time

Using a python Project in java

I am using java in order to build a linguistic System for arabic language and i need to use an open source project as a black box inside my System the only problem is that the open source System is in Python so my question how could i use this System in java,
so that i could make this function
String output=applyPythonSystem(String input);
And please don't say Jython (Without explaining How??) i tried to use it but i couldn't find a way to do this function

How to execute java functions/script in PHP

I have a system which is implemented using PHP(Joomla). Now the client wants to integrate a SMS gateway. Unfortunately SMS gateway does not supoort PHP. It's written in Java and All the examples are written in JAVA.
I'm supposed to include webservices‐rt.jar to my program and run a example script as below.
lk.mobitel.esms.User user = new lk.mobitel.esms.User (); user.setUsername(“TestUser”);
user.setPassword(“Password”);
lk.mobitel.esms.test.ServiceTest st = new lk.mobitel.esms.test.ServiceTest ();
System.out.println(st.testService(u));
According to my knowledge I can run a .jar as below using PHP
<?php exec("java -jar filename.jar arguments",$output); ?>
How can I run a JAVA script like above in PHP? Is it possible? Is there a way to bridge PHP and JAVA? What I want is to run JAVA in PHP else I would say communicate between these two.
I never did this, but PHP Manual gave a link for PHP-Java Bridge for PHP5 as PHP/Java Bridge. If it is what you are looking for ?
It's not possible to combine PHP and Java in the same script and have them executed in one run.
Your exec approach is the way to go, if you are approaching from PHP. But you should rather use passthru as exec does not return anything. With passthru you can get the shell response of your java command and act accordingly.
Is there a way to bridge PHP and JAVA? What I want is to run JAVA in PHP else I would say communicate between these two.
Simple answer:
Bridge using data-exchange layer. :)
Hint (in super simple language): My favorite webservice uses PERL to process their scripts and I fetch them using XML.
Groupon is made on RoR but, I happily get tweets, thanks to their API which outputs a JSON.
Simple? :)

Android: Call Python Script (via SL4A) from Java code

Is it possible to call/run a python script file from Java code on the Android platform using SL4A? Basically I have a full blown Java Android app and I have several Python scripts that scrape some information from various web pages. I would like to be able to call these python scripts with the web page and get the results back. Is this possible? If so, can anyone point me in the direction of an example or two?
Thank you,
Harry
run an SL4A script from my application?
http://code.google.com/p/android-scripting/wiki/FAQ#Can_I_run_an_SL4A_script_from_my_application?
Here you go, a solution on how to make Android applications using SL4A and Python. I have developed a functional Python application following this tutorial so I can vouch for it. I assume you can add the Python code and do your data exchange with JSON.
I personally have never tried to mix these two together, though I will probably try after seeing your post.
Also, if you have any problems/questions, related to starting that example, post them here, I might help.

Categories

Resources