Open graph : count actions by object - facebook

I'm new to the facebook open graph.
I would like to know how many times an action is performed over a given object.
eg :
Bob cooks chocolate cake
Sam cooks orange cake
Peter cooks chocolate cake
I would to query how many people have cooked "chocolate cake" to get 2 as a result.
Thanks !

Related

Using context variables to write the user's car registration

In watson-conversation, I have reached a point where I ask the user their car number (registration), which follows this format: 0000BBB (4 numbers, 3 letters).
I want to type that to the user like:
User: "My car id is 0123asd"
Watson: "Okay so your car id is this one: 0123asd"!
I have tried defining an entity #carId with some examples, but every time I input something with that format (0000BBB), it shows "irrelevant".
If the chat detects #carId, respond with Okay so this is your carId! #exampleCarId (I have some examples like 5487qwe, or 8521rty, I thought the machine learning below that would learn the "pattern").
And my #carId has these examples:
I know I am missing something! Do I need to code anything? I think it's not necessary. I tried to save it on a sys-number but it does not work as it is not a "number".
Most developers would consider he car ID an entity (denoted by #). IBM Watson Assistant allows to define so-called dictionary-based entities. One form of such an entity is pattern-based. Thus, you would define a pattern of 4 digits and 3 letters.
You could have an intent (denoted by #) that identifies that a user inputs the car ID. In the dialog node you could match against the intent and then assign the matched entity for the actual ID to a variable.
The linked documentation has examples.

Detecting number of objects in image Cloud Vision

I am sorry if this has been asked before but is there any way to count the number of a specific "tag" in an image using Cloud Vision? For instance, if I have a picture of a cat and a dog, can I make a request that will return "1 cat, 1 dog, 2 mammals" or something like that?
AFAIK, Google Cloud Vision can't do that and you probably should look at services from MS and AWS, but... you could recursively split image into parts, like if you split it in three, the left one can say "cat", the right one "dog" and the middle says nothing useful -- that would with some probability mean that it's a 1 cat and 1 dog.

Tagging and Training NER dataset

I have a data set and I want to tag it for Named Entity Recognition. My dataset is in Persian.
I want to know how should I tag expressions like :
*** آقای مهدی کاظمی = Mr Mehdi Kazemi / Mr will Smith. >>> (names with titles) should I tag all as a person or just the first name and last name should be tagged? (I mean should i also tag "Mr")
Mr >> b_per || Mr >> O
Mehdi >> i_per || Mehdi >> b_per
Kazemi >> i_per || Kazemi >> i_per
*** بیمارستان نور = Noor hospital >>> Should I tag the name only or the name and hospital both as Named Entity?
*** Eiffel tower / The Ministry of Defense (I mean the us DOD for example) >>> in Persian it is called :
وزارت دفاع (vezarate defa)
should I only tag Defense ? or all together?
There are many more examples for schools, movies, cities, countries and.... since we use the entity class before the named entity.
I would appreciate if you can help me with tagging this dataset.
I'll give you some examples from the CoNLL 2003 training data:
"Mr." is not tagged as part of the person, so titles are ignored.
"Columbia Presbyterian Hospital" is tagged as (LOC, LOC, LOC)
"a New York hospital" (O, LOC, LOC, O)
"Ministry of Commerce" is (ORG, ORG, ORG)
I think "Eiffel Tower" should be (LOC, LOC)
In general, you tag as the way you want the output to look. It's up to you if you want titles included, for example. However, Core NLP won't tag overlapping entities, so you have to make a decision in for cases like the hospital named after someone.
I believe you are heading to Stanford NLP and BIO format. But in case you'd also consider other options, you may have a look a structured entities such as: http://www.afcp-parole.org/etape/docs/etape-06022012-quaero-en.pdf.
Those allow to describe entities as trees, providing a finer analysis for information extraction. More tedious to annotate but probably relevant if you intend to use annotation for semantic purposes, not only indexing.

About MongoDB documents

I am new to the NoSQL/MongoDB world and so I am experimenting with several things.
Let's say I would like to create a blog using MongoDB.
I could create a Blog post like this:
{
Title: "My First Post",
Body: "Bla de bla de bla bli bla de bah"
Date: "07/07/2013" // or 06/07/2013 when using javascript date notation
}
And then I would like my readers to post comments. One thing I know about my readers is they get very involved. They write thousands of comments to my blog posts.
First question:
Is it a good idea to embed the comments? Or is it better to store them in their own collection with a reference to the blog post id?
Here's another example. Let's say I'd like to create a social media like web site that has several different types of objects (i.e.: blog posts, video's, contacts) and people can subcribe to the objects so they can comment and read other people's comments.
A comment feed would look like this:
{
Type:[either blog post,video or contact]
Name:"Comments on this crazy video"
SubscribedUsers:[userid1,userid2,userid3...userid999]
Comments: {
{
Name:"Purple Dog",
Date: "07/07/2013 09:12:23",
Text: "Bla bla bla"
},
{
Name:"Shizzly Feather",
Date: "07/07/2013 09:23:08",
Text: "I agree with Purple Dog."
}
}
}
(maybe the notation is a bit off but I hope you get what I mean)
Question two:
Is the above example a good idea for a site like this? Is MongoDB a good fit or should I not use it for stuff like this? (What should I use then?) Or is there another way to achieve the same result (in the end, I would like to show the user an aggregated feed with all comments sorted by date DESC for the feeds they are subscribed to)
What I'm trying to learn (and what hopefully is useful to others) is when to choose MongoDB/NoSQL and when to stick with RDBMS's.
If you are using MongodB, you are better off embedding the comments because the comments are inextricably linked to each post - In fact, comments that are not germane/relevant to the post might be viewed as spam. The embedding shines when you ask for say, every comment that's associated with the post. The embedding sucks when you ask for say, every comment that's been made by anyone in the last 6 hours, but I can't think of a reason why you might want to ask for such a thing :)
You'll like RDBMS if you put the comments in their own table and you DO ask questions like "give me all comments that were made by everyone in the last six hours". On the other hand, RDBMS sucks when Julie C. (rightfully) expects to see all comments associated with her post and you have to run a "join" operation between the "poster" table, the "posts" table and the "comments" table to give her what she expects.
So, choose your poison :)
Here is an another approach which is a hybrid called a bucketing strategy
http://www.slideshare.net/jrosoff/mongodb-advanced-schema-design-inboxes

