Is there any API in Java to access wikipedia data - java

I want to know: is there any API or a query interface through which I can access Wikipedia data?

Mediawiki, the wiki platform that wikipedia uses does have an HTTP based API. See MediaWiki API.
For example, to get pages with the title stackoverflow, you call
http://en.wikipedia.org/w/api.php?action=query&titles=Stackoverflow
There are some (incomplete) Java wrappers around the API - see the Client Code - Java section of the API page for more detail.

For the use with Java, try http://code.google.com/p/wiki-java. It is only one class, but a great one!

You can use Jwiki to get Wikipedia data
Example :
Jwiki jwiki = new Jwiki("elon musk");
System.out.println("Title :"+jwiki.getDisplayTitle()); //get title
System.out.println("Text : "+jwiki.getExtractText()); //get summary text
System.out.println("Image : "+jwiki.getImageURL()); //get image URL

I had the same question and the closest I came to an out-of-the-box solution is bliki, hosted at http://code.google.com/p/gwtwiki/.
I also wrote an article at Integrating Stuff to help you get started with it: http://www.integratingstuff.com/2012/04/06/hook-into-wikipedia-using-java-and-the-mediawiki-api/

MediaWiki is a free and open-source wiki software. Originally developed by Magnus Manske and improved by Lee Daniel Crocker, it runs on many websites, including Wikipedia, Wiktionary and Wikimedia Commons.[5][6]
There is list of Java libraries that can help you to connect wiki by java code .
https://www.mediawiki.org/wiki/API:Client_code#Java
but after use some of them because of their limitations , we try to call REST services from mediawiki directly.

Related

Is there any method to create radio button in com.ibm.cics.server

The java API for CICS is here. Does anyone know if there any method to put a couple of radio buttons to a web form using this API?
Here's my code to create radio button
HttpRequest req = HttpRequest.getHttpRequestInstance();
String msg = "ZEUSBANK ANTI-FRAUD CHECK BY SHE0008.<br> "
+ "When investigation is complete. Tick the check box and submit.<br>";
String template = "<form><input type=\"radio\"> YES<br><input type=\"radio\"> NO<br></form>";
HttpResponse resp = new HttpResponse();
Document doc = new Document();
doc.createText(msg);
doc.appendFromTemplate(template);
resp.setMediaType("text/plain");
resp.sendDocument(doc, (short)200, "OK", ASCII);
But when I run it on a browser, it print plain text and doesn't convert html tag.
Fixed it, I just change media type from text/plain to text/html and it works.
As you've already discovered, you needed to send the request with the text/html content type.
If you're planning to do more Java web-based work through CICS Java, you might want to investigate the embedded WebSphere Liberty. It adds support for Java EE features, which includes JSF, JSP and Servlets, which can make web development in Java a lot easier.
Tri,
I haven't used CICS for 15 years, so I doubt I'm an expert anymore. But looking quickly at the API, it seems like all the presentation logic would be in your regular Java code. You would then format appropriate messages and invoke the CICS API to update the server & get a response.
There doesn't seem to be any 'BMS-related' methods at all (which is a good thing).
The only 'field' method I see is com.ibm.cics.server.FormField but that only has get() methods, not set().
Are you just starting with Java CICS, or are you just stuck on this particular issue? If you have some sample code of what you are trying, post it so we can see if anyone has any ideas.
HTH, Jim

How to retrieve from Azure mobile services using android studio

I am new to Android and Windows Azure. I have successfully inserted data from Android application but how do I retrieve single data and post that data on a TextView?
The read function after the gettable class is also not working. What is the exact function use for it? I have followed these instructions but they did not work for me, also I do not understand the documentation.
Currently, I just can provide some tutorials about how to use query data from azure database. I recommend you can refer to this official document about how to use Azure Client Library using Java: https://azure.microsoft.com/en-us/documentation/articles/mobile-services-android-how-to-use-client-library . You can focus on two part: “how to query data from a mobile service” and “how to bind data to the UI”.
At the same time, you can view this video from Channel 9: https://channel9.msdn.com/Series/Windows-Azure-Mobile-Services/Android-Getting-Started-With-Data-Connecting-your-app-to-Windows-Azure-Mobile-Services.
The sample code project of this tutorial, please go to the GitHub link https://github.com/Azure/mobile-services-samples/tree/master/GettingStartedWithData .
For the ‘getTable(Class )’ function is not working, please double check whether the class name is same as table name. If they are same, you can use it like below:
MobileServiceTable<ToDoItem> mToDoTable = mClient.getTable(ToDoItem.class);
If not, you can write you code like this:
MobileServiceTable<ToDoItem> mToDoTable = mClient.getTable("ToDoItemBackup", ToDoItem.class);
For further better support, please share more detail about your code snippet .

