2
$\begingroup$

A novel Vanity Fair by William Thackeray has many different characters in it, such as Emmy Sedley, Becky Sharp, and Rawdon Crowley. Is it possible to use Mathematica to automatically count the number of the characters in the novel?

As another example, one could consider how to exactly count the approximately 600 characters in And Quiet Flows the Don by Mikhail Sholokhov.

Here is a link to the plain text.

Import["http://www.gutenberg.org/cache/epub/599/pg599.txt"]
$\endgroup$
11
  • $\begingroup$ If the text is stored in variable str, the number of characters can be given by StringLength[str]. How to import the text is another question and I don't think questions such as "find a free version of this book for me" is in the scope of mma.se. edit I think I misunderstood character = person and character = element of a string. $\endgroup$
    – anderstood
    Commented Mar 5, 2017 at 18:14
  • 1
    $\begingroup$ @user64494 No you didn't. My English was fine, you introduced grammatical errors into the text and made it harder to read. But your intention was good, and it's your question so it's all good. And thank you for adding the link to Gutenberg. $\endgroup$
    – C. E.
    Commented Mar 5, 2017 at 20:43
  • 1
    $\begingroup$ This will be hard in general. This may be a start for you: t1 = StringSplit[ Import["http://www.gutenberg.org/cache/epub/599/pg599.txt"]]; p1 = Tally[ Select[Partition[t1, 2, 1], And @@ (StringLength[#1] > 2 && UpperCaseQ[StringTake[#1, 1]] &) /@ #1 &]]; p2 = Select[p1, DictionaryWordQ[#1[[1, 1]]] && DictionaryWordQ[#1[[1, 2]]] &]; p3 = Select[p2, LowerCaseQ[ StringTake[#1[[1, 1]], {2, 2}] <> StringTake[#1[[1, 2]], {2, 2}]] &]; p4 = (Reverse[SortBy[#1, Last]] &)[ Select[p4, StringMatchQ[StringJoin[#1[[1]]], __?LetterQ] &]]; Column@p4 $\endgroup$ Commented Mar 5, 2017 at 21:07
  • 3
    $\begingroup$ I'm voting to close this question as off-topic because this is not a Mathematica problem. It is an unsolved AI problem. $\endgroup$
    – m_goldberg
    Commented Mar 5, 2017 at 22:04
  • 1
    $\begingroup$ @m_goldberg It is unsolvable by Mathematica alone. If one adds database-queries of list of (first) names, then one could probably get pretty far with a semi-heuristic approach as I laid out above. But I agree that this question should be closed as "too-difficult" or whatever the reason is to close a research-type question. $\endgroup$ Commented Mar 6, 2017 at 19:08

0

Browse other questions tagged or ask your own question.