Getting the best category for a topic in Freebase - freebase

How to get the best (top) category for a topic ?
For example the movie "Life Is Beautiful" has a notable type "Award-Winning Work". I can not use this category. I'd like to know that, over all categories, the best choice is "/film/film" and not "/award/award_winning_work".
Is it possible to get the top category for a item ?
Thanks for your ideas,
Mickael.
#TomMorris: Yes, "category" in my context, means "type".
But for a particular topic, there could be many many types and I don't know which to choose without actually making some choices, for example decide that if "/film/film" is present, then it is the best category for my topic.
I would have imagined that Freebase would provide this "main type" out of the box. If you read the description of notable_type you can read "The way a topic's notable types is calculated is rather complex." If Freebase provide this service that requires complex calculation, then why not provide another service that would be something like a "main type" that would be the top type, that is, the top of the ontonlogy classification (a caniche is a dog which is a animal, etc... and somewhat stop at a significant level like "animal" that I would consider as my "main type"). Simply put, "Award Work" is not a good description of the topic "Life is beautiful". "Film" is a better description of it.
I am afraid you're right. I need to make my own choices betwwen all the "types" of the topics.

I don't know if you refer to the the dumps or to one of the Api's.
Regarding the API's please check the search API (link below). There results includes score and notable type which attempts to indicate what is the most relevant entity with the name you are looking for. You can also include additional properties in the results but this is the basic result.
Regarding working directly from the dumps - I haven't found a solution for that except of implementing some mechanism myself.
https://www.googleapis.com/freebase/v1/search?query=Life+is+beautiful&limit=10

Related

Finding out the amount of sessions for a particular event category in Google Analytics?

I am getting a little confused as to what is the best way to measure the amount of sessions/visits for which a particular event has happened at least once.
I am reading different options for doing this: via segments or via filters. Which one is the correct one? I am getting different numbers!
In practice I have this section of my site that has these articles people can post and they tag their article with topics/tags. Using GTM I am collecting the topics/tags whenever someone views an article. So I have this event category named "Post view - topics" and in the event label I am listing the topics.
The idea is that I can build dashboards around specific topics (ex. the topic "Analytics") and track how many articles have been viewed, how many visits/sessions led to read an article that concerned that topic, what are the most popular articles for that topic, etc...
The way I've been doing it until now is:
Apply a event-category filter on my data ("Post view - topics")
Apply a event-label filter ("Analytics")
screenshot of my filters
And then build my charts around that filtered data.
I thought this was the right way to do it, but now I'm concerned that this might not be correct, especially when I want to measure the amount of sessions. I am reading (here for instance) that it might be better to use segments?
What do you guys think?
I suggest you to use segments, in this way you can request sessions which have your event category and your event action.

Drupal 8: How do I create a content reference/textarea compound field?

I have a company content type being used on a website-in-progress. Companies consist of a company name, name sorting mechanism, logo image and URL. I have a requirement to show companies taking part in different use cases in various parts of the website.
Challenge:
In the past I used a company content type for a "corporate members" list on a page, also assigning a "member level" field. But then, companies started being listed as event sponsors with specifics for what they were sponsoring, also with different membership levels in a "corporate giving club". It was messy while added/included in the old company content type. It caused confusion for content editors and developers.
Possible Solution:
In other content types, create compound fields such as "Sponsors", "Corporate members", "Donors", select lists with company entities, or sponsorship detail text areas with company entities. That may keep companies flexible and not messy (keeping company just a company).
Progress:
I found the Double field module, splitting core fields up into two separate parts. This is almost what I'm looking for, providing compound field sets. However, it won't allow references to be selected and is out of the scope of this project per this issue. I'm finding a lot of Drupal 7 examples, but not much Drupal 8 yet.
I'm starting to dig into the examples for developers module for inspiration and will post a solution unless you beat me to it. I'm also open to alternative ideas.
What is the best way to proceed? Specific code examples are not required. I would accept clues that lead me to a final working solution.
The solution turned out to be simpler than creating a custom module.
The Field Collection module allowed for the simple creation of compound fields containing any number and most (if not all) field types, including reference fields. It's also available as a Drupal 8 module (alpha at the time of writing, seems to work fine).

Filter out nodes that refer to a specific kind of node

I have a node type (reviews) that uses CCK to refer to another kind of node (either books or videos). Is there a way for me to use Views so that I can show only Reviews of Books or only Reviews of Videos?
I've tried creating a Relationship in the View and using a parameter, but that doesn't seem to work.
Are you using a CCK node reference field? If so this documentation may help get you started: http://drupal.org/node/289738
I was able to get my client to agree to a change, so that each node gets a radio button to mark what kind of review it is. That means that users will have to select the book/video and then say which type it is, but they are college-educated and hopefully this won't be beyond them.
So then I can add the review type into my Filters, and show only book reviews or video reviews that way. I suspect that my initial question is impossible without a lot of hacking.
You can do this with Views 3, which may not be a solution for you at all. :/
You add a required relationship based on your node reference, and then add a filter on node type of book/movie. The filter's 'Use relationship' should be set to the required relationship you set up previously.

Website Layout Statistics

I have a client who has suggested laying out a long list of categories in a custom order. The order is to be decided by them based on product items they sell the most etc.
I tend to disagree and feel that people browsing the internet prefer to search lists of categories that are in alphabetical order or sorted by something they can take reference of such as a date.
I would like to know others thoughts on this and it would be appreciated if anyone could point me in the direction of any open source surveys that have been taken in this area.
Thanks
Ben
What a silly stance to take regarding a simple customer request. Allow for both orderings, and other ones too. There is no survey that will demonstrate that the client is wrong as they are - by definition - correct.
Code that allows for different orderings has greater utility anyway, and real user data will be able to show them which - if either - should be the default.

How to display only taxonomy terms with nodes associated to in Views 2?

I've created a view with a set filters exposed (to show filtering options in the page). And one of those filters is a select field with all the taxonomy terms of a vocabulary.
That's ok, it's showing now. But I want to only show the taxonomy terms that have at least one node associated to it. To avoid empty results if selects an empty term.
Anyone knows how to do that?
Thanks.
Solution in views 3 (which may work in views 2)
Set a relationship for the view to join the terms to the nodes (in views 3 this is 'Taxonomy term: Content with term')
Then in the options tick 'Require this relationship' (this excludes terms without any nodes)
This may produce duplicates, in views 3 you open up Query settings, and tick Distinct (this will omit duplicates)
This would be a great feature for Views to have and you should submit a feature request to the maintainers for it. Unfortunately you can't do this with the existing Views code.
\What you could do, though, is see how Views constructs a filter control in its own source code, and implement that function yourself and add in an extra check to see if there are any posts with that term or not, and not display that term if there aren't any.
This is a simpler way. Hope it helps.
Add a relationship, filter for terms and choose "Taxonomy term: Representative node". Check the "require this relationship" and thats it. Optionally tick "Query settings > Distinct" in case of duplicate terms.
Based on http://www.waldbeek.com/blog/view-taxonomy-term-and-hide-empty-terms
With views 3 this gets very simple using aggregation! I'm posting this replay because I spent a lot of time discovering it. Everything is very well explained in this screencast: http://dev.nodeone.se/en/the-aggregation-setting-the-emmajane-episode

Resources