Skip to content

Instantly share code, notes, and snippets.

@giltotherescue
Created May 22, 2012 21:59
Show Gist options
  • Save giltotherescue/2771904 to your computer and use it in GitHub Desktop.
Save giltotherescue/2771904 to your computer and use it in GitHub Desktop.
Search freebase
<?
$nouns = array(
'/film/film' =>
array(
'possessives' => array('directed_by', 'starring')
'adjectives' => array('genre')
),
'/music/album' => array(...)
);
$file = "/film/film";
$query = "The Departed";
foreach (file($file . '.tsv') as $num => $line) {
if ($num === 0) {
$headers = explode("\t", $line);
}
if (preg_match('#\t' . $query . '\t#', $line)) {
$parts = explode("\t", $line);
foreach ($parts as $k => $v) {
print $headers[$k] . ": " . $v . "\n";
}
break;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment