Next / Previous / Contents / Shipman's homepage

22.1. SpTail.__init__()

nomcompile3
# - - -   S p T a i l . _ _ i n i t _ _

    def __init__ ( self, scan ):
        '''Constructor for SpTail.
        '''

In the general case, the species tail has three parts, separated by slashes: the “Genus (Subgenus) species” part, the English name, and optionally the disambiguated bird code. Here are some examples:

   Geopelia striata/Dove, Zebra
   Regulus (Regulus) satrapa/Kinglet, Golden-crowned
   Tyto alba/Owl, Barn/BRNOWL

The processing of the first part is handled in Section 22.2, “SpTail.__scanSci().

nomcompile3
        #-- 1 --
        # [ if scan starts with a valid scientific name group ->
        #     scan  :=  scan advanced past that group
        #     self.genus  :=  genus name from that group
        #     self.subgenus  :=  subgenus name from that group
        #                        or None if missing
        #     self.species  :=  species name from that group
        #   else ->
        #     scan  :=  scan advanced no further than end of line
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        self.__scanSci ( scan )

We use the pattern from Section 6.24, “SLASH_RE to scan the separating slash and any adjacent whitespace.

nomcompile3
        #-- 2 --
        # [ if scan starts with "/", optionally preceded and
        #   followed by whitespace ->
        #     scan  :=  scan advanced past all that
        #   else ->
        #     scan  :=  scan advanced no further than end of line
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        m = scan.tabReMatch ( SLASH_RE )
        if m is None:
            scan.syntax ( "Expecting the '/' after the scientific "
                          "name." )

What remains at this point is the English name, optionally followed by another slash and the disambiguated code. Hence, we see if there is a slash out there. If so, the English name is the part before it and the code is the part after it. If there is no slash remaining on this line, the rest is all the English name.

nomcompile3
        #-- 3 --
        # [ if there is a slash anywhere on the remainder of the
        #   line in scan ->
        #     scan  :=  scan advanced up to the first slash
        #     rawEng  :=  text up to the first slash, stripped
        #   else ->
        #     scan  :=  scan advanced to end of line
        #     rawEng  :=  balance of the line, stripped ]
        slashPos = scan.find ( '/' )
        if slashPos is None:
            rawEng = scan.tab(-1).strip()
        else:
            rawEng = scan.tab(slashPos).strip()

The English name may need to be rearranged: “Hawk, Gray” must be stored as “Gray Hawk”. See Section 22.3, “SpTail.__checkEng(): Check the English name”.

nomcompile3
        #-- 4 --
        # [ if rawEng is a valid English name ->
        #     self.eng  :=  rawEng
        #     self.canonical  :=  abbrMod.abbreviate ( eng-normalize (
        #                         rawEng ) )
        #   else ->
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        self.__checkEng ( scan, rawEng )

Then, if there is a disambiguation, it is validated by Section 22.4, “SpTail.__checkDisamb(): Check the disambiguation”.

nomcompile3
        #-- 5 --
        # [ if scan is at end of line ->
        #     self.disamb  :=  None
        #   else if the balance of the line in scan is a SLASH_RE
        #   followed by a code matching abbrMod.RE_ABBR ->
        #     scan  :=  scan advanced to end of line
        #     self.disamb  :=  that code, stripped and uppercased
        #   else ->
        #     scan  :=  scan advanced not past end of line
        #     Log()  +:=  error message
        #     raise SyntaxError ]
        self.__checkDisamb ( scan )