Help Center » Discuss

Discussions on Help Center

Filtersonly show threads also posted in:

  1.  

    Grabbing Images

    1. 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...)


    Discussion is posted in:

    Think this discussion also relates to something else? Cross-post it by adding a new discussion area:

  2.  

    to get (image) statistics

    1. 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! 

      1. 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.

      2. 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.

      3. 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.
      4. 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.
      5. 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)
        650326 have one img
        63058 have two imgs
        2296 have three imgs
        328 have four or more imgs

        Note that more than one topic can be linked to the same image.
      6. 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
              }]
            }]
          }
        }

      7. 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.

      8. 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.
      9. 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?
      10. 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

      11. 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.
      12. Hi parity, minor point: you don't need to send your authentication cookie for doing mqlread (only for mqlwrite).

    Discussion is posted in:

    Think this discussion also relates to something else? Cross-post it by adding a new discussion area:

  3.  

    Batch update data

    also posted to
    1. Is it possible to batch update data in Freebase? Or do I need to program this using the API?  I know that all locations in Belgium are in the CET time zone so instead of adding these manually I could batch update all locations where country is Belgium and set the time zone to CET. Any hints?

      1. The only real "batch update" tool in Freebase is the list importer.  If there were a link from the timezone to "places in this timezone" then you could do "import list" to do what you ask, but since there is no such link, I think you'll probably have to use the API.

    Discussion is posted in:

    Think this discussion also relates to something else? Cross-post it by adding a new discussion area:

  4.  

    Prettier links to Freebase than GUIDs

    1. Hi there...

      I'm trying to use a "prettier" URL in my application than to the Freebase GUID-based one.  Got my hopes up from what I read at http://www.readwriteweb.com/archives/freebase_overview.php

      "Each permanent object in the system has a GUID - a unique identifier, something like this: #9202a8c040000064..... The identifier can be used to refer to the object via URL and via queries. In addition to the GUID, there are other ways to refer to the object, for example, http://www.freebase.com/view/en/leonardo_da_vinci. Beyond that, there are even other aliases, for example, you can refer to a public company by its stock ticker symbol. But regardless of the reference, the key point is that you end up with the same, unique node in the system."

      That sounded good, but... how can you do this, besides typing in the stock symbol as an "alias"?

      I'd imagine it's very common for a domain to have a property which is generally unique within that space.  All things being equal, people would like to see a link with that instead of the GUID.  But to have to type it in twice (once as a property and once as an "alias") seems like the wrong answer..

      There are a lot of cool things in api/* but I haven't found one that would finesse something like this, any pointers?  I'm just trying to get a link that will jump to the Freebase page for the topic...based on, say, the ISBN# of a book.

      1. I think freebase has mimicked wikipedia in populating the "/view/en" (i.e. english language) namespace.  Clearly, there can be only one leonardo_da_vinci, and that's not a problem in many cases. There are probably many topics in freebase that could be reliably identified by their common name in that space but the freebase staff (who control it) haven't caught up.  Perhaps some collaborative feature in this are would be helpful e.g. "suggest a unique name for this topic", "flag this topic as more deserving of 'john_smith' " :)

        your idea of creating other url paths that represent namespaces is fantastic e.g. NYSE stock symbols could be /view/nyse/ge. This could go a long way for providing user readable urls to topics.

        I think freebase.com should consider this a pretty hot feature request; it's not possible now. At least, the company could start creating url/namespaces, but allowing users to create (or at least nominate them) should be considered as well.

      2. Hmmm...

        Well, if I could spec this, I'd like to be able to form an inbound link to Freebase by providing a property name and a value, and simply get a page to view the article from that.  e.g. ("book/book_edition/isbn", "817525766")  If this does not specify a unique article, then come up with a list of all matches.

        It would be trivial for Metaweb to add an API that did this, it's just that once you start putting question marks and such in things it starts to confuse users, e.g.

        http://freebase.com/api/view?property="book/book_edition/isbn"?value="817525766"

        So maybe overloading view (or something otherwise prettier) could be good:

        http://freebase.com/view/book/book_edition/isbn=817525766

        A key goal would be that when you loaded an article this way, you would not be redirected, but rather see that "pretty" URL in the address bar.

        This way pretty links would come from properties of the data, without anyone having to do extra work in disambiguation that hadn't already been done.

      3. We’ve done this for some properties already, like NAICS industry classification, IMDb IDs for actors and films. You can do it yourself in your own namespace; it might be a bit unwieldy (/user/metaeducation/isbn/0817525766) but it would work. If you come up with a good one we could link it into a shorter place (like /authority/isbn).
      4. Really?  This sounds good.  How would I go about doing this?

        As you probably guessed from our discussion in Music, I'm actually trying to link to albums by catalog #.  (Imagine a manufacturer who has several releases of the same album, under different numbers, and would like the links to go to the appropriate Freebase article.  So that's what we're looking for.  A pretty URL with the catalog number in it, instead of GUID, which takes one to the appropriate page to upload cover art or edit the track info.)

        It appears, however, that the albums are not correctly organized right now, since multiple releases of the same album are in Freebase as separate "albums".  I'm worried about how doing the work of properly sorting releases might interfere with synchronizing the data with MusicBrainz... is it better just to let well enough alone?

      5. You can make namespaces, such as /user/metaeducation/labels and /user/metaeducation/labels/capitol, with the query editor. Create an instance of /type/namespace and add a key into the parent namespace.

        {

          "type":"/type/namespace",

          "name":"My Namespace",

          "key":{

            "value":"sample",

            "namespace":"/user/metaeducation"

          },

          "create":"unless_exists"

        }

        will create an instance of Namespace addressable as /user/metaeducation/sample. You can add things to that namespace:

        {

          "id":"/guid/deadbeefcafebabedeadbabecafebeef",

          "key":{

            "value":"why_dead_beef",

            "namespace":"/user/metaeducation/sample",

            "connect":"insert"

          }

        }

        As for uniqueness of albums: the problem is that MusicBrainz only models releases, not actual albums. We attempt to identify releases of the same albums, but we inevitably miss some as it is an automated process. Duplicate albums should be marked for merge. 

      6. Bear in mind also that ids must be unique within a namespace. If catalog numbers are all unique, this isn't a problem. But if they're only unique per label, this might be enormously cumbersome. If I'm reading you right, Chris, I'm seeing a one-namespace-per-label model, which, while theoretically do-able, seems like a vast undertaking.


    Discussion is posted in:

    Think this discussion also relates to something else? Cross-post it by adding a new discussion area:

  5.  

    How do I save a view?

    also posted to
    1. 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

      1. Replied to related post in the Computers domain.
      2. 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.

    Discussion is posted in:

    Think this discussion also relates to something else? Cross-post it by adding a new discussion area:

  6.  

    create Post request in .net

    1. Hi,

      This is my first time I'm working with FreeBase,

      and I'm trying to create WebRequest (Post method) to login/mqlread by vb.net or c#.

      Can anyone send me a code example that doing this?

      Tx, all.


    Discussion is posted in:

    Think this discussion also relates to something else? Cross-post it by adding a new discussion area:

  7.  

    Queries Confusing Me...

    1. Hi Guys,

      I'm trying to do what I think is a basic query but I can't get my head around how to do this using MQL.

      Basically I want to get a list of all games on the Xbox 360 - I've managed this so far:


      {

      "query":{

      "games":[],

      "name":"Xbox 360",

      "type":"/cvg/cvg_platform"

      }

      }



      Now this returns 2 results, nothing like I was expecting. Anyone know what I am doing wrong?

      Cheers,
      Chris

      1. Chris, the platform schema shows that the “Games” property is hidden and deprecated; what you want is the “Games On This Platform” property (games_on_this_platform) instead. Keep in mind that that property points to a compound value type, so you will then need to ask for the game property of that.

        {
        "query":{
        "games_on_this_platform":[{
        "game":null
        }],
        "name":"Xbox 360",
        "type":"/cvg/cvg_platform"
        }
        }

      2. Thanks for the reply. I do have a suggestion/question though for the site in general. Why not show, on the site, the query used to generate the data on the page?

         For example, this page: http://www.freebase.com/view/reorder/topic/en/xbox_360?propertyId=%2Fcvg%2Fcvg_platform%2Fgames_on_this_platform&returnUrl=http%3A%2F%2Fwww.freebase.com%2Fview%2Fxbox_360

        It would be good to see the query used to generate all of those results and would make it easier for people to get to grips with it. 

      3. I agree with the last statement.  I was wondering exactly the same thing.

        "Why not show, on the site, the query used to generate the data on the page?"

      4. Actually, you can get the queries for most things! Take a look at this page: http://tinyurl.com/6h28kt -- that's a list of computer games where I've added the "platform" column then filtered on "Xbox 360".

        Then click on "Use Results" and then "See the query".

        That gives you a MQL query you can use in your own apps or wherever.


    Discussion is posted in:

    Think this discussion also relates to something else? Cross-post it by adding a new discussion area:

  8.  

    See my history?

    1. Is there a way to see my entire activty history?  I added some stuff yesterday with the plan to go back and fill in data, but now I'm not sure if I remembered all that I added :)  And the history in my user account doesn't go back far enough (not even the expanded view). 

      Is there a way to see this kind of info?   

      1. Hmmm, seems like you may have stumbled on to a regression. I'll file an internal bug, but in the meantime, you can try this URL: http://dev.mqlx.com/~nick/reports/userdetail.html?user=%2Fuser%2Fevening

        Thanks for reporting this!

      2. I've been told that this has been fixed in the upcoming release.