4

Is there a database of fictional characters from novels, films, dramas etc., grouped by genre?

The most important entries for me are the name, nationality (real or fictional), title of the novel/film/drama and the genre.

6
  • I don't think that a data set of fictional characters fall under the open data concept. – Kermit May 10 '13 at 22:41
  • 2
    @FreshPrinceOfSO Why not? – Patrick Hoefler May 15 '13 at 23:23
  • 7
    This seems like a perfectly valid question to me. Why was it closed? The current FAQ doesn't prescribe what kind of data can be discussed, and the question is very clear. – ldodds May 24 '13 at 9:04
  • 5
    Please anyone reopen this question, it is a valid question. My answer would be to use SPARQL to query DBpedia for all children of dbpedia.org/describe/… – Nicolas Raoul Jun 5 '13 at 7:03
  • It might be on topic, but it's way too broad. You'd have to deal with every book, tv show, movie, play, opera, comic book, etc. In English and in every other language. It'd be challenging enough just trying to get a list of all fiction books in English. – Joe Jun 5 '13 at 20:23
7

A past alternative to using DBpedia as suggested by Nicolas Raoul was Freebase before it was shut down.

2
  • 1
    It's up to 703K instances as of this date, but note that characters are linked to their "fictional universe" not books or films directly since they're often shared by a common setting, you'll need to go one hop further to get the name of the book/movie, etc. – Tom Morris Aug 8 '13 at 3:35
  • Link does not work anymore unfortunately. – Nicolas Raoul Feb 17 at 15:19
4

Wikidata contains 145941 fictional characters, you can get them using this query:

SELECT ?item ?itemLabel WHERE {
  # Item's type is: fictional character, or sub-type, or sub-sub-type, etc
  ?item p:P31/ps:P31/wdt:P279* wd:Q95074.  
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
  }
}

Just run it by clicking here and download as CSV, TSV or JSON.

https://www.wikidata.org/wiki/Q95074 is the "fictional character" item.

You can get more properties about each by adding OPTIONAL lines (and corresponding label in the first line), like this:

SELECT ?item ?itemLabel ?presentInWorkLabel ?countryOfCitizenshipLabel ?image WHERE {
  # Item's type is: fictional character, or sub-type, or sub-sub-type, etc.
  ?item p:P31/ps:P31/wdt:P279* wd:Q95074.
  OPTIONAL{?item wdt:P18 ?image}
  OPTIONAL{?item wdt:P27 ?countryOfCitizenship}
  OPTIONAL{?item wdt:P1441 ?presentInWork}
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en". # You can specify more languages.
  }
}

The problem is that the query times out easily, so you might have to run it several times with different properties then match the QID identifiers.

Extract from the output:

enter image description here

Please note that the same fictional character can appear in different works, which can be of different genres.

To get genres, you could use OPTIONAL{?item wdt:P1441 ?work. OPTIONAL{?work wdt:P136 ?genre}} but timeouts will become difficult to avoid so you will have to limit your query.

Try it to get a result like this:

enter image description here

To reliably get all properties of all fictional characters, I believe (I would love to be proved wrong, if you know another way please comment) that your only option is to write a script that performs many smaller SPARQL requests, similar to this script that gets a dozen properties for all embassies and consulates of the world, please be aware that adapting this script will take a few hours (or a few days if you are new to development) and running it without overloading the server will take days.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.