Hacking the dramatica theory book

FOR MACOS USERS ONLY:

I used this script to find every full sentence with the word ‘inequity’ in the theory book, then save it to a file called inequity.txt.

(this is a single line)

perl -MLingua::EN::Sentence=get_sentences -ne ‘print "$\n" for grep { /inequity/ } @{get_sentences($)}’ <(tr ‘\n’ ’ ’ < dramatica-theory-book.txt) > inequity.txt

You have to install the Lingua::EN::Sentence module in perl, and then you have to set the PERL5LIB in bash_profile to the correct path for the library. In my case that’s

export PERL5LIB=$HOME/perl5/lib/perl5

====
here’s how you can install Perl modules:
*You can enter the Perl shell to install the modules you want.
*perl -MCPAN -e shell.
*to install the module type. install module name. Example: install Lingua::EN::Sentence
*make the shell significantly more user friendly type. install Bundle::CPAN. highly recommended.

====

I used convertio.co to turn the theory book pdf into a text file, the better for string searches.

====

I got output like this:

In a sense, these Char-
acters are made more interesting by creating an inequity within them even as they
continue to represent methods of problem solving within the Story Mind.
The trial of Tom Robinson brings all of the
towns’ people into squabbles about inequity in the treatment of
different races, inequity among the social classes of people, their
levels of income, and their educations.
Scout, as the Main Character, is driven by her personal problem
of inequity.
Kept at the margins of the Overall Story dealings with the
problem of inequity, Scout however comes to see her prejudice
against Boo Radley as being every bit as wrong.
The resolution may be to rearrange one’s environment or to come to terms
with the environment as it is. Regardless of the source of the inequity or the means
employed to resolve it, all thinking creatures try to maximize their pleasure and minimize
their pain.
Or, we
change the nature of the forces at work that determine the processes that sustain the
inequity, so that it dissolves when its foundation is eroded.
Problem solving requires identifying the source of the inequity and/or the kind of
effort that will bring an end to it.
Each of these requirements depends upon an accurate
assessment of the mechanism that generates the inequity, and therein lies the opportu-
nity for error.

====

here’s the original stackoverflow article that told me how to do this.

====

this method should be easily adaptable for Windows users, as perl is cross platform. i’m sure there’s some grep for Windows, or the equivalent, that would work.

@jhull

made this clearer above:

here’s how you can install Perl modules:

*You can enter the Perl shell to install the modules you want.
*perl -MCPAN -e shell.

(follow the prompts, answer with the defaults. it takes a few minutes.)

*to install the module type. install module name. Example:
install Lingua::EN::Sentence

*make the shell significantly more user friendly type.
install Bundle::CPAN.

highly recommended.

also, there is some issue with the way code gets translated on this board, even using the code tag. Here’s a picture of the tested perl line that works.

and here are ideas for more

should have thought of this before: txt file with with working command. After you’ve configured your system. you can cut and paste this in a text editor and modify the search string and output file.

In the string example, I’m looking to make a document from the dramatica theory book, every sentence that contains the word ‘handoff.’

perl sentence parser.txt.pdf (164 Bytes)

(as usual, get rid of the .pdf extension, it’s only there so that the board would accept my upload. then you’ll have a plain text file with the example string in it.

(umm except it should be hand-off in the search string, not handoff, which won’t find anything. Dramatica book always inserts the dash between the two words).

REMEMBER you have to close your terminal window and open a new one to get the bash_profile to export the perl5 library path.