views:

416

answers:

3

I am developing a web page in which I am accepting input words from user and when user will submit those words then I want to display definition of those words or wikipedia link of those words for more definition about that word. Something like below:

Let's say user enetered 5 words:

toast, egg, beans, coffee, tea

Now I want to display them like:

toast  › slices of bread that have been toasted
egg    › animal reproductive body consisting of an ovum or embryotogether with nutritive and protective envelopes
beans  › a small skullcap <link to wikipedia>read more on wikipedia</link>
coffee › a beverage consisting of an infusion of ground coffee beans
tea    › a beverage made by steeping tea leaves in water <link to wikipedia>read more on wikipedia</link>

For those there is no article on wikipedia then no wiki link will be displayed for those words.

Can you guyz please suggest me some opensource PHP script or package which will do this for me, or suggest me some ideas about how to do this in PHP.

I am more interested in getting data from some other website directly instead of storing word definitions in my database.

I am using PHP - MYSQL

+2  A: 

Hello,

this will include a learning courve, but I would try "MySite with Wikipedia" - http://scripsi.mirrors.phpclasses.org/browse/package/2647.html

Augenfeind
+10  A: 

Explode user's sanitized input into single words by using explode() function and then use Wikipedia API (see api.php) to get definitions or wiki links.
There should be other web services apart from Wikipedia which is providing API access, just Google them. Also this could be a good guide if you want to make it in Javascript.

As a whole, A well-formed API is not language-dependent. Usually it's XML or JSON (see API Data formats, serialized PHP included), for the XML case you can use the native PHP SimpleXML (Guide here) or SimplePie library. just get & parse!

Sepehr Lajevardi
This is only available for .NET, I need it for PHP :(
Prashant
currently only help for C# on that page, not for php.
Natrium
link is now corrected.
Sepehr Lajevardi
+6  A: 

I would suggest you use definition of the selected words fro Google Define. when you type define:beans, you would get a definition list of the word from google. This google search results come from various sources, but the first one is mostly correct.

You need to use Google Search API to search for this word, parse the XML and show the first result to the user.

You can use Google Search API from this tutorial

Quoting from the Google Search API Documentation

The Google AJAX Search API is a Javascript library that allows you to embed Google Search in your web pages and other web applications. For Flash, and other Non-Javascript environments, the API exposes a raw RESTful interface that returns JSON encoded results that are easily processed by most languages and runtimes.


Example: define:cow to Google Search API would return back a lot of definitions. Get the first element of the search result, parse it and show it next to the word.

Manish Sinha
Yes @Manish, this will be good because google has definitions of almost all words. Let me try it out will let you know if it works....
Prashant
Yes. That is why am saying to use Google. Secondly when you done, please tell me whether it works or not. Of all Google APIs I have used, Search one was always left out.
Manish Sinha
Hi @Manish: I tried but `define:computer` query with `define` word is not working and not returning any results. I have checked this in there sample examples. Go to http://www.google.com/uds/samples/apidocs/tabbed.html and search `define:computer` and the click on web tab, its not giving any results. I think google not provided support for searching definitions from its search API
Prashant
There was a SOAP Search API(http://code.google.com/apis/soapsearch/reference.html) which is not longer available. Google retired it. I was checking out this Developer Guide( http://code.google.com/apis/ajaxsearch/documentation/#fonje ) for Google AJAX Search API. Check whether it works
Manish Sinha