Preprocessing/generate_romanization.py
def segment_str(self, string: str) -> list:
        """
        Converts string to a list, treating all the items in long_chars
        as single characters.

        """
        segments = []
        
        i = 0
        while i < len(string):
            if string[i] not in self.long_chars:
                segments.append(string[i])
                i += 1
             
            # accounts for multi-char "characters"
            else:
                candidates = []
                curr = self.long_chars[string[i]]
                j = i + 1
                while j < len(string) and string[j] in curr:
                    curr = curr[string[j]]
                    j += 1
                    if END in curr:
                        candidates.append(curr[END])
                        
                if len(candidates) == 0:
                    segments.append(string[i])
                    i += 1
                    
                else:
                    segments.append(candidates.pop())
                    i += len(segments[-1])
                    
                    
        return(segments)

        Converts string to a list, treating all the items in long_chars
        as single characters.

        
Converts string to a list, treating all the items in long_chars
as single characters.
Converts string to a list treating all the items in long_chars as single characters .
def segment_str(self, string: str) -> list:
        segments = []
        i = 0
        while i < len(string):
            if string[i] not in self.long_chars:
                segments.append(string[i])
                i += 1
            else:
                candidates = []
                curr = self.long_chars[string[i]]
                j = i + 1
                while j < len(string) and string[j] in curr:
                    curr = curr[string[j]]
                    j += 1
                    if END in curr:
                        candidates.append(curr[END])
                if len(candidates) == 0:
                    segments.append(string[i])
                    i += 1
                else:
                    segments.append(candidates.pop())
                    i += len(segments[-1])
        return(segments)
def segment_str ( self , string : str ) -> list : segments = [ ] i = 0 while i < len ( string ) : if string [ i ] not in self . long_chars : segments . append ( string [ i ] ) i += 1 else : candidates = [ ] curr = self . long_chars [ string [ i ] ] j = i + 1 while j < len ( string ) and string [ j ] in curr : curr = curr [ string [ j ] ] j += 1 if END in curr : candidates . append ( curr [ END ] ) if len ( candidates ) == 0 : segments . append ( string [ i ] ) i += 1 else : segments . append ( candidates . pop ( ) ) i += len ( segments [ - 1 ] ) return ( segments )
Converts string to a list, treating all the items in long_chars
as single characters.
Converts string to a list treating all the items in long_chars as single characters .
"""
        Converts string to a list, treating all the items in long_chars
        as single characters.

        """ # accounts for multi-char "characters"
self
string
str