Scripts tagged with freebase

1-10 of 25.

form validation and completion with mqlread

to javascript freebase by nando.quintana , 1 comments

1 2 3 4 5 ...
/**
 * Add an onchange event handler to the specified textfield object
 * to validate the user's input and autocomplete it if necessary.
 * The type argument is the Metaweb type, such as "/music/artist"
 * for which autocompletion should be done.

using Metaweb.addValidationAndCompletion()

to xhtml freebase by nando.quintana , 0 comments

1 2 3 4 5 ...
<script src="json.js"></script>
<script src="metaweb.js"></script>
<script src="validateAndComplete.js"></script>
<script>
window.onload = function() {

a trivial mqlread proxy in PHP

to php freebase by nando.quintana , 1 comments

1 2 3 4 5 ...
<?php
$q = str_replace("\\\"", "\"", $_GET["queries"]);
$url = "http://www.freebase.com/api/service/mqlread?queries=" . urlencode($q);
$request = curl_init($url);
curl_setopt($request, CURLOPT_COOKIE, "###freebase.com cookie data here###");

Metaweb queries through a proxy

to javascript freebase by nando.quintana , 0 comments

1 2 3 4 5 ...
/**
 * metaweb_proxy.js: 
 *
 * This file implements a Metaweb.read() utility function using XMLHttpRequest
 * and a server-side proxy script named mqlread.php

JSON parsing and serialization in JavaScript

to javascript freebase by nando.quintana , 4 comments

1 2 3 4 5 ...
/**
 * json.js:
 * This file defines functions JSON.parse() and JSON.serialize()
 * for decoding and encoding JavaScript objects and arrays from and to
 * application/json format.

unlinking Metaweb objects

to python freebase by nando.quintana , 0 comments

1 2 4 5 7 ...
import sys, getopt    # Command-line parsing
import metaweb        # login, read, and write utilities
# A cache that maps type ids to arrays of property information
typecache = {}
# Primitive types other than /type/text and /type/key, which are

uploading HTML documents to Metaweb

to python freebase by nando.quintana , 0 comments

1 3 4 5 6 ...
import sys, re, metaweb
# Read the content of the file specified on the command line
# It must be an HTML file with a <title>
filename = sys.argv[1]
try:

uploading images to Metaweb

to python freebase by nando.quintana , 0 comments

1 2 4 5 7 ...
import metaweb             # Our metaweb utilities
import urllib2             # For downloading images from the mint server
USERNAME = 'username'      # Put your Freebase username and password here
PASSWORD = 'password'
# The ID for our US State Quarter type depends on our username

uploading content to Metaweb

to python freebase by nando.quintana , 0 comments

1 2 4 5 7 ...
import urllib2       # Higher-level URL content fetching
import simplejson    # JSON serialization and parsing
host = 'sandbox.freebase.com'           # The Metaweb host
uploadservice = '/api/service/upload'   # Path to upload service
# Upload the specified content (and give it the specified type).

writing a data set to Metaweb

to python freebase by nando.quintana , 0 comments

1 3 4 6 7 ...
import metaweb         # Use the metaweb module
USERNAME = 'username'  # Put your Freebase username and password here
PASSWORD = 'password'
# The ID for our US State Quarter type depends on our username
TYPEID = '/user/' + USERNAME + '/default_domain/us_state_quarter'