Allow specification of a Google API key.
This commit is contained in:
parent
50888c6f2e
commit
fef773bae0
@ -124,8 +124,6 @@ public class GuidBasedReconConfig extends StrictReconConfig {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
JSONWriter jsonWriter = new JSONWriter(stringWriter);
|
||||
|
||||
jsonWriter.object();
|
||||
jsonWriter.key("query");
|
||||
jsonWriter.array();
|
||||
jsonWriter.object();
|
||||
|
||||
@ -143,14 +141,13 @@ public class GuidBasedReconConfig extends StrictReconConfig {
|
||||
|
||||
jsonWriter.endObject();
|
||||
jsonWriter.endArray();
|
||||
jsonWriter.endObject();
|
||||
|
||||
query = stringWriter.toString();
|
||||
}
|
||||
|
||||
StringBuffer sb = new StringBuffer(1024);
|
||||
sb.append(s_mqlreadService);
|
||||
sb.append("?query=");
|
||||
sb.append(getMqlreadService());
|
||||
sb.append("&query=");
|
||||
sb.append(ParsingUtilities.encode(query));
|
||||
|
||||
URL url = new URL(sb.toString());
|
||||
|
@ -128,8 +128,6 @@ public class IdBasedReconConfig extends StrictReconConfig {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
JSONWriter jsonWriter = new JSONWriter(stringWriter);
|
||||
|
||||
jsonWriter.object();
|
||||
jsonWriter.key("query");
|
||||
jsonWriter.array();
|
||||
jsonWriter.object();
|
||||
|
||||
@ -147,14 +145,13 @@ public class IdBasedReconConfig extends StrictReconConfig {
|
||||
|
||||
jsonWriter.endObject();
|
||||
jsonWriter.endArray();
|
||||
jsonWriter.endObject();
|
||||
|
||||
query = stringWriter.toString();
|
||||
}
|
||||
|
||||
StringBuffer sb = new StringBuffer(1024);
|
||||
sb.append(s_mqlreadService);
|
||||
sb.append("?query=");
|
||||
sb.append(getMqlreadService());
|
||||
sb.append("&query=");
|
||||
sb.append(ParsingUtilities.encode(query));
|
||||
|
||||
URL url = new URL(sb.toString());
|
||||
|
@ -129,8 +129,6 @@ public class KeyBasedReconConfig extends StrictReconConfig {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
JSONWriter jsonWriter = new JSONWriter(stringWriter);
|
||||
|
||||
jsonWriter.object();
|
||||
jsonWriter.key("query");
|
||||
jsonWriter.array();
|
||||
jsonWriter.object();
|
||||
|
||||
@ -161,14 +159,13 @@ public class KeyBasedReconConfig extends StrictReconConfig {
|
||||
|
||||
jsonWriter.endObject();
|
||||
jsonWriter.endArray();
|
||||
jsonWriter.endObject();
|
||||
|
||||
query = stringWriter.toString();
|
||||
}
|
||||
|
||||
StringBuffer sb = new StringBuffer(1024);
|
||||
sb.append(s_mqlreadService);
|
||||
sb.append("?query=");
|
||||
sb.append(getMqlreadService());
|
||||
sb.append("&query=");
|
||||
sb.append(ParsingUtilities.encode(query));
|
||||
|
||||
URL url = new URL(sb.toString());
|
||||
|
@ -40,7 +40,12 @@ import com.google.refine.model.Recon.Judgment;
|
||||
import com.google.refine.model.recon.ReconConfig;
|
||||
|
||||
abstract public class StrictReconConfig extends ReconConfig {
|
||||
final static protected String s_mqlreadService = "http://api.freebase.com/api/service/mqlread";
|
||||
final static private String s_mqlreadService =
|
||||
"https://www.googleapis.com/freebase/v1/mqlread";
|
||||
|
||||
static protected String getMqlreadService() {
|
||||
return s_mqlreadService + "?key=" + System.getProperty("refine.google_api_key");
|
||||
}
|
||||
|
||||
static public ReconConfig reconstruct(JSONObject obj) throws Exception {
|
||||
String match = obj.getString("match");
|
||||
|
7
refine
7
refine
@ -46,6 +46,8 @@ where [options] include:
|
||||
-m <memory> max memory heap size to use
|
||||
default: 1024M
|
||||
|
||||
-k <google api key> a server API key for calling Google APIs
|
||||
|
||||
-v <level> verbosity level [from low to high: error,warn,info,debug,trace]
|
||||
default: info
|
||||
|
||||
@ -665,6 +667,10 @@ run() {
|
||||
add_option "-Drefine.host=$REFINE_HOST"
|
||||
fi
|
||||
|
||||
if [ "$REFINE_GOOGLE_API_KEY" ] ; then
|
||||
add_option "-Drefine.google_api_key=$REFINE_GOOGLE_API_KEY"
|
||||
fi
|
||||
|
||||
CLASSPATH="$REFINE_CLASSES_DIR${SEP}$REFINE_LIB_DIR/*"
|
||||
|
||||
RUN_CMD="$JAVA -cp $CLASSPATH $OPTS com.google.refine.Refine"
|
||||
@ -869,6 +875,7 @@ while [ $# -ne 0 ] ; do
|
||||
-w) shift; REFINE_WEBAPP="$1"; shift; continue;;
|
||||
-d) shift; REFINE_DATA_DIR="$1"; shift; continue;;
|
||||
-m) shift; REFINE_MEMORY="$1"; shift; continue;;
|
||||
-k) shift; REFINE_GOOGLE_API_KEY="$1"; shift; continue;;
|
||||
-v) shift; REFINE_VERBOSITY="$1"; shift; continue;;
|
||||
-x) shift; REFINE_EXTRA_OPTS="$1"; shift; continue;;
|
||||
--debug) shift; add_option '-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n'; continue;;
|
||||
|
Loading…
Reference in New Issue
Block a user