Search code examples
conceptnet

ConceptNet RelatedTo Tuning


I'm using ConceptNet http://conceptnet.io to try to get related keywords using both their relatedto and edge/query endpoints. The data is awesome, however I've encountered some behaviour I can't figure out.

If you query "relatedto" for the keyword "person" with a limit of 20 on the main site you get:

http://conceptnet.io/c/en/person?rel=/r/RelatedTo&limit=20

Or this list of words:

doll
character
statue
person
servant
body
farmer
child
man
baby
guard
name
doctor
captain
people
neighbour
boy

Pretty awesome right? That's super topical and useful.

On the other hand if you query the API with what appears to be the same query formatted for the API:

http://api.conceptnet.io/related/c/en/person?filter=/c/en&limit=20

Shortened for clarity (see the link above for the full response):

{
  "@id": "/c/en/person",
  "related": [
    {
      "@id": "/c/en/person",
      "weight": 1.0
    },
    {
      "@id": "/c/en/sean_connery",
      "weight": 0.963
    },
    {
      "@id": "/c/en/steve_ballmer",
      "weight": 0.962
    },
    {
      "@id": "/c/en/norman_jewison",
      "weight": 0.962
    },
    {
      "@id": "/c/en/aretha_franklin",
      "weight": 0.962
    }
  ]
}

Huh. What happened there? That's a lot less useful. We got just names and not very related terms.

So my question is: How do I get a similar list?

Are they using some complex edge analysis (using a standard, not relatedto query) to get the relatedterms on the website?

OR

Am I missing something I can't figure out?

Any help much appreciated.

Thanks


Solution

  • To query for existing edges labeled with /r/RelatedTo that contain the node /c/en/person, you should query: http://api.conceptnet.io/query?node=/c/en/person&rel=/r/RelatedTo

    The results of that query match the Web site.

    The /related endpoint is different, and is only present in the API. It applies some machine learning to predict nodes that are related, whether or not the edge connecting them is already present in ConceptNet. It's better for more specific concepts than "person". Try "teacher" for example: http://api.conceptnet.io/related/c/en/teacher?filter=/c/en&limit=20