php mysql - spelling conversion? - php

I need to change UK spelling to US spelling for the content stored in the database(mysql). Is there any way to do this on the db itself? I found various software's(like a word add-ins) but to use these I need to have the data in a doc format, do the changes and export it back to mysql. Please let me know if there is a method using php/mysql to change the spellings. Checked out things like pspell and other classes(found through google search) but they do not these conversion of uk to us.
regards

I'm fairly sure there's no possibility to do this in mySQL - it is a task that definitely should not be performed by the DBMS.
If no PHP based solution comes up, there are lists like the one from the spelling society that may allow for automatic conversion to some degree - they even come with variations like
cudgel +led, +ling > cudgel +ed, +ing
it is far from complete, though.
May I ask what you need this for?

Related

J-locate on joomla platform

I created an external link for J-locate plugin for Joomla that would help show a certain locations I need on the map since there is no way to set a default location through the plugin. It goes something like this: view=jlocate&state=nc&zip=27604&radius=10
I am trying to figure out a way to get rid of the state filter so it doesn't restrict the zipcodes closest location by the states. Is it possible to put multiple states in the external link I made? It would be nice if it works so it filters through all states, i tried putting something like the following: view=jlocate&state=nc&ca&fl&zip=27604&radius=10 so it would go through multiple states but it only selects the first one, so if the zipcode is not in NC, it wouldn't find it.
My goal is to make the map available so anyone can search all states by the zipcode field alone without putting in a state. This will resolve a border line locations that i am facing right now due to the fact that its filtering states.
Thank you in advance for any positive help.
here is the link to the plugin i am using: http://joomlavida.com/jlocate-joomla-store-locator-demo?zip=33761&state=FL
It really depends on the component.
The correct way to pass a list could be an array
&state[]=nc&state[]=va&state[]=nj
but since you want to do without, why not omit it? If it's forced somewhere beyond your control you could still unset() it.
Otherwise in the unlikely scenario that the programmer is not doing server-side sql injection filtering, pass
&state=%
where % is the wildcard for SQL.

How to save a file to MySQL BLOB using PHP?

I'm trying to make a chat history system. So every time a person says hi to one another, they can also say something else. And each of those hi's, i wan't to add what they wrote into a history html file. Being something like this:
James Said: Hi Richard, i saw that hardware you told me about, it is compatible with our software!.
At: 23 November 2011 - 23:09 UTC-08.
________________________________________________________________________________________
Richard Said: Nice!! let's start working with it this week, the project has to be finished before the end of the world.
At: 24 November 2011 - 09:23 UTC-08.
________________________________________________________________________________________
The html file i can build with php, but how do i save it to a MySQL BLOB? Without storing it in a directory (directly to the BLOB).
You're approach to this problem isn't really a good one.
If you try to store the data in a particular output format then you're in real trouble if you suddenly find you need the data in a different format.
You're much better off just storing the particulars of the conversation, and then generating the output to display from the stored conversation. That way you can easily present it in all kinds of formats you might need it in.
EDIT TO ADD:
Something else I should have mentioned (but forgot thanks to all the Christmas brandy ;) ), trying to store the conversation data in a single big block of data will negate most of the advantages using a relational database can confer in the first place. You couldn't, for example, easily store the timestamp of each line of the conversation, or search the database for particular items in the conversation. You could find workarounds of course, but given databases are already designed to solve those kinds of problems anyway, you'd just be wasting effort and your solution wouldn't measure up to what the database already provides.
Since it is not really a binary (the B in Blob), but HTML, I suggest you use the MEDIUMTEXT type and deal with it as just a normal text field.

is there an api for word meaning or dicitonary?

I have an app that checks the spelling entered by the user. What i am trying to do is when user corrects there spelling it shows them the complete meaning of the word. Is there any free api i can use to do this? With no limitations?
Also i tried finding a dictionary with meaning that i can upload to my server which will have over 200k words and all the meanings in it. But i am unable to find any. Have anyone here used a dictionary like this that you can refer me to?
I looked at this:
English dictionary SQL dump?
but these also dont have meanings with them
How about exporting the data from Wiktionary? You could write a script to automatically export the entries you need (maybe based on some wordlist). See http://en.wiktionary.org/wiki/Special:Export

Form: let user select their country (drop-down) and get the currency (php)

Currently I'm writing a short survey (html form) using php, mysql and jquery. I want the user to select their country from a drop-down list and then get the right currency (server side) so later on I can ask things referring to the right currency.
I really don't got a clear view on how to achieve this. I know I can find an up to date country list from: http://www.iso.org/iso/country_codes/iso_3166_code_lists.htm
I could make into a php array but then?
http://snipplr.com/view/36437/php-country-code--to-html-currency-symbol-list/
Seems nice code, but I like to use something that is up to date.
Its no problem for me to use a mysql database, but it is a problem to install plug-ins/expansions (hosting won't allow it).
Does somebody knows a good (and maybe easy) way to achieve this?
You can use CURL or file_get_contents() to read the content from the URL and is always updated.
Not answering your question, but:
As of PHP5.3 the intl became a default. It contains NumberFormatter::formatCurrency() that does what your linked country_currency() is trying to do - only properly. If PHP5.3 is a viable minimum requirement (seeing that 5.2 is deprecated and not supported anymore) - use the intl functions.
With Locale::acceptFromHttp() you can check the browser's request headers to preselect the best matching locale.
Your ISO CountryCode list should still be helpful for a manual <select> on a certain level. But keep in mind that it's not quite accurate: Germany translates to de, which may not be specific enough seeing de_AT, de_CH, de_DE. Each of them may present Currency differently. €1,123.23, 1 123,23 €, and so on. You'll still need to know which currency you're processing, though. So you need the list of ISO country codes AND the map of countrycode to currency.
PHP Intl's NumberFormatter accepts English as a language for any country. So just use en_ plus your country code.
echo (new NumberFormatter('en_DE', NumberFormatter::CURRENCY))
->getTextAttribute(NumberFormatter::CURRENCY_CODE); // EUR
echo (new NumberFormatter('en_RS', NumberFormatter::CURRENCY))
->getTextAttribute(NumberFormatter::CURRENCY_CODE); // RSD

how to parse google-style search syntax

I would like to be able to enter search strings in my web application (php) similar to google's style, for example:
frank
frank -jones
created:2010-5-1...2011-6-3 deleted:false
From this I would like a php data structure from which i can build an sql query. The first would search my contact table for "full_name like %frank%". The second would search it for "full_name like %frank% and not like %jones%", the third would search for "created between 2010-5-1 and 2011-6-3 and deleted=0"
i believe what i need is a context-free grammer parser. Is there a good one for PHP?
Thanks!
Would it not be better to load the table result on the first search in an array then base if off of that using AJAX?
It may not be, but google got the hosting power to do what they want, depending on your hosting and your usage of DB calls it may not result in the same way you think it will do.
Just a thought.
gee, don't everyone rush in at once...
the answer is: "hey, why don't you look at the source code for Lucene's Query Parser? Because it does exactly what you are looking for. In fact, you should just use Lucene, as it's probably going to be easier."

Categories