Has anyone used pubchemdb? Any similar API?

Update: The link in the answer is both interesting and useful, but unfortunately does not address the need for a java API, so I am still looking forward to any input.
I'm building a database of chemical compounds. I need all the synonyms (IUPAC and common names) as well as safety data for each.
I'll be using the freely available data at PubChem (http://pubchem.ncbi.nlm.nih.gov/)
There's an easy way of querying each compound with simple HTTP gets. For example, to obtain glycerol data, the URL is:
http://pubchem.ncbi.nlm.nih.gov/summary/summary.cgi?cid=753
And the following URL would return an easy to parse format:
http://pubchem.ncbi.nlm.nih.gov/summary/summary.cgi?cid=753&disopt=DisplaySDF
but it will respond only very basic info, lacking safety data and only a few common names.
There is one public domain API for JAVA that seems a very complete, developed by a group at Scripps (citation). The code is here.
Unfortunately, this API is not very well documented and it's quite difficult to follow due to the complexity of the data involved.
For what I gathered, pubchemdb is using the PubChem Power User Gateway (PUG) XML API
Has anyone used this API (or any other one available)? I would appreciate a short description or tutorial on how to start with it.
The Cactvs Chemoinformatics toolkit (free for academic/educational use) has full PubChem integration. Using the scripting environment, you can easily do something like
cactvs>ens create 753
ens0
cactvs>ens get ens0 E_NAMESET
PROPANE-1,2,3-TRIOL GLYCEROL 8043-29-6 29796-42-7 30049-52-6 37228-54-9 75398-78-6 78630-16-7 8013-25-0 175385-78-1 25618-55-7 64333-26-2 56-81-5 {Tegin M} LS-1377 G8773_SIGMA 15523_RIEDEL {Glycerin, natural} NCGC00090950-03 191612_ALDRICH 15524_RIEDEL {Glycerol solution} L-glycerol 49767_FLUKA {Biodiesel impurity} 49770_FLUKA 49771_FLUKA NCGC00090950-01 49927_FLUKA Glycerol-Gelatine G7757_SIAL GOL D-glycerol G9012_SIAL {Polyhydric alcohols} c0066 MOON {NSC 9230} G2025_SIGMA ZINC00895048 49781_FLUKA {Concentrated glycerin} {Concentrated glycerin (JP15)} D00028 {Glycerin (JP15/USP)} 44892U_SUPELCO {Glycerin, concentrated (JAN)} CRY 49782_FLUKA NCGC00090950-02 G6279_SIAL W252506_ALDRICH G7893_SIAL {Glycerin, concentrated} 33224_RIEDEL Bulbold Cristal Glyceol G9281_SIGMA Glycerol-1,2,3-3H G1901_SIGMA G7043_SIGMA 1,2,3-trihydroxypropane 1,2,3-trihydroxypropanol glycerin G2289_SIAL G9406_SIGMA {Glycerol-[2-3H]} CHEBI:17754 Glyzerin Oelsuess InChI=1/C3H8O3/c4-1-3(6)2-5/h3-6H,1-2H {90 Technical glycerine} Dagralax {Glycerin, anhydrous} {Glycerin, synthetic} Glycerine Glyceritol {Glycyl alcohol} Glyrol Glysanin NSC9230 Ophthalgan Osmoglyn Propanetriol {Synthetic glycerin} {Synthetic glycerine} Trihydroxypropane Vitrosupos {WLN: Q1YQ1Q} Glycerol-1,3-14C {4-01-00-02751 (Beilstein Handbook Reference)} AI3-00091 {BRN 0635685} {CCRIS 2295} {Caswell No. 469} {Citifluor AF 2} {Clyzerin, wasserfrei [German]} {EINECS 200-289-5} {EPA Pesticide Chemical Code 063507} {FEMA No. 2525} {Glicerina [DCIT]} {Glicerol [INN-Spanish]} {Glycerin (mist)} {Glycerin [JAN]} {Glycerin mist} {Glycerine mist} Glycerinum {Glycerolum [INN-Latin]} Grocolene {HSDB 492} IFP {Incorporation factor} 1,2,3-Propanetriol C00116 Optim {Propanetriol (VAN)} {1,2,3-PROPANETRIOL, HOMOPOLYMER} {Glycerol polymer} {Glycerol, polymers} {HL 80} {PGL 300} {PGL 500} {PGL 700} Polyglycerin Polyglycerine Polyglycerol {Unigly G 2} {Unigly G 6} G5516_SIGMA MolMap_000024
cactvs>
This hides all PUG ugliness - but in any case, I dare say that PUG is well documented. The toolkit goes much beyond simple data downloads - you can even open and query PubChem like a local SD file if you want to.
PubChem does not contain safety data, though. And safety data is country/region-dependent, strictly regulated, and you should be really careful not to be hit with liabilities. Have your approach checked by legal personnel!

