Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8847351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:10:14+00:00 2026-06-14T12:10:14+00:00

I’m an absolute beginner in MQL trying to access Freebase by ken-rb in this

  • 0

I’m an absolute beginner in MQL trying to access Freebase by ken-rb in this way:

[1] pry(main)> res = Ken.get("/en/allium_neapolitanum")
=> #<Resource id="/en/allium_neapolitanum" name="Allium neapolitanum">

I noticed the query submitted via freebase API:

{"guid":null,"name":null,"ken:type":[
  {"id":null,"name":null,"properties":[
    {"id":null,
     "name":null,
     "expected_type":null,
     "unique":null,
     "reverse_property":null,
     "master_property":null}]}],
 "/type/reflect/any_master":[
   {"id":null,
    "link":null,
    "name":null,
    "optional":true,
    "limit":999999}],
 "/type/reflect/any_reverse":[
   {"id":null,
    "link":null,
    "name":null,
    "optional":true,
    "limit":999999}],
 "/type/reflect/any_value":[
   {"link":null,
    "value":null,
    "optional":true,
    "limit":999999}],
 "id":"/en/allium_neapolitanum"}

fiddling with this MQL in the query editor I found a way to get simply a list of common names for my resource:

[2]pry(#<Ken::Resource>):2> data["/type/reflect/any_value"].map { |h| h }
=> [{"link"=>"/type/object/name", "value"=>"Allium neapolitanum"},
 {"link"=>"/type/object/name", "value"=>"שום משולש"},
 {"link"=>"/type/object/name", "value"=>"Ail blanc"},
 {"link"=>"/biology/organism_classification/scientific_name",
  "value"=>"Allium neapolitanum"},
 {"link"=>"/type/object/name", "value"=>"Neapolitanischer Lauch"}]

[3] pry(#<Ken::Resource>):2> names = data["/type/reflect/any_value"].select { |h| h["link"]=="/type/object/name"}
=> [{"link"=>"/type/object/name", "value"=>"Allium neapolitanum"},
 {"link"=>"/type/object/name", "value"=>"שום משולש"},
 {"link"=>"/type/object/name", "value"=>"Ail blanc"},
 {"link"=>"/type/object/name", "value"=>"Neapolitanischer Lauch"}]

[4] pry(#<Ken::Resource>):2> names.map { |name| name["value"] }
=> ["Allium neapolitanum", "שום משולש", "Ail blanc", "Neapolitanischer Lauch"]

The problem is: I need to know which language (I means an attribute such as: “lang: ‘/lang/fr'”) is related to each common name.

There is a chance, using Ken or by changing the MQL query / submit others queries / etc. , to also have what is the language of each “/type/object/name”?

[EDIT]

I found a possible approach to the solution, however, my goal would be to get the data directly modifying the original query originated by ken-rb ( .. copied to the top of the question )

The MQL could be:

[{
  "name": [{
    "lang": null,
    "value": null
  }]
  "id": "/en/allium_neapolitanum"
}]​

give this result

  "result": [{
    "id": "/en/allium_neapolitanum",
    "name": [
      {
        "lang":  "/lang/en",
        "value": "Allium neapolitanum"
      },
      {
        "lang":  "/lang/he",
        "value": "שום משולש"
      },
      {
        "lang":  "/lang/fr",
        "value": "Ail blanc"
      },
      {
        "lang":  "/lang/de",
        "value": "Neapolitanischer Lauch"
      }
    ]
  }]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:10:15+00:00Added an answer on June 14, 2026 at 12:10 pm

    According to the documentation Ken supports Ken.mqlread() in addition to Ken.get(), so you could use that with the MQL query that you worked out.

    Having said that, I would argue that a) it’s a bug that they query multiple languages without returning the language info and b) you might not want to use Ken anyway since it appears to still be using the old freebase.com API which is deprecated and about to be turned off. The new googleapis.com/freebase APIs are documented here. The MQL syntax is unchanged, but you’ll need an API key and need to use the new endpoint.

    If you want to fix Ken to return the language with the text value, you can modify the any_value portion of the query to look like this:

    {
      "/type/reflect/any_value": [{
        "*":     null,
        "link": {
          "master_property": null,
          "target": {
            "id":       null,
            "optional": true
          }
        },
        "limit": 99999
      }],
      "id":   "/en/allium_neapolitanum"
    }​
    

    I think you should also be able to use just

    {
      "/type/reflect/any_value": [{}],
      "id":   "/en/allium_neapolitanum"
    }​
    

    but that gives you the language and value, but no link, so you can’t tell what property the value is associated with (not very useful).

    Note that you can drop the top level name property from your query since it’s technically redundant. If you want to keep it for simpler access to the name, you could consider changing it from "name":null to "name":[{}] which will give you the name in all languages (all this information is also available in the /reflect/any_value) portion of the query.

    Finally, I feel compelled to point out that querying all values of all properties is going to be more expensive and slower than necessary in almost all cases since one normally is only interested in a few key bits of info. It’s find for a general purpose browser/explorer/debugger, but huge overkill for almost everything else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to render a haml file in a javascript response like so:
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.