I want to use the Google translation from a server side.
My Ideas are 1. run javascript on a server or 2. Direct http call to Google from server with PHP.
RESULT:
I selected "#2 Direct http call".
DETAIL:
1. run javascript on a server
I found "V8 JavaScript Engine".
"V8 JavaScript Engine" is a very good Engine,
but for me, it will take much time to make goolge objects in the V8.
How to install memo.
DOWNLOAD scons-2.0.1.tar.gz
# tar xzf scons-2.0.1.tar.gz
# cd scons-2.0.1
# python setup.py install --prefix=$HOME
# svn co http://google..... V8
# tar xzf scons-2.0.1.tar.gz
# cd v8
# scon
# cd samples
# g++ -I../include shell.cc -o shellv8 ../libv8.a -lpthread -m32
Test run javascript.
#./shellv8 test.js
test.js is:
print ('Hello' + ', World');
var x = 100;
var y = 200;
print ("x * y = " + (x * y));
Some objects, window and google, not implemented in shell.
It will take much time to make these objects.
2. Direct http call to Google from server PHP.
I re-read "Google Translate API Version 2".
it's is in Labs, but it has REST API.
REST is "Representational State Transfer".
like.
https://www.googleapis.com/language/translate/v2?key=AIzaSdkdN4TfYc0&q=flowers&source=en&target=fr&callback=handleResponse&prettyprint=true
Jan 28, 2011
Jan 5, 2011
How to quickly, randomly select and sort using MySQL?
(ENGLISH)
How to quickly, randomly select and sort a specified number of records from a table under some conditions using MySQL?
I think that it is very difficult.
My solution has an almost randomness.
Here, "much_more_number" is about twice or greater than "specified_number".
SQL likes...
"SELECT * (SELECT *, RAND() as random FROM (SELECT * FROM table WHERE conditions LIMIT much_more_number) as x ORDER random LIMIT specified_number) as y ORDER sort_conditions"
(JAPANESE)
MySQLを用いて、一定の検索条件に該当するレコードを指定された数だけランダムに抽出しそれをソートすることを高速に行う方法とは、
これを実現することはとても難しいと思われる。
私の解答は、まあまたランダムというものです。
ここで、"much_more_number"というのは、"specified_number"の二倍とかもっと大きな数です。
SQLは、こんな感じです。
"SELECT * (SELECT *, RAND() as random FROM (SELECT * FROM table WHERE conditions LIMIT much_more_number) as x ORDER random LIMIT specified_number) as y ORDER sort_conditions"
How to quickly, randomly select and sort a specified number of records from a table under some conditions using MySQL?
I think that it is very difficult.
My solution has an almost randomness.
Here, "much_more_number" is about twice or greater than "specified_number".
SQL likes...
"SELECT * (SELECT *, RAND() as random FROM (SELECT * FROM table WHERE conditions LIMIT much_more_number) as x ORDER random LIMIT specified_number) as y ORDER sort_conditions"
(JAPANESE)
MySQLを用いて、一定の検索条件に該当するレコードを指定された数だけランダムに抽出しそれをソートすることを高速に行う方法とは、
これを実現することはとても難しいと思われる。
私の解答は、まあまたランダムというものです。
ここで、"much_more_number"というのは、"specified_number"の二倍とかもっと大きな数です。
SQLは、こんな感じです。
"SELECT * (SELECT *, RAND() as random FROM (SELECT * FROM table WHERE conditions LIMIT much_more_number) as x ORDER random LIMIT specified_number) as y ORDER sort_conditions"
Subscribe to:
Posts (Atom)