Discussions on Help Center
Filtersonly show threads also posted in:
-
-
-
looking for a way to query freebase through vbs or VB.
I want to get the results as a stringthnx,
Jur
-
I'm not too familiar with VBS or VB, but you'll need an API that can communicate using HTTP. A quick Google search turned up at least 1 such API. You can then use the freebase /api/service/mqlread API to query. The query is returned in JSON format; you can parse the response yourself, or maybe there's a VB JSON API that you can use. Good luck!
-
thanx a lot. I will try that
-
-
-
I've created a type: http://www.freebase.com/type/view/user/mlevison/agile_software_development/functional_test_tools and wish to change the properties that visitors will see in the default case (i.e no image, etc). How can I achieve that?
The whole goal of this is to build a repository of "Functional test tools" that users can quickly scan to figure out which tool they need.
As it stands the default view is of no interest.
Confused in Ottawa
-
Replied to related post in the Computers domain.
-
You can't actually save a view, per se -- you can only save a filter. E.g., if you filtered the view of your type for Domain Specific Language = "yes", you could save that. However, there is currently a work-around (although I doubt this was intentional and I can't promise that it will be around forever) -- if you click the "filter results" button, a field labeled "save view as" will appear; you can enter a name and save the view without actually running a filter. The saved view will then appear on your homepage (I think), and will have a stable URL.
-
For what it's worth, I believe this is the intended functionality, and that you *should* be able to save a view even if you haven't filtered. They just hid the "save as" thing back there because of screen real estate concerns.
-
-
-
Hey,
Simple and possibly stupid question... just wondering about grabbing images from entries in Freebase. I couldn't find any examples in the API documentation, but most articles now tend to have either a user-uploaded thumbnail, or a scrape of the equivalent Wikipedia article's image.
So does anyone have experience pulling images into your own apps and/or have an example of how to do so?
(Sorry if this has been answered before but I couldn't find anything...)
-
Check out the Metaweb Application Reference Guide and follow the link to §4.8, “Fetching Content with trans” in the Metaweb Read Services chapter.
-
I recently did this, and also, just fixed a bug in my program this morning. The bug happened because the code I copied from did not gracefully handle cases of multiple images. (Alas, I'm really just gluing together things without a lot of "understanding" and so these kinds of problems are happening to me a lot!)
Maybe this will help:
var query = { // This is our MQL query
type: "/music/artist", // Find a band
name: bandName, // With the specified name
id: null, // Fetch the ID of the band to link to their Freebase page
album: [{ // We want to know about albums
"/common/topic/image" : [{ // the images list on the album
"id" : null, // each image has an ID
"optional" : true // don't require an image to return a result
}]
};Once your query comes back, you should have a list of 0 or more images in the "/common/topic/image" field. Each image will have an ID. You can then pass that ID to Freebase's thumbnail API to generate a version of that image at any size you like:
http://www.freebase.com/view/guid/9202a8c04000641f8000000006cf560a
I'm not quite sure
-
At first glance, that query looks correct. You can test it out by throwing it into the queryeditor and testing it out.
-
Ooops, the "I'm not quite sure" was an accident, must have been scrolled off the bottom. I'm sure that's the query. :)
What I wasn't exactly sure about was how to get the dimensions of the original image, but I'm sure it's in there somewhere!!
-
/api/trans/image_thumb can return you the image in a specified height/width, but won't tell you anything about the original size. In your query, you can ask for the /common/image/size, which is a CVT that has the x/y sizes.
-
-
-
It's my understanding that every article has a GUID. But how do you find out that GUID if you are browsing and an article has a textual ID?
It would be nice if there was a button you could push to say "give me this article's GUID which will survive any renaming". Perhaps I'm just being daft, but I can't find this button in the interface. I even viewed source of the article to see if it was somewhere in there... but couldn't find anything.
Is there a way to do this?
-
It's not entirely obvious on the website, but you can get it easily through the API (just ask for the guid instead of id) or by using our developer toolbar. Click on the explore link and you should see it there.
-
A couple of further notes. First, don’t confuse the topic with the article. I am not sure if you are, or if it is just a terminological confusion; For example, the topic for Freebase has an article associated, which is a discrete object.
The non-GUID ID, when available, should be more useful in the long term than the GUID is. If two topics merge, either GUID may be the survivor, but IDs for either will still work.
All that said, the Explore view in the dev toolbar that Kirrily describes is pretty much the fastest way to find a GUID for a topic or its article (look for the /common/topic/article property in that view).
-
-
-
Hey all,
I have the following query to pull back 10 movies with the latest release dates:
[
{
"directed_by" : [
{}
],
"id" : null,
"initial_release_date" : null,
"limit" : 10,
"name" : null,
"sort" : "-initial_release_date",
"timestamp" : null,
"type" : "/film/film"
}
]The problem is thatit is pulling back films with null release dates, and on sort, I get those first.
Is there a way that I can specify that only non-null entries be returned; i.e. all films with a non-null release date?
Thanks for the assist
-
Hi mjs, try expanding initial_release_date and using optional:false
[
{
"directed_by" : [
{}
],
"id" : null,
"initial_release_date" : {
"optional" : false,
"value" : null
},
"limit" : 10,
"name" : null,
"sort" : "-initial_release_date.value",
"timestamp" : null,
"type" : "/film/film"
}
] -
That worked a treat; thanks for the help!
-
-
-
I want to have some basic statistics of images, e.g. how many images there are in freebase, how many objects or topics have images. Now my query is like:
{"type":"/common/image",
"id":null,
"limit":10000
}
and then parse result to see how many are returned. Then I change "limit" and see when it breaks. I wonder if there's any more systematic way of doing this? Thanks!
-
The result times out because there is a large amount of /common/image topics. Usually, the way to request counts is:
{
"id" : null,
"return" : "count",
"type" : "/common/image"
}But this will still time out on requests with a large amount of topics. You could query for the instance count which is tallied nightly:
{
"/freebase/type_profile/instance_count" : null,
"id" : "/common/image"
}but that isn't real-time.
Lastly, you could count yourself by using a cursor and counting until the end of the result set:
{
"cursor": true,
"query": [{
"id" : null,
"type" : "/common/image"
}]
}To find topics that have an image, you can query for them like so:
[
{
"id" : null,
"image" : [
{
"id" : null
}
],
"type" : "/common/topic"
}
]Again, the resultset is very large and will time out, so you will need to cursor and count yourself.
-
Thanks, that's really helpful!
Now if i'm not mistaken there're about 700K images and 330K topics with image. Does that imply that on average those topics with images each has 2 images? Thanks.
-
No, not necessarily - a /common/image topic may not be linked to a /common/topic topic (for whatever reason). You could use the last query to find out how many images each /common/topic topic has by counting the ids in the "image" clause.
-
Thank you. Then if a /common/image object is not linked to any /common/topic object, why is it there and how can it be presented to end users? Thanks.
-
You can just break the link between an image and a topic and not have the image deleted. Just for fun, I ran a quick analysis:
Found 716008 /common/topic topics with image links (out of ~4 million topics)
Note that more than one topic can be linked to the same image.
650326 have one img
63058 have two imgs
2296 have three imgs
328 have four or more imgs -
Thank you. It seems I don't know enough of MQL language; let me know if there's reference other than this website for I don't want to bother you like this.
I use the following code embedded in a perl code to count the number of topics with at least one image, and the result is about 438K--much lower than yours. By the way how to get the number of topics with exactly 1, 2, or 3 images? Can this be requested directly in the query?
{
"qname":{
"cursor":<cursor value>"query":[{
"id":null,
"limit":1000,
"type":"/common/topic",
"image":[{
"id":null
}]
}]
}
} -
Some MQL reference material can be found here. I iterated through topics with images and then recorded the number of links there were. Currently, you can't constrain the query to ask it to return topics with exactly n amount of images. I'm not sure why your results differ so greatly that mine - I'll try to investigate a little more.
-
Thanks. I counted the number of iteration for the code above and multiply it by 1000 (since I set the limit 1000) to get approximate image count.
-
Well, I got essentially the same results as reported above using metaweb.py. Are you using your own Perl module, or one from our API library?
-
The following is the code I used. Have a look only if you're free. I print out $count to see number of topics with images and $count~438
Afterwards I grep entire query result and got numbers close to you:
692001 topics with image
626805 topics with 1 image
62827 topics with 2 images
2210 topcis with 3 images
and so on...
#!/usr/bin/perl
use URI::Escape;
# This module provides the uri_escape function used below
# Build the Metaweb query, using string manipulation
# CAUTION: the use of string manipulation here makes this script vulnerable
# to MQL injection attacks when the command-line argument includes JSON.
#$band = $ARGV[0]; # This is the band or musician whose albums are to be listed
my $cursor = 'true';
my $query;
my $pre =
'{
"qname":{
"cursor":';
my $post = ',
"query":[{
"id":null,
"limit":1000,
"type":"/common/topic",
"image":[{
"return":"count",
"id":null
}]
}]
}
}';
my $allresult = '';
my $count = 0;
my $result = '';
until($cursor =~ /error/){
#while($cursor){
$query = $pre . $cursor . $post;
$escaped = uri_escape($query);
$baseurl='http://www.freebase.com/api/service/mqlread'; # Base URL for queries
$url = $baseurl . "?queries=" . $escaped;
$auth = 'metaweb-user=###Enter Your cookie data here###';
#$result = `curl -s --cookie \'$auth\' $url`;
$result = `curl -s $url`;
$result =~ /\/api\/status\/(.*)/;
$status = $1;
$result =~ /cursor\":\s*(\".*\")/;
$cursor = $1;
$count = $count + 1;
print $result . "\n";
}
# Use regular expressions to extract the album list from the HTTP response
#$result =~ s/^.*"album"\s*:\s*\[\s*([^\]]*)\].*$/$1/s;
#$result =~ s/[ \t]*"[ \t,]*//g;
#print $allresult ."\n";
print 'done'."\n";
# Finally, display the list of albums
#print "$result\n";
#
# vim: ts=2 sw=2 -
I suspect /api/service/mqlread is returning a timeout or error. My Perl is rusty, but the until loop doesn't look like it's checking for a 200 OK return response; it just looks like if you don't find a cursor, you assume the counting is complete and exit.
-
Hi parity, minor point: you don't need to send your authentication cookie for doing mqlread (only for mqlwrite).
-
