org.pandora.sense.http
Class Freebase

java.lang.Object
  extended by org.pandora.sense.BasicSense
      extended by org.pandora.sense.http.Http
          extended by org.pandora.sense.http.Freebase
All Implemented Interfaces:
Sense

public class Freebase
extends Http

Process Freebase pages and data. This sense can load data from the Freebase database into Pandora. It uses the Freebase web service to query with MQL for JSON data.


Field Summary
static java.lang.String URL_PREFIX
           
 
Fields inherited from class org.pandora.sense.http.Http
WORKER_THREADS
 
Fields inherited from class org.pandora.sense.BasicSense
DEFAULT_SPEAKER, RETRY
 
Constructor Summary
Freebase()
           
 
Method Summary
 void awake()
          Start sensing.
 boolean discover(Vertex input, Network network, Vertex currentTime)
          Attempt to discover information on the vertex.
 java.util.List<java.lang.Object> extractPropertyValues(java.lang.Object data, java.util.List<java.lang.String> filters, int cascade, Network network, java.util.Map<java.lang.String,Vertex> processed)
          Extract the relevant data from the Freebase property.
 java.util.List<java.lang.String> getTypeFilters()
           
 void input(java.lang.Object input, Network network)
          Get and process the URL.
 void output(Vertex output)
          Post, process the post request.
 Vertex processId(java.lang.String id, int cascade, Network network, java.util.Map<java.lang.String,Vertex> processed)
          Process the object for the Freebase id.
 Vertex processJson(net.sf.json.JSONObject json, int cascade, Network network, java.util.Map<java.lang.String,Vertex> processed)
          Process the JSON object to the cascade level.
 net.sf.json.JSON processQuery(java.lang.String query)
          Process the mql query and convert the result to a JSON object.
 void setTypeFilters(java.util.List<java.lang.String> typeFilters)
           
 
Methods inherited from class org.pandora.sense.http.Http
batchProcessURL, convertToXHTML, findNextTag, findTag, findTag, findTag, getAllBullets, getAllURLBullets, getDomains, getHtmlCleaner, getNextBulletList, getParser, getSentence, getText, input, nextNode, parseURL, parseXHTML, processHeaders, processRoot
 
Methods inherited from class org.pandora.sense.BasicSense
getEmotionalState, getLanguageState, getName, getPandora, getPrimitive, getShortTermMemory, initialize, input, isEnabled, log, log, log, setEmotionalState, setIsEnabled, setLanguageState, setName, setPandora, shutdown, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

URL_PREFIX

public static java.lang.String URL_PREFIX
Constructor Detail

Freebase

public Freebase()
Method Detail

awake

public void awake()
Description copied from class: BasicSense
Start sensing.

Specified by:
awake in interface Sense
Overrides:
awake in class BasicSense

input

public void input(java.lang.Object input,
                  Network network)
           throws java.lang.Exception
Get and process the URL.

Specified by:
input in interface Sense
Overrides:
input in class Http
Throws:
java.lang.Exception

processId

public Vertex processId(java.lang.String id,
                        int cascade,
                        Network network,
                        java.util.Map<java.lang.String,Vertex> processed)
Process the object for the Freebase id.


extractPropertyValues

public java.util.List<java.lang.Object> extractPropertyValues(java.lang.Object data,
                                                              java.util.List<java.lang.String> filters,
                                                              int cascade,
                                                              Network network,
                                                              java.util.Map<java.lang.String,Vertex> processed)
Extract the relevant data from the Freebase property.


processJson

public Vertex processJson(net.sf.json.JSONObject json,
                          int cascade,
                          Network network,
                          java.util.Map<java.lang.String,Vertex> processed)
Process the JSON object to the cascade level.


processQuery

public net.sf.json.JSON processQuery(java.lang.String query)
                              throws java.io.IOException
Process the mql query and convert the result to a JSON object.

Throws:
java.io.IOException

output

public void output(Vertex output)
Post, process the post request.

Specified by:
output in interface Sense
Overrides:
output in class Http

discover

public boolean discover(Vertex input,
                        Network network,
                        Vertex currentTime)
Attempt to discover information on the vertex.


getTypeFilters

public java.util.List<java.lang.String> getTypeFilters()

setTypeFilters

public void setTypeFilters(java.util.List<java.lang.String> typeFilters)