class_docstr: A word stemmer based on the Porter stemming algorithm.
  
      Porter, M. "An algorithm for suffix stripping."
      Program 14.3 (1980): 130-137.
  
  See https://www.tartarus.org/~martin/PorterStemmer/ for the homepage
  of the algorithm.
  
  Martin Porter has endorsed several modifications to the Porter
  algorithm since writing his original paper, and those extensions are
  included in the implementations on his website. Additionally, others
  have proposed further improvements to the algorithm, including NLTK
  contributors. There are thus three modes that can be selected by
  passing the appropriate constant to the class constructor's `mode`
  attribute:
  
  - PorterStemmer.ORIGINAL_ALGORITHM
  
      An implementation that is faithful to the original paper.
  
      Note that Martin Porter has deprecated this version of the
      algorithm. Martin distributes implementations of the Porter
      Stemmer in many languages, hosted at:
  
      https://www.tartarus.org/~martin/PorterStemmer/
  
      and all of these implementations include his extensions. He
      strongly recommends against using the original, published
      version of the algorithm; only use this mode if you clearly
      understand why you are choosing to do so.
  
  - PorterStemmer.MARTIN_EXTENSIONS
  
      An implementation that only uses the modifications to the
      algorithm that are included in the implementations on Martin
      Porter's website. He has declared Porter frozen, so the
      behaviour of those implementations should never change.
  
  - PorterStemmer.NLTK_EXTENSIONS (default)
  
      An implementation that includes further improvements devised by
      NLTK contributors or taken from other modified implementations
      found on the web.
  
  For the best stemming, you should use the default NLTK_EXTENSIONS
  version. However, if you need to get the same results as either the
  original algorithm or one of Martin Porter's hosted versions for
  compatibility with an existing implementation or dataset, you can use
  one of the other modes instead.
class_docstr_tok: ["A","word","stemmer","based","on","the","Porter","stemming","algorithm",".","Porter",",","M.","``","An","algorithm","for","suffix","stripping",".","''","Program","14.3","(","1980",")",":","130-137",".","See","https",":","\/\/www.tartarus.org\/~martin\/PorterStemmer\/","for","the","homepage","of","the","algorithm",".","Martin","Porter","has","endorsed","several","modifications","to","the","Porter","algorithm","since","writing","his","original","paper",",","and","those","extensions","are","included","in","the","implementations","on","his","website",".","Additionally",",","others","have","proposed","further","improvements","to","the","algorithm",",","including","NLTK","contributors",".","There","are","thus","three","modes","that","can","be","selected","by","passing","the","appropriate","constant","to","the","class","constructor","'s","`","mode","`","attribute",":","-","PorterStemmer.ORIGINAL_ALGORITHM","An","implementation","that","is","faithful","to","the","original","paper",".","Note","that","Martin","Porter","has","deprecated","this","version","of","the","algorithm",".","Martin","distributes","implementations","of","the","Porter","Stemmer","in","many","languages",",","hosted","at",":","https",":","\/\/www.tartarus.org\/~martin\/PorterStemmer\/","and","all","of","these","implementations","include","his","extensions",".","He","strongly","recommends","against","using","the","original",",","published","version","of","the","algorithm",";","only","use","this","mode","if","you","clearly","understand","why","you","are","choosing","to","do","so",".","-","PorterStemmer.MARTIN_EXTENSIONS","An","implementation","that","only","uses","the","modifications","to","the","algorithm","that","are","included","in","the","implementations","on","Martin","Porter","'s","website",".","He","has","declared","Porter","frozen",",","so","the","behaviour","of","those","implementations","should","never","change",".","-","PorterStemmer.NLTK_EXTENSIONS","(","default",")","An","implementation","that","includes","further","improvements","devised","by","NLTK","contributors","or","taken","from","other","modified","implementations","found","on","the","web",".","For","the","best","stemming",",","you","should","use","the","default","NLTK_EXTENSIONS","version",".","However",",","if","you","need","to","get","the","same","results","as","either","the","original","algorithm","or","one","of","Martin","Porter","'s","hosted","versions","for","compatibility","with","an","existing","implementation","or","dataset",",","you","can","use","one","of","the","other","modes","instead","."]
docstr: Implements Step 1b from "An algorithm for suffix stripping"
  
  From the paper:
  
      (m>0) EED -> EE                    feed      ->  feed
                                         agreed    ->  agree
      (*v*) ED  ->                       plastered ->  plaster
                                         bled      ->  bled
      (*v*) ING ->                       motoring  ->  motor
                                         sing      ->  sing
  
  If the second or third of the rules in Step 1b is successful,
  the following is done:
  
      AT -> ATE                       conflat(ed)  ->  conflate
      BL -> BLE                       troubl(ed)   ->  trouble
      IZ -> IZE                       siz(ed)      ->  size
      (*d and not (*L or *S or *Z))
         -> single letter
                                      hopp(ing)    ->  hop
                                      tann(ed)     ->  tan
                                      fall(ing)    ->  fall
                                      hiss(ing)    ->  hiss
                                      fizz(ed)     ->  fizz
      (m=1 and *o) -> E               fail(ing)    ->  fail
                                      fil(ing)     ->  file
  
  The rule to map to a single letter causes the removal of one of
  the double letter pair. The -E is put back on -AT, -BL and -IZ,
  so that the suffixes -ATE, -BLE and -IZE can be recognised
  later. This E may be removed in step 4.
