class_docstr: Provides 2 main methods that syllabify words given phonology of its language.
docstr: Filters syllable respecting the legality principle
  
  :param syllables: list of syllables
  
  The method scans for invalid syllable onsets:
  
  >>> s = Syllabifier(["i", "u", "y"], ["o", "ø", "e"], ["a"], ["r"], ["l"], ["m", "n"], ["f", "v", "s", "h"], ["k", "g", "b", "p", "t", "d"])
  >>> s.set_invalid_onsets(['lm'])
  >>> s.legal_onsets(['a', 'lma', 'tigr'])
  ['al', 'ma', 'tigr']
  
  You can also define invalid syllable ultima:
  
  >>> s.set_invalid_ultima(['gr'])
  >>> s.legal_onsets(['al', 'ma', 'ti', 'gr'])
  ['al', 'ma', 'tigr']
docstr_tok: ["Filters","syllable","respecting","the","legality","principle",":","param","syllables",":","list","of","syllables","The","method","scans","for","invalid","syllable","onsets",":",">",">",">","s","=","Syllabifier","(","[","``","i","''",",","``","u","''",",","``","y","''","]",",","[","``","o","''",",","``","\u00f8","''",",","``","e","''","]",",","[","``","a","''","]",",","[","``","r","''","]",",","[","``","l","''","]",",","[","``","m","''",",","``","n","''","]",",","[","``","f","''",",","``","v","''",",","``","s","''",",","``","h","''","]",",","[","``","k","''",",","``","g","''",",","``","b","''",",","``","p","''",",","``","t","''",",","``","d","''","]",")",">",">",">","s.set_invalid_onsets","(","[","'lm","'","]",")",">",">",">","s.legal_onsets","(","[","'","a","'",",","'lma","'",",","'tigr","'","]",")","[","'al","'",",","'ma","'",",","'tigr","'","]","You","can","also","define","invalid","syllable","ultima",":",">",">",">","s.set_invalid_ultima","(","[","'gr","'","]",")",">",">",">","s.legal_onsets","(","[","'al","'",",","'ma","'",",","'ti","'",",","'gr","'","]",")","[","'al","'",",","'ma","'",",","'tigr","'","]"]
code: def legal_onsets(self, syllables: List[str]) -> List[str]:
      """
      Filters syllable respecting the legality principle
  
      :param syllables: list of syllables
  
      The method scans for invalid syllable onsets:
  
      >>> s = Syllabifier(["i", "u", "y"], ["o", "ø", "e"], ["a"], ["r"], ["l"], ["m", "n"], ["f", "v", "s", "h"], ["k", "g", "b", "p", "t", "d"])
      >>> s.set_invalid_onsets(['lm'])
      >>> s.legal_onsets(['a', 'lma', 'tigr'])
      ['al', 'ma', 'tigr']
  
      You can also define invalid syllable ultima:
  
      >>> s.set_invalid_ultima(['gr'])
      >>> s.legal_onsets(['al', 'ma', 'ti', 'gr'])
      ['al', 'ma', 'tigr']
      """
  
      vowels = self.vowels
  
      for i in range(1, len(syllables)):
          onset = ""
  
          for letter in syllables[i]:
              if letter in vowels:
                  break
  
              onset += letter
  
          for j in range(len(onset)):
              # Check whether the given onset is valid
              if onset[j:] not in self.invalid_onsets:
                  syllables[i - 1] += onset[:j]
                  syllables[i] = syllables[i][j:]
                  break
  
      # Check whether ultima is invalid
  
      if syllables[-1] in self.invalid_ultima:
          syllables[-2] += syllables[-1]
          syllables = syllables[:-1]
  
      return syllables
  
imports: import logging
  import unicodedata
  from collections import defaultdict
  from typing import List, Union
  import cltk.phonology.ang.syllabifier
  import cltk.phonology.enm.syllabifier
  import cltk.phonology.gmh.syllabifier
  import cltk.phonology.non.syllabifier
  import cltk.phonology.non.utils
  from cltk.core.exceptions import CLTKException
label_desc: Use image node_id 9 for calling the Syllabifier obj's underlying member method code with example usage: obj.legal_onsets(syllables) and returns: syllables