Extract a person's full name from a block of text in Perl?

I need to extract names (including uncommon names) from blocks of text using Perl. I've looked into this module for extracting names, but it only has the top 1000 popular names and surnames in the US dating back to 1990; I need something a bit more comprehensive.
I've considered using the Social Security Index to make a database for comparison, but this seems very tedious and processing intensive. Is there a way to pull names from Perl using another method?
Example of text to parse:
LADNIER Louis Anthony Ladnier, [Louie] age 48, of Mobile, Alabama died at home Friday, November 16, 2012. Louie was born January 9, 1964 in Mobile, Alabama. He was the son of John E. Ladnier, Sr. and Gloria Bosarge Ladnier. He was a graduate of McGill-Toolen High School and attended University of South Alabama. He was employed up until his medical retirement as Communi-cations Supervisor with the Bayou La Batre Police Department. He is preceded in death by his father, John. Survived by his mother, Gloria, nephews, Dominic Ladnier and Christian Rubio, whom he loved and help raise as his own sons, sisters, Marj Ladnier and Morgan Gordy [Julian], and brother Eddie Ladnier [Cindy], and nephews, Jamie, Joey, Eddie, Will, Ben and nieces, Anna and Elisabeth. Memorial service will be held at St. Dominic's Catholic Church in Mobile on Wednesday at 1pm. Serenity Funeral Home is in charge of arrangements. In lieu of flowers, memorials may be sent to St. Dominic School, 4160 Burma Road Mobile, AL 36693, education fund for Christian Rubio and McGill-Toolen High School, 1501 Old Shell Road Mobile, AL 36604, education Fund for Dominic Ladnier. The family is grateful for all the prayers and support during this time. Louie was a rock and a joy to us all.
Use Stanford's NER (GPL). Demo:
http://nlp.stanford.edu:8080/ner/process
There is no sure fire way to do this due to the nature of the English language. You either need lists to (fuzzy)compare with, or will have to settle for significant accuracy penalties.
The Apache Foundation has a few projects that cover the topic of entity extraction with specific pre-trained models for English names (nameFinder). I would recommend openLNP or Stanbol. In the meantime if you have just a few queries I have an NLP I've implemented in C# in my apps section at http://www.augmentedintel.com/apps/csharpnlp/extract-names-from-text.aspx.
Best,
Don
You're trying to implement a named-entity recognition. The bad news is that it's really hard.
You could try Lingua::EN::NamedEntity, however:
$ perl -MLingua::EN::NamedEntity -nE 'say $_ for map { $_->{class} eq "person" ? $_->{entity} : () } extract_entities($_)' names.txt
Louie
Louis Anthony Ladnier
Louie
John E
Bayou La Batre Police Department
Gloria
Julian
Cindy
Eddie Ladnier
Eddie
John
Catholic Church
Christian Rubio
Dominic Ladnier
Burma Road Mobile
Louie
You can also use Calais, a Reuters webservice for natural language processing, which offers a lot better results:
I think you want to Google something like:
perl part of speech tagging