def scanner(self, state, chart_index): # given a POS rule, see if the current word is that POS # then add it to the next chart: Verb-->book * [0,1] # advancing the dot #if self.debug: #print " scanner considering:" , #state.printme() pos = state.get_next_symbol() if chart_index < len(self.words): word = self.words[chart_index] rule = self.get_word_pos(word, pos) ##print " scanner considering:" , word, rule if rule != None: if not self.is_rule_in_state(rule, self.chart[chart_index + 1]): new_rule = RuleState(pos, [word], 1, chart_index, chart_index + 1, rule.get_semantics(), rule.get_semantics_txt()) if self.debug: print "scanner adding to: ", chart_index + 1 print "scanner :", new_rule.printme() self.chart[chart_index + 1].append(new_rule) else: if True: #self.debug: print " canner not adding", state.printme()
def scanner(self, state, chart_index): # given a POS rule, see if the current word is that POS # then add it to the next chart: Verb-->book * [0,1] # advancing the dot pos = state.get_next_symbol() if chart_index < len(self.words): word = self.words[chart_index] rule = self.get_word_pos(word, pos) if rule != None: if not self.is_rule_in_state(rule, self.chart[chart_index + 1]): new_rule = RuleState(pos, [word], 1, chart_index, chart_index + 1, rule.get_semantics()) print "scanner :", new_rule.printme() self.chart[chart_index + 1].append(new_rule)
#!/usr/bin/python from ruleState import RuleState from early import Early import sys r = RuleState("x-->test,x") r.Test()