在Java中使用Freebase API [英] Using Freebase API in Java

查看:159
本文介绍了在Java中使用Freebase API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个GWT应用程序来从Freebase获取查询结果。这是我的EntryPoint类的代码。

  package com.google.tracker.client; 

import com.freebase.api.Freebase;
import com.freebase.json.JSON;
import com.google.gwt.core.client.EntryPoint;

public class Tracker实现EntryPoint {

public void onModuleLoad(){
Freebase freebase = Freebase.getFreebase();
字符串query_str ={+
'id':null,+
'type':'/ film / film',+
'na​​me' :'Blade Runner','+
''directed_by':[{+
''id':null,+
'na​​me':null+
}}+
}.replace('\'',''');

JSON query = new JSON(query_str);
JSON结果= freebase.mqlread(query);
@SuppressWarnings(unused)
String director = result.get(result)。get(directed_by)。get(0).get(名字)。string();
}
}

以下错误:

  [错误]第10行:没有源代码可用于com.freebase.api.Freebase类型;您是否忘记继承所需的模块?
[错误]第21行:没有源代码可用于com.freebase.json.JSON类型;您忘记了继承一个必需的模块?

这些可能的原因是什么?

$ b $ Freebase的API包不是GWT模块,因此不能翻译成Javascript。这就是为什么有没有可用的源代码。您需要从服务器拨打Freebase并将结果发送给客户端。


I am developing a GWT application to get the query results from the Freebase. This is the code of my EntryPoint class.

package com.google.tracker.client;

import com.freebase.api.Freebase;
import com.freebase.json.JSON;
import com.google.gwt.core.client.EntryPoint;

public class Tracker implements EntryPoint{

    public void onModuleLoad() {
        Freebase freebase = Freebase.getFreebase();
        String query_str = "{" +
                "'id':   null," +
                "'type': '/film/film'," +
                "'name': 'Blade Runner'," +
                "'directed_by': [{" +
                "'id':   null," +
                "'name': null" +
                "}]" +
                "}​".replace('\'', '"');

        JSON query = new JSON(query_str);
        JSON result = freebase.mqlread(query);
        @SuppressWarnings("unused")
        String director = result.get("result").get("directed_by").get(0).get("name").string();
    }
}

I am getting following errors :

[ERROR] Line 10: No source code is available for type com.freebase.api.Freebase; did you forget to inherit a required module?
[ERROR] Line 21: No source code is available for type com.freebase.json.JSON; did you forget to inherit a required module?

What could be the possible reasons for these?

解决方案

Freebase's API package is not a GWT module and as such can't be translated to Javascript. That's why there's "No source code available". You need to make the call to Freebase from the server and send the results down to the client.

这篇关于在Java中使用Freebase API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