I want to find the ceo of IBM. What would be the MQL query for this?
The MQL for this search looks like the following.
This particular instance may be a tat more complicated than necessary because I got it initially produced from a Freebase interactive search and then simply added/improved the filters manually.
I verified it with various company names with relative success, i.e. it works provided that the underlying data is properly codified in Freebase (some companies are missing, for some companies the leadership data is incomplete etc.)
There are a few tricks to this query:
the company name in u0 fitler needs to match precisely the company name as recorded in Freebase. You could use a contains predicate rather than an equal one, but that could introduce many irrelevant hits. For example you need to use "IBM", "Apple Inc.", "General Motors" rather than common alternatives to these names ("International Business Machines", "Apple", "GM"...")
the u1 filter, on the leadership role is expressed in a extensive One of predicate because unfortunately the nomenclature for these roles is relatively loose, with duplicates (e.g. could be CEO or Chief Executive Officer) and with the fact that the role of CEO is often coupled with other corporate roles such as Chairman [of the board] and/or President etc. I hand picked this list by first looking up (in Freebase) the instances of Leadership Roles which contained "CEO" or "Chief Executive".
the u2 filter expresses that the to date should be empty, to select only the person currently in office, as opposed to former CEOs (for which hopefully Freebase recorded the end date of their tenure).
Depending on your application, you may need to test that the query returns one and exactly one record, and adapt accordingly if it doesn't.
Freebase MQL editor is a convenient tool test and edit with this kind of queries.
[
{
"from": null,
"id": null,
"limit": 20,
"organization": {
"id": null,
"name": null,
"optional": true
},
"person": {
"id": null,
"name": null,
"optional": true
},
"role": {
"id": null,
"name": null,
"optional": true
},
"s0:type": [
{
"id": "/organization/leadership",
"link": [
{
"timestamp": [
{
"optional": true,
"type": "/type/datetime",
"value": null
}
],
"type": "/type/link"
}
],
"type": "/type/type"
}
],
"sort": "s0:type.link.timestamp.value",
"title": null,
"to": null,
"type": "/organization/leadership",
"u0:organization": [
{
"id": null,
"name": "IBM",
"type": "/organization/organization"
}
],
"u1:role": [
{
"id": null,
"name|=": ["Chief Executive Officer", "President and CEO", "Chairman and CEO", "Interim CEO", "Interim Chief Executive Officer", "Founder and CEO", "Chairman, President and CEO", "Managing Director and CEO", "Executive Vice President and Chief Operating Officer", "Co-Founder, Chairman and Chief Executive Officer"],
"type": "/organization/role"
}
],
"u2:to": [
{
"value": null,
"optional": "forbidden"
}
]
}
]
Sample return (for "IBM", specifically)
{
"code": "/api/status/ok",
"result": [{
"from": "2012-01-01",
"id": "/m/09t7b08",
"organization": {
"id": "/en/ibm",
"name": "IBM"
},
"person": {
"id": "/en/virginia_m_rometty",
"name": "Virginia M. Rometty"
},
"role": {
"id": "/en/chairman_president_and_ceo",
"name": "Chairman, President and CEO"
},
"s0:type": [{
"id": "/organization/leadership",
"link": [{
"timestamp": [{
"type": "/type/datetime",
"value": "2010-01-23T08:02:57.0006Z"
}],
"type": "/type/link"
}],
"type": "/type/type"
}],
"title": "Chairman, President and CEO",
"to": null,
"type": "/organization/leadership",
"u0:organization": [{
"id": "/en/ibm",
"name": "IBM",
"type": "/organization/organization"
}],
"u1:role": [{
"id": "/en/chairman_president_and_ceo",
"type": "/organization/role"
}],
"u2:to": []
}
Related
How to get the users list from the current flow / thread with Hubot on Flowdock? I'd like to create plugin showing messages with the usage of current flow user names.
I have found this: robot.brain.data.users
but it returns the whole list of users from organization rather than from the current flow.
The list of a flow’s users can be fetched using the Flows resource. You'll need to know the Organization name and Flow name. See the 'Get a Flow' section here:
https://www.flowdock.com/api/flows
The format is:
GET /flows/:organization/:flow
and returns:
{
"id": "deadbeefdeadbeef",
"name": "My flow",
"parameterized_name": "my-flow",
"organization": {
"id": 8,
"name": "Acme",
"parameterized_name": "acme",
"user_limit": 0,
"user_count": 5,
"active": true,
"url": "https://api.flowdock.com/organizations/acme"
}
"unread_mentions": 0,
"open": true,
"url": "https://api.flowdock.com/flows/acme/my-flow",
"web_url": "https://www.flowdock.com/app/acme/my-flow",
"join_url": "https://www.flowdock.com/invitations/eedd2bf0643f75c14be9099272429351c7132a71-my-flow",
"access_mode": "link",
"users": [
{
"id": 9,
"nick": "Joe",
"name": "Joe Smith",
"email": "joe#example.com",
"avatar": "https://d2cxspbh1aoie1.cloudfront.net/avatars/f5b8fb60c6116331da07c65b96a8a1d1/",
"status": "Testing API",
"disabled": false,
"last_activity": 1328016726423000,
"last_ping": 1328017690004000
},
{
"id": 42,
"nick": "Stevie",
"name": "Stevie Johnson",
"email": "stevie#example.com",
"avatar": "https://d2cxspbh1aoie1.cloudfront.net/5bdd089a099acc56fc7120f6325a5d5c/",
"status": null,
"disabled": false,
"last_activity": 1328016712345000,
"last_ping": 1328017612345000
}
]
}
I have taken the Blog App, added a Category ContentType as a field in the BlogPost ContentType and built a query to factor Category into the results.
But I am having trouble with the In-ValueProvider. Following the example here the Visual Query Designer seems to be ignoring the incoming value from my ModuleDataSource.
I have double checked the In-Stream name, my Entity names, case, TestParameters, etc. Are there any known bugs in 2sxc 8.44 and up that would cause this issue? What have I missed?
In this case I am using a RelationshipFilter. Relationship is "Category". Filter is "[In:Config:Category]". I can switch out to a [Querystring:Category] and that works fine and runs all my code.
Thanks for reading.
OK I found a workaround.
It turns out that the In-ValueProvider is working but it's struggling with the Category of my BlogPost I think because Category is an entity.
For background I have a BlogPost ContentType, a Category ContentType, and an Articles Home Header ContentType. Articles Home Header sets both the header info for the articles page and the Category entity.
For some reason the RelationshipFilter is having trouble comparing the Category entities between Articles Home Header and BlogPost. I tried the following for my Filter and neither worked:
[In:Config:Category]
[In:Config:Category:Title]
I wonder if this is a case sensitivity issue, a bug, or if I am just misunderstanding the filter syntax.
To work around I created a temp field called TempCategory in my Articles Home Header and used [In:Config:TempCategory] for the filter.
That worked.
For reference here is a snippet from the Query:
{
"Config": [
{
"Title": "Coaching Articles",
"SubTitle": "",
"Image": "/Portals/0/uploadedimages/AcademicPrograms/Christ_College/crosswise-hero.jpg",
"ImageAlt": "Crosswise stained glass",
"Category": [
{
"Id": 2716,
"Title": "Coaching"
}
],
"Id": 3118,
"Modified": "2016-06-21T10:44:21.9Z",
"_2sxcEditInformation": {
"sortOrder": 0
}
}
],
"Paging": [
{
"Title": "Paging Information",
"PageSize": 10,
"PageNumber": 1,
"ItemCount": 0,
"PageCount": 0,
"Id": 0,
"Modified": "0001-01-01T00:00:00Z",
"_2sxcEditInformation": {
"entityId": 0,
"title": "Paging Information"
}
}
],
,
"Default": [
{
"Title": "Protect Your Players and Your Program: An Athletic Leader's Legal Duties",
"UrlKey": "an-athletic-leaders-legal-duties",
"PublishingGroup": null,
"PublicationMoment": "2016-06-15T00:00:00Z",
"Image": "/Portals/0/uploadedimages/AcademicPrograms/Graduate/Coaching/an_athletic_leaders_legal_duty.jpg",
"ImageSquare": false,
"Teaser": "<p>When the clock started on the new year earlier this month, all but one state joined the growing legal effort to protect and prevent concussions and head injuries among America’s young.</p>",
"Body": "<p><strong>When the clock started on the new year earlier this month,</strong> all but one state joined the growing legal effort to protect and prevent concussions and head injuries among America’s young.</p>\n<p>As sports-related injuries and issues continue to dominate the headlines and influence programs throughout the country, laws like “return-to-play” are becoming a sign of the times when it comes to protecting players and athletic programs alike. The world of athletics is experiencing a significant shift in the perception of the roles and responsibilities of coaches, schools and athletic personnel.</p>",
"DesignedContent": [],
"Tags": [
{
"Id": 2576,
"Title": "coaching"
},
{
"Id": 2575,
"Title": "management"
},
{
"Id": 2574,
"Title": "sports"
},
{
"Id": 3035,
"Title": "legal"
}
],
"Author": [
{
"Id": 3030,
"Title": "Shaleek Blackburn"
}
],
"ImageAlt": "Referee holding a red",
"Thumbnail": "",
"ThumbnailAlt": "",
"RelatedArticles": [
{
"Id": 2564,
"Title": "Athletic Personnel's Duty To Warn"
},
{
"Id": 2565,
"Title": "Get A Better Grip On Bullying"
},
{
"Id": 2717,
"Title": "Good Coaching Develops Exceptional Athletes and People"
}
],
"Category": [
{
"Id": 2716,
"Title": "Coaching"
}
],
"ArticleRelationships": null,
"Id": 2513,
"Modified": "2016-06-15T19:32:17.913Z",
"_2sxcEditInformation": {
"entityId": 2513,
"title": "Protect Your Players and Your Program: An Athletic Leader's Legal Duties"
}
}
]
}
I would like to use the Freebase Api to determine if a certain thing refers to an entity (e.g. person, tv show, ...). For instance "how i met your mother" refers to a TV show, "lana del rey" is a singer. However if something is not an entity, I would like to know that as well.
Unfortunately the Freebase search api gives me quite a few false positives for things that are not clear entities, even with the parameter exact=true and prefix=false:
For instance: https://www.googleapis.com/freebase/v1/search?query=girl&exact=true
[
{
"mid": "/m/0ytdbkr",
"name": "Naked girl",
"notable": {
"name": "Film character",
"id": "/film/film_character"
},
"lang": "en",
"score": 5.222793
},
{
"mid": "/m/0y4k26c",
"name": "Sexy girl",
"notable": {
"name": "Film character",
"id": "/film/film_character"
},
"lang": "en",
"score": 4.754522
},
{
"mid": "/m/0yg73tt",
"name": "Call girl",
"notable": {
"name": "Film character",
"id": "/film/film_character"
},
"lang": "en",
"score": 4.567947
},
{
"mid": "/m/0w1sb51",
"name": "Gorgeous girl",
"notable": {
"name": "Film character",
"id": "/film/film_character"
},
"lang": "en",
"score": 4.526981
},
{
"mid": "/m/03p0tvg",
"id": "/user/girl",
"name": "girl",
"lang": "en",
"score": 4.465735
},
{
"mid": "/m/05p197",
"id": "/en/bad_girl_movies",
"name": "Bad girl movies",
"notable": {
"name": "Film genre",
"id": "/film/film_genre"
},
"lang": "en",
"score": 4.464571
},
....
]
}
What's an "exact" match in this context?
If you simply want an exact name & type match, you can get that using the MQLRead API instead of the Freebase Search API. If you're looking for something different, you need to be more specific about what you seek...
I am curious if I can control the results of a query so that it will not display the a particular field in the query. For instance...
query:
[{
"id": null,
"name": null,
"type": "/people/person"
}]
result:
{
"result": [
{
"type": "/people/person",
"id": "/en/jack_abramoff",
"name": "Jack Abramoff"
},
{
"type": "/people/person",
"id": "/en/bob_ney",
"name": "Bob Ney"
},...
I have tried this...
[{
"id": null,
"name": null,
"type": [{
"id": "/people/person",
"limit": 0
}]
}]
Which gives me ...
{
"result": [
{
"type": [],
"id": "/en/jack_abramoff",
"name": "Jack Abramoff"
},
{
"type": [],
"id": "/en/bob_ney",
"name": "Bob Ney"
},...
I am wondering if there is a way to just get this
{
"result": [
{
"id": "/en/jack_abramoff",
"name": "Jack Abramoff"
},
{
"id": "/en/bob_ney",
"name": "Bob Ney"
},...
No, there is no way to do this. Why would you need to do this? Once you parse the JSON data in your application its very easy to just ignore any values that you don't need. The APIs support using gzip compression so you don't have to worry about the response size either. If you're really optimizing for speed you might consider switching to the Search API which looks like this:
https://www.googleapis.com/freebase/v1/search?filter=(all+type:/people/person)
In addition to this question:link i'm asking if i can retrieve data like the text or even geolocation from topics that seems that they have not any info been entered(but there is text description from wikipedia)
So, the problem is that when you run the following query you don't get any results:
[{
"name": "River Thames",
"type": "/location/location",
"geolocation": [{
"latitude": null,
"longitude": null
}],
"/common/topic/article": [{
"text": {
"maxlength": 16384,
"chars": null
}
}]
}]
Try it out
This is because Freebase doesn't have geocoordinates (yet) for a topic called "River Thames". In other words, there are no combination of facts in Freebase that will match this query structure exactly so it returns nothing. It does however have coordinates for the mouth of the river so you will get results for this similar query:
[{
"name": "River Thames",
"type": "/location/location",
"/geography/river/mouth_long_lat": [{
"latitude": null,
"longitude": null
}],
"/common/topic/article": [{
"text": {
"maxlength": 16384,
"chars": null
}
}]
}]
Try it out
But what should you do if you don't know beforehand whether the data that you're looking for is completely filled out in Freebase yet?
You can mark certain parts of a query as being "optional" which means that they should be returned if the data is present but that the query should still return results even if that data isn't present. So for your original query that would look like this:
[{
"name": "River Thames",
"type": "/location/location",
"geolocation": [{
"latitude": null,
"longitude": null,
"optional": true
}],
"/common/topic/article": [{
"text": {
"maxlength": 16384,
"chars": null
}
}]
}]
Try it out
Now you should get results with the text of the article present but the geolocation returned as an empty array.
One more thing I should point out is that you should be aware that the query you've written is asking for a list of ALL topics in Freebase with the name "River Thames". Right now, that query only returns one result but in the future, when more data is added to Freebase, it may return multiple results. If you're really only interested in THIS River Thames, you should query it using its unique MID like this:
{
"id": "/m/0d2kt"
"name": null,
"type": "/location/location",
"geolocation": [{
"latitude": null,
"longitude": null,
"optional": true
}],
"/common/topic/article": [{
"text": {
"maxlength": 16384,
"chars": null
}
}]
}
Try it out