Google Translator API and many translation for one word

I am using google-api-translate-java-0.92.jar.
Translate.setHttpReferrer("http://translate.google.com/");
try {
String translation = Translate.execute("arrangement", Language.ENGLISH, Language.UKRANIAN);
System.out.println(translation);
} catch (Exception e) {
System.out.println(e.getMessage());
}
But I get only one translation.
I go to page http://translate.google.com/ and It gives me multiple translation.
How can I get multiple translation from my code?
I don't believe you can...
Looking at the soucre, it builds up the following URL:
http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&langpair=en|uk&q=arrangement
which when you look at the JSON response, returns:
{"responseData": {"translatedText":"Композиція"}, "responseDetails": null, "responseStatus": 200}
As you can see, this is only returning a single word. The dictionary lookup on the google translate page must be an additional call to a different service (not part of the translate service)
EDIT
Using firebug, you can see the request that is being made by the translate page, and you get this URL:
http://translate.google.com/translate_a/t?client=t&text=arrangement&hl=en&sl=en&tl=uk&multires=1&otf=2&pc=0&sc=1
Which returns this:
[[["Композиція","arrangement","Kompozytsiya"]],[["noun",["розташування","розміщення","домовленість","аранжування","упорядкування","механізм","оформлення","пристрій","систематизація","монтаж","пристосування","урегулювання","плани","згода","залагода","розв'язання","порозуміння"]]],"en"]
However, this extended URL format is not supported by the translate JAR you are using (at least I can't find it in the source on google code), is not part of the googleapis subdomain, and I'm not even sure it's for public consumption or that calling it directly doesn't violate Googles T&Cs.
But that's how they generate the dictinary list anyway...
From Google Translate API FAQ (checked: 16 November 2013)
Is it possible to get multiple translations of a word?
The answer:
No. This feature is only available via the web interface at
translate.google.com
source: https://developers.google.com/translate/v2/faq#technical
There is an open enhancement request for this functionality. So it doesn't look like you're doing anything wrong; the API just doesn't expose that functionality.

Web Search API for Java

I need a Java library for doing web searches ( any search engine is good ).
I should be able to to write code such as:
WebSearch search = new WebSearch("Apple");
System.Out.Println("Results = " + search.Results.Count);
Does such a library/API exist ?
Regards,
Sebastian
There's an API called JFreeWebSearch:
http://www.ke.tu-darmstadt.de/resources/jfreewebsearch
I think this is your best options.
What is important here is Google's API:
http://ajax.googleapis.com/ajax/services/search/web?start=0&rsz=large&v=1.0&q=Apple
Note the "Apple" in the query String.
With this in mind, use any Java HttpClient (URLConnection class, Apache's HttpClient, you name it) to query and get results back.
lucene is Java based search engine

Categories

Resources