1515# specific language governing permissions and limitations
1616# under the License.
1717
18- import six
19-
2018from .connections import get_connection
2119from .utils import AttrDict , DslBase , merge
2220
2321__all__ = ["tokenizer" , "analyzer" , "char_filter" , "token_filter" , "normalizer" ]
2422
2523
26- class AnalysisBase ( object ) :
24+ class AnalysisBase :
2725 @classmethod
2826 def _type_shortcut (cls , name_or_instance , type = None , ** kwargs ):
2927 if isinstance (name_or_instance , cls ):
3028 if type or kwargs :
31- raise ValueError ("%s () cannot accept parameters." % cls . __name__ )
29+ raise ValueError (f" { cls . __name__ } () cannot accept parameters." )
3230 return name_or_instance
3331
3432 if not (type or kwargs ):
@@ -39,20 +37,20 @@ def _type_shortcut(cls, name_or_instance, type=None, **kwargs):
3937 )
4038
4139
42- class CustomAnalysis ( object ) :
40+ class CustomAnalysis :
4341 name = "custom"
4442
4543 def __init__ (self , filter_name , builtin_type = "custom" , ** kwargs ):
4644 self ._builtin_type = builtin_type
4745 self ._name = filter_name
48- super (CustomAnalysis , self ).__init__ (** kwargs )
46+ super ().__init__ (** kwargs )
4947
5048 def to_dict (self ):
5149 # only name to present in lists
5250 return self ._name
5351
5452 def get_definition (self ):
55- d = super (CustomAnalysis , self ).to_dict ()
53+ d = super ().to_dict ()
5654 d = d .pop (self .name )
5755 d ["type" ] = self ._builtin_type
5856 return d
@@ -92,12 +90,12 @@ def get_analysis_definition(self):
9290 return out
9391
9492
95- class BuiltinAnalysis ( object ) :
93+ class BuiltinAnalysis :
9694 name = "builtin"
9795
9896 def __init__ (self , name ):
9997 self ._name = name
100- super (BuiltinAnalysis , self ).__init__ ()
98+ super ().__init__ ()
10199
102100 def to_dict (self ):
103101 # only name to present in lists
@@ -148,7 +146,7 @@ def simulate(self, text, using="default", explain=False, attributes=None):
148146 sec_def = definition .get (section , {})
149147 sec_names = analyzer_def [section ]
150148
151- if isinstance (sec_names , six . string_types ):
149+ if isinstance (sec_names , str ):
152150 body [section ] = sec_def .get (sec_names , sec_names )
153151 else :
154152 body [section ] = [
@@ -213,7 +211,7 @@ def get_definition(self):
213211 if "filters" in d :
214212 d ["filters" ] = [
215213 # comma delimited string given by user
216- fs if isinstance (fs , six . string_types ) else
214+ fs if isinstance (fs , str ) else
217215 # list of strings or TokenFilter objects
218216 ", " .join (f .to_dict () if hasattr (f , "to_dict" ) else f for f in fs )
219217 for fs in self .filters
@@ -227,7 +225,7 @@ def get_analysis_definition(self):
227225 fs = {}
228226 d = {"filter" : fs }
229227 for filters in self .filters :
230- if isinstance (filters , six . string_types ):
228+ if isinstance (filters , str ):
231229 continue
232230 fs .update (
233231 {
0 commit comments