class_docstr: Middle English stresser
docstr: :param word: word to stress
  :param stress_rule: Stress Rule, valid options:
  
      'FSR': French Stress Rule, stress falls on the ultima, unless it contains schwa (ends with e), in which case the penult is stressed.
  
      'GSR': Germanic Stress Rule, stress falls on the first syllable of the stemm. Note that the accuracy of the function directly depends on that of the stemmer.
  
      'LSR': Latin Stress Rule, stress falls on the penult if its heavy, else, if it has more than two syllables on the antepenult, else on the ultima.
  
  :return: A list containing the separate syllable, where the stressed syllable is prefixed by ' . Monosyllabic words are left unchanged, since stress indicates relative emphasis.
  
  Examples:
  
  >>> from cltk.phonology.syllabify import Syllabifier
  >>> from cltk.phonology.enm.syllabifier import DIPHTHONGS, TRIPHTHONGS, SHORT_VOWELS, LONG_VOWELS
  >>> enm_syllabifier = Syllabifier()
  >>> enm_syllabifier.set_short_vowels(SHORT_VOWELS)
  >>> enm_syllabifier.set_vowels(SHORT_VOWELS+LONG_VOWELS)
  >>> enm_syllabifier.set_diphthongs(DIPHTHONGS)
  >>> enm_syllabifier.set_triphthongs(TRIPHTHONGS)
  >>> stresser = MiddleEnglishStresser(enm_syllabifier)
  >>> stresser.stress('beren', stress_rule="FSR")
  ['ber', "'en"]
  >>> stresser.stress('prendre', stress_rule="FSR")
  ["'pren", 'dre']
  >>> stresser.stress('yisterday', stress_rule="GSR")
  ['yi', 'ster', "'day"]
  >>> stresser.stress('day', stress_rule="GSR")
  ['day']
  >>> stresser.stress('mervelus', stress_rule="LSR")
  ["'mer", 'vel', 'us']
  >>> stresser.stress('verbum', stress_rule="LSR")
  ['ver', "'bum"]
docstr_tok: [":","param","word",":","word","to","stress",":","param","stress_rule",":","Stress","Rule",",","valid","options",":","'FSR","'",":","French","Stress","Rule",",","stress","falls","on","the","ultima",",","unless","it","contains","schwa","(","ends","with","e",")",",","in","which","case","the","penult","is","stressed",".","'GSR","'",":","Germanic","Stress","Rule",",","stress","falls","on","the","first","syllable","of","the","stemm",".","Note","that","the","accuracy","of","the","function","directly","depends","on","that","of","the","stemmer",".","'LSR","'",":","Latin","Stress","Rule",",","stress","falls","on","the","penult","if","its","heavy",",","else",",","if","it","has","more","than","two","syllables","on","the","antepenult",",","else","on","the","ultima",".",":","return",":","A","list","containing","the","separate","syllable",",","where","the","stressed","syllable","is","prefixed","by","'",".","Monosyllabic","words","are","left","unchanged",",","since","stress","indicates","relative","emphasis",".","Examples",":",">",">",">","from","cltk.phonology.syllabify","import","Syllabifier",">",">",">","from","cltk.phonology.enm.syllabifier","import","DIPHTHONGS",",","TRIPHTHONGS",",","SHORT_VOWELS",",","LONG_VOWELS",">",">",">","enm_syllabifier","=","Syllabifier","(",")",">",">",">","enm_syllabifier.set_short_vowels","(","SHORT_VOWELS",")",">",">",">","enm_syllabifier.set_vowels","(","SHORT_VOWELS+LONG_VOWELS",")",">",">",">","enm_syllabifier.set_diphthongs","(","DIPHTHONGS",")",">",">",">","enm_syllabifier.set_triphthongs","(","TRIPHTHONGS",")",">",">",">","stresser","=","MiddleEnglishStresser","(","enm_syllabifier",")",">",">",">","stresser.stress","(","'beren","'",",","stress_rule=","''","FSR","''",")","[","'ber","'",",","``","'en","''","]",">",">",">","stresser.stress","(","'prendre","'",",","stress_rule=","''","FSR","''",")","[","``","'pren","''",",","'dre","'","]",">",">",">","stresser.stress","(","'yisterday","'",",","stress_rule=","''","GSR","''",")","[","'yi","'",",","'ster","'",",","``","'day","''","]",">",">",">","stresser.stress","(","'day","'",",","stress_rule=","''","GSR","''",")","[","'day","'","]",">",">",">","stresser.stress","(","'mervelus","'",",","stress_rule=","''","LSR","''",")","[","``","'mer","''",",","'vel","'",",","'us","'","]",">",">",">","stresser.stress","(","'verbum","'",",","stress_rule=","''","LSR","''",")","[","'ver","'",",","``","'bum","''","]"]
code: def stress(self, word, stress_rule="FSR") -> List:
      """
      :param word: word to stress
      :param stress_rule: Stress Rule, valid options:
  
          'FSR': French Stress Rule, stress falls on the ultima, unless it contains schwa (ends with e), in which case the penult is stressed.
  
          'GSR': Germanic Stress Rule, stress falls on the first syllable of the stemm. Note that the accuracy of the function directly depends on that of the stemmer.
  
          'LSR': Latin Stress Rule, stress falls on the penult if its heavy, else, if it has more than two syllables on the antepenult, else on the ultima.
  
      :return: A list containing the separate syllable, where the stressed syllable is prefixed by ' . Monosyllabic words are left unchanged, since stress indicates relative emphasis.
  
      Examples:
  
      >>> from cltk.phonology.syllabify import Syllabifier
      >>> from cltk.phonology.enm.syllabifier import DIPHTHONGS, TRIPHTHONGS, SHORT_VOWELS, LONG_VOWELS
      >>> enm_syllabifier = Syllabifier()
      >>> enm_syllabifier.set_short_vowels(SHORT_VOWELS)
      >>> enm_syllabifier.set_vowels(SHORT_VOWELS+LONG_VOWELS)
      >>> enm_syllabifier.set_diphthongs(DIPHTHONGS)
      >>> enm_syllabifier.set_triphthongs(TRIPHTHONGS)
      >>> stresser = MiddleEnglishStresser(enm_syllabifier)
      >>> stresser.stress('beren', stress_rule="FSR")
      ['ber', "'en"]
      >>> stresser.stress('prendre', stress_rule="FSR")
      ["'pren", 'dre']
      >>> stresser.stress('yisterday', stress_rule="GSR")
      ['yi', 'ster', "'day"]
      >>> stresser.stress('day', stress_rule="GSR")
      ['day']
      >>> stresser.stress('mervelus', stress_rule="LSR")
      ["'mer", 'vel', 'us']
      >>> stresser.stress('verbum', stress_rule="LSR")
      ['ver', "'bum"]
  
      """
  
      assert self.syllabifier is not None
  
      # Syllabify word
      syllabified = self.syllabifier.syllabify(word, mode="MOP")
  
      # Check whether word is monosyllabic
      if len(syllabified) == 1:
          return syllabified
  
      if stress_rule == "FSR":
          # Check whether ultima ends in e
          if syllabified[-1][-1] == "e":
              return (
                  syllabified[:-2]
                  + ["'{0}".format(syllabified[-2])]
                  + syllabified[-1:]
              )
  
          else:
              return syllabified[:-1] + ["'{0}".format(syllabified[-1])]
  
      elif stress_rule == "GSR":
          # The word striped of suffixes
          st_word = stem(word, strip_suf=False)
          affix = word[: len(word) - len(st_word)]
  
          # Syllabify stripped word and affix
  
          syl_word = self.syllabifier.syllabify(st_word, mode="MOP")
  
          # Add stress
          syl_word = ["'{0}".format(syl_word[0])] + syl_word[1:]
  
          if affix:
              affix = self.syllabifier.syllabify(affix, mode="MOP")
              syl_word = affix + syl_word
  
          return syl_word
  
      elif stress_rule == "LSR":
          # Check whether penult is heavy (contains more than one mora)
          if sum(map(lambda x: x in SHORT_VOWELS, syllabified[-1])) > 1:
              return (
                  syllabified[:-2]
                  + ["'{0}".format(syllabified[-2])]
                  + syllabified[-1:]
              )
  
          elif len(syllabified) > 2:
              return (
                  syllabified[:-3]
                  + ["'{0}".format(syllabified[-3])]
                  + syllabified[-2:]
              )
  
          else:
              return syllabified[:-1] + ["'{0}".format(syllabified[-1])]
  
file_path: cltk/src/cltk/phonology/enm/stress.py
imports: import re
  from typing import List
  from cltk.phonology.enm.syllabifier import CONSONANTS, DIPHTHONGS, SHORT_VOWELS, TRIPHTHONGS
  from cltk.stem.enm import stem
label_desc: Use image node_id 2 for calling the MiddleEnglishStresser obj's underlying member method code with example usage: obj.stress(word, stress_rule) and returns: syllabified, unknown, unknown, syl_word, unknown, unknown, unknown