![]() add_state ( "error_state", None, end_state = 1 ) m. add_state ( "pos_state", None, end_state = 1 ) m. add_state ( "neg_state", None, end_state = 1 ) m. add_state ( "not_state", not_state_transitions ) m. add_state ( "is_state", is_state_transitions ) m. add_state ( "Python_state", python_state_transitions ) m. add_state ( "Start", start_transitions ) m. split ( None, 1 ) word, txt = splitted_txt if len ( splitted_txt ) > 1 else ( txt, "" ) if word in positive_adjectives : newState = "neg_state" elif word in negative_adjectives : newState = "pos_state" else : newState = "error_state" return ( newState, txt ) def neg_state ( txt ): print ( "Hallo" ) return ( "neg_state", "" ) m = StateMachine () m. split ( None, 1 ) word, txt = splitted_txt if len ( splitted_txt ) > 1 else ( txt, "" ) if word = "not" : newState = "not_state" elif word in positive_adjectives : newState = "pos_state" elif word in negative_adjectives : newState = "neg_state" else : newState = "error_state" return ( newState, txt ) def not_state_transitions ( txt ): splitted_txt = txt. split ( None, 1 ) word, txt = splitted_txt if len ( splitted_txt ) > 1 else ( txt, "" ) if word = "is" : newState = "is_state" else : newState = "error_state" return ( newState, txt ) def is_state_transitions ( txt ): splitted_txt = txt. split ( None, 1 ) word, txt = splitted_txt if len ( splitted_txt ) > 1 else ( txt, "" ) if word = "Python" : newState = "Python_state" else : newState = "error_state" return ( newState, txt ) def python_state_transitions ( txt ): splitted_txt = txt. Positive_adjectives = negative_adjectives = def start_transitions ( txt ): splitted_txt = txt. The definition is that the automaton accepts if its run ends. 'Final state' is a poor choice of name, and most authors seem to prefer 'accepting state'. The source of your confusion is that this isnt the definition.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |