2to3 (compiles, not tested)
[tag_parser.git] / src / mjacob / nltk / parse / tag / strategies.py
blobf77c33706c24a9ddffcd2b52226f47a533fb4c96
1 # This Python file uses the following encoding: utf-8
2 '''
3 Created on May 30, 2011
5 @author: mjacob
6 '''
7 from abc import abstractmethod, ABCMeta
9 class Strategy(tuple, metaclass=ABCMeta):
10 """represents a ChartParser strategy"""
12 def __new__(cls, edge_class, *rules):
13 return tuple.__new__(cls, rules)
15 def __init__(self, edge_class, *rules):
16 super(Strategy, self).__init__(rules)
17 self.__edge_class = edge_class
19 def edge_class(self):
20 return self.__edge_class
22 @abstractmethod
23 def goal_edges(self, chart, symbol): pass
25 def goal_found(self, chart, symbol):
26 try:
27 next(self.goal_edges(chart, symbol))
28 return True
29 except StopIteration:
30 return False