docstr_tok: ["Implements","Step","1b","from","``","An","algorithm","for","suffix","stripping","''","From","the","paper",":","(","m",">","0",")","EED","-",">","EE","feed","-",">","feed","agreed","-",">","agree","(","*","v","*",")","ED","-",">","plastered","-",">","plaster","bled","-",">","bled","(","*","v","*",")","ING","-",">","motoring","-",">","motor","sing","-",">","sing","If","the","second","or","third","of","the","rules","in","Step","1b","is","successful",",","the","following","is","done",":","AT","-",">","ATE","conflat","(","ed",")","-",">","conflate","BL","-",">","BLE","troubl","(","ed",")","-",">","trouble","IZ","-",">","IZE","siz","(","ed",")","-",">","size","(","*","d","and","not","(","*","L","or","*","S","or","*","Z",")",")","-",">","single","letter","hopp","(","ing",")","-",">","hop","tann","(","ed",")","-",">","tan","fall","(","ing",")","-",">","fall","hiss","(","ing",")","-",">","hiss","fizz","(","ed",")","-",">","fizz","(","m=1","and","*","o",")","-",">","E","fail","(","ing",")","-",">","fail","fil","(","ing",")","-",">","file","The","rule","to","map","to","a","single","letter","causes","the","removal","of","one","of","the","double","letter","pair",".","The","-E","is","put","back","on","-AT",",","-BL","and","-IZ",",","so","that","the","suffixes","-ATE",",","-BLE","and","-IZE","can","be","recognised","later",".","This","E","may","be","removed","in","step","4","."]
code: def _step1b(self, word):
      """Implements Step 1b from "An algorithm for suffix stripping"
  
      From the paper:
  
          (m>0) EED -> EE                    feed      ->  feed
                                             agreed    ->  agree
          (*v*) ED  ->                       plastered ->  plaster
                                             bled      ->  bled
          (*v*) ING ->                       motoring  ->  motor
                                             sing      ->  sing
  
      If the second or third of the rules in Step 1b is successful,
      the following is done:
  
          AT -> ATE                       conflat(ed)  ->  conflate
          BL -> BLE                       troubl(ed)   ->  trouble
          IZ -> IZE                       siz(ed)      ->  size
          (*d and not (*L or *S or *Z))
             -> single letter
                                          hopp(ing)    ->  hop
                                          tann(ed)     ->  tan
                                          fall(ing)    ->  fall
                                          hiss(ing)    ->  hiss
                                          fizz(ed)     ->  fizz
          (m=1 and *o) -> E               fail(ing)    ->  fail
                                          fil(ing)     ->  file
  
      The rule to map to a single letter causes the removal of one of
      the double letter pair. The -E is put back on -AT, -BL and -IZ,
      so that the suffixes -ATE, -BLE and -IZE can be recognised
      later. This E may be removed in step 4.
      """
      # this NLTK-only block extends the original algorithm, so that
      # 'spied'->'spi' but 'died'->'die' etc
      if self.mode == self.NLTK_EXTENSIONS:
          if word.endswith("ied"):
              if len(word) == 4:
                  return self._replace_suffix(word, "ied", "ie")
              else:
                  return self._replace_suffix(word, "ied", "i")
  
      # (m>0) EED -> EE
      if word.endswith("eed"):
          stem = self._replace_suffix(word, "eed", "")
          if self._measure(stem) > 0:
              return stem + "ee"
          else:
              return word
  
      rule_2_or_3_succeeded = False
  
      for suffix in ["ed", "ing"]:
          if word.endswith(suffix):
              intermediate_stem = self._replace_suffix(word, suffix, "")
              if self._contains_vowel(intermediate_stem):
                  rule_2_or_3_succeeded = True
                  break
  
      if not rule_2_or_3_succeeded:
          return word
  
      return self._apply_rule_list(
          intermediate_stem,
          [
              ("at", "ate", None),  # AT -> ATE
              ("bl", "ble", None),  # BL -> BLE
              ("iz", "ize", None),  # IZ -> IZE
              # (*d and not (*L or *S or *Z))
              # -> single letter
              (
                  "*d",
                  intermediate_stem[-1],
                  lambda stem: intermediate_stem[-1]
                  not in ("l", "s", "z"),
              ),
              # (m=1 and *o) -> E
              (
                  "",
                  "e",
                  lambda stem: (
                      self._measure(stem) == 1 and self._ends_cvc(stem)
                  ),
              ),
          ],
      )
  
imports: import re
  from nltk.stem.api import StemmerI
label_desc: Use image node_id 11 for calling the PorterStemmer obj's underlying member method code with example usage: obj._step1b(word) and returns: self, word, unknown, word, self, self