@@ -0,0 +1,2502 @@
+import os%0A%0Afrom teras.base import Iterator%0A%0A%0Aclass Reader(Iterator):%0A%0A    def __init__(self, file=None):%0A        self.set_file(file)%0A%0A    def set_file(self, file):%0A        file = os.path.expanduser(file)%0A        if not os.path.exists(file):%0A            raise FileNotFoundError(%22file was not found: '%7B%7D'%22%0A                                    .format(file))%0A        self.file = file%0A        self.reset()%0A%0A    def __iter__(self):%0A        self._iterator = self._get_iterator()%0A        return self%0A%0A    def __next__(self):%0A        return self._iterator.__next__()%0A%0A    def read(self, file=None):%0A        if file is not None:%0A            self.set_file(file)%0A        items = %5Bitem for item in self%5D%0A        return items%0A%0A    def read_next(self):%0A        if self._iterator is None:%0A            self._iterator = self._get_iterator()%0A        return self._iterator.__next__()%0A%0A    def reset(self):%0A        self._iterator = None%0A%0A    def _get_iterator(self):%0A        with open(self.file, mode='r') as f:%0A            for line in f:%0A                yield line.strip()%0A%0A%0Aclass ConllReader(Reader):%0A%0A    def create_root(self):%0A        root = %7B%0A            'id': 0,%0A            'form': %22%3CROOT%3E%22,%0A            'lemma': %22%3CROOT%3E%22,%0A            'cpostag': %22ROOT%22,%0A            'postag':  %22ROOT%22,%0A            'feats':   %22_%22,%0A            'head': 0,%0A            'deprel':  %22root%22,%0A            'phead':   %22_%22,%0A            'pdeprel': %22_%22,%0A        %7D%0A        return root%0A%0A    def _get_iterator(self):%0A        with open(self.file, mode='r') as f:%0A            tokens = %5Bself.create_root()%5D%0A            for line in f:%0A                line = line.strip()%0A                if not line:%0A                    if len(tokens) %3E 1:%0A                        yield tokens%0A                        tokens = %5Bself.create_root()%5D%0A                elif line.startswith('#'):%0A                    continue%0A                else:%0A                    cols = line.split(%22%5Ct%22)%0A                    token = %7B%0A                        'id': int(cols%5B0%5D),%0A                        'form': cols%5B1%5D,%0A                        'lemma': cols%5B2%5D,%0A                        'cpostag': cols%5B3%5D,%0A                        'postag': cols%5B4%5D,%0A                        'feats': cols%5B5%5D,%0A                        'head': int(cols%5B6%5D),%0A                        'deprel': cols%5B7%5D,%0A                        'phead': cols%5B8%5D,%0A                        'pdeprel': cols%5B9%5D,%0A                    %7D%0A                    tokens.append(token)%0A            if len(tokens) %3E 1:%0A                yield tokens%0A

implement reader.