Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A suggestion for a possible method of using this addon #38

Open
UrKr opened this issue Jan 20, 2024 · 1 comment
Open

A suggestion for a possible method of using this addon #38

UrKr opened this issue Jan 20, 2024 · 1 comment

Comments

@UrKr
Copy link

UrKr commented Jan 20, 2024

First, thank you for this addon, I needed something to organise my revision process.

I'd like to offer an idea.
When memorising something like T.S.Eliot I find that the lines in the poem aren't such a useful unit for dividing the poem.

Instead I like to set all the LPCG values to 1 and then run the poem through this script, which breaks it into sentences and puts each sentence into a separate line. I'm a bit torn as to whether I should count a semicolon as the end of a sentence.

You need to put the poem in poem.txt

Also, I brought in nltk for this, which is a bit overkill, but I already had it installed.

from nltk.tokenize.punkt import PunktSentenceTokenizer, PunktLanguageVars

class MyPunktLanguageVars(PunktLanguageVars):
  sent_end_chars = ('.', '?', '!')

tokenizer = PunktSentenceTokenizer(lang_vars = MyPunktLanguageVars())


# take a poem and split it into sentences and make each sentence a line
def poem_to_sentence_lines(text):
  text = text.strip()
  # remove all single newlines, leave double newlines
  text = text.replace('\n\n', 'placeholder')
  text = text.replace('\n', ' ')
  text = text.replace('placeholder', '\n\n')  
  sentences = tokenizer.tokenize(text)
  return '\n'.join(sentences)

# read the text from a file called poem.txt
def read_poem():
  with open('poem.txt', 'r') as f:
    return f.read()

poem = read_poem()
poem = poem_to_sentence_lines(poem)

with open('poem_out.txt', 'w') as f:
  f.write(poem)
@UrKr
Copy link
Author

UrKr commented Jan 20, 2024

You are then left with something like this for the dry-salvages

I do not know much about gods; but I think that the river Is a strong brown god—sullen, untamed and intractable, Patient to
some degree, at first recognised as a frontier; Useful, untrustworthy, as a conveyor of commerce; Then only a problem confronting the builder of bridges.

The problem once solved, the brown god is almost forgotten By the dwellers in cities—ever, however, implacable.

Keeping his seasons and rages, destroyer, reminder Of what men choose to forget.

Of course the sentences can be quite long if you don't count a semicolon as an ending, but I think it makes sense to learn AND REVISE the whole sentence together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant