class_docstr: The scansion symbols used can be configured by passing a suitable constants class to
  the constructor.
docstr: The 'inverted amphibrach': stressed_unstressed_stressed syllable pattern is invalid
  in hexameters, so here we coerce it to stressed:  - U - -> - - -
  
  :param scansion: the scansion stress pattern
  :return: a string with the corrected scansion pattern
  
  >>> print(HexameterScanner().correct_inverted_amphibrachs(
  ... " -   U -   - U  -  U U U U  - U  - x")) # doctest: +NORMALIZE_WHITESPACE
  -   - -   - -  -  U U U U  - -  - x
  >>> print(HexameterScanner().correct_inverted_amphibrachs(
  ... " -   - -   U -  -  U U U U  U- - U  - x")) # doctest: +NORMALIZE_WHITESPACE
  -   - -   - -  -  U U U U  U- - -  - x
  >>> print(HexameterScanner().correct_inverted_amphibrachs(
  ... "-  - -   -  -   U -   U U -  U  U - -")) # doctest: +NORMALIZE_WHITESPACE
  -  - -   -  -   - -   U U -  U  U - -
  >>> print(HexameterScanner().correct_inverted_amphibrachs(
  ... "- UU-   U -   U -  -   U   U U   U-   U")) # doctest: +NORMALIZE_WHITESPACE
  - UU-   - -   - -  -   U   U U   U-   U
docstr_tok: ["The","'inverted","amphibrach","'",":","stressed_unstressed_stressed","syllable","pattern","is","invalid","in","hexameters",",","so","here","we","coerce","it","to","stressed",":","-","U","-","-",">","-","-","-",":","param","scansion",":","the","scansion","stress","pattern",":","return",":","a","string","with","the","corrected","scansion","pattern",">",">",">","print","(","HexameterScanner","(",")",".correct_inverted_amphibrachs","(","...","``","-","U","-","-","U","-","U","U","U","U","-","U","-","x","''",")",")","#","doctest",":","+NORMALIZE_WHITESPACE","-","-","-","-","-","-","U","U","U","U","-","-","-","x",">",">",">","print","(","HexameterScanner","(",")",".correct_inverted_amphibrachs","(","...","``","-","-","-","U","-","-","U","U","U","U","U-","-","U","-","x","''",")",")","#","doctest",":","+NORMALIZE_WHITESPACE","-","-","-","-","-","-","U","U","U","U","U-","-","-","-","x",">",">",">","print","(","HexameterScanner","(",")",".correct_inverted_amphibrachs","(","...","``","-","-","-","-","-","U","-","U","U","-","U","U","-","-","''",")",")","#","doctest",":","+NORMALIZE_WHITESPACE","-","-","-","-","-","-","-","U","U","-","U","U","-","-",">",">",">","print","(","HexameterScanner","(",")",".correct_inverted_amphibrachs","(","...","``","-","UU-","U","-","U","-","-","U","U","U","U-","U","''",")",")","#","doctest",":","+NORMALIZE_WHITESPACE","-","UU-","-","-","-","-","-","U","U","U","U-","U"]
code: def correct_inverted_amphibrachs(self, scansion: str) -> str:
      """
      The 'inverted amphibrach': stressed_unstressed_stressed syllable pattern is invalid
      in hexameters, so here we coerce it to stressed:  - U - -> - - -
  
      :param scansion: the scansion stress pattern
      :return: a string with the corrected scansion pattern
  
      >>> print(HexameterScanner().correct_inverted_amphibrachs(
      ... " -   U -   - U  -  U U U U  - U  - x")) # doctest: +NORMALIZE_WHITESPACE
      -   - -   - -  -  U U U U  - -  - x
      >>> print(HexameterScanner().correct_inverted_amphibrachs(
      ... " -   - -   U -  -  U U U U  U- - U  - x")) # doctest: +NORMALIZE_WHITESPACE
      -   - -   - -  -  U U U U  U- - -  - x
      >>> print(HexameterScanner().correct_inverted_amphibrachs(
      ... "-  - -   -  -   U -   U U -  U  U - -")) # doctest: +NORMALIZE_WHITESPACE
      -  - -   -  -   - -   U U -  U  U - -
      >>> print(HexameterScanner().correct_inverted_amphibrachs(
      ... "- UU-   U -   U -  -   U   U U   U-   U")) # doctest: +NORMALIZE_WHITESPACE
      - UU-   - -   - -  -   U   U U   U-   U
      """
      new_line = scansion
      while list(self.inverted_amphibrach_re.finditer(new_line)):
          matches = list(self.inverted_amphibrach_re.finditer(new_line))
          for match in matches:
              (
                  start,
                  end,
              ) = match.span()  # pylint: disable=unused-variable
              unstressed_idx = new_line.index(
                  self.constants.UNSTRESSED, start
              )
              new_line = (
                  new_line[:unstressed_idx]
                  + self.constants.STRESSED
                  + new_line[unstressed_idx + 1 :]
              )
      return new_line
  
file_path: cltk/src/cltk/prosody/lat/hexameter_scanner.py
imports: import re
  import cltk.prosody.lat.string_utils
  from cltk.prosody.lat.metrical_validator import MetricalValidator
  from cltk.prosody.lat.scansion_constants import ScansionConstants
  from cltk.prosody.lat.scansion_formatter import ScansionFormatter
  from cltk.prosody.lat.syllabifier import Syllabifier
  from cltk.prosody.lat.verse import Verse
  from cltk.prosody.lat.verse_scanner import VerseScanner
label_desc: Use image node_id 6 for calling the HexameterScanner obj's underlying member method code with example usage: obj.correct_inverted_amphibrachs(scansion) and returns: new_line