# Path: neuronlp2/io/instance.py
# class DependencyInstance(object):
#     def __init__(self, sentence, postags, pos_ids, heads, types, type_ids):
#         self.sentence = sentence
#         self.postags = postags
#         self.pos_ids = pos_ids
#         self.heads = heads
#         self.types = types
#         self.type_ids = type_ids
# 
#     def length(self):
#         return self.sentence.length()
# 
# class NERInstance(object):
#     def __init__(self, sentence, postags, pos_ids, chunk_tags, chunk_ids, ner_tags, ner_ids):
#         self.sentence = sentence
#         self.postags = postags
#         self.pos_ids = pos_ids
#         self.chunk_tags = chunk_tags
#         self.chunk_ids = chunk_ids
#         self.ner_tags = ner_tags
#         self.ner_ids = ner_ids
# 
#     def length(self):
#         return self.sentence.length()
# 
# Path: neuronlp2/io/instance.py
# class Sentence(object):
#     def __init__(self, words, word_ids, char_seqs, char_id_seqs):
#         self.words = words
#         self.word_ids = word_ids
#         self.char_seqs = char_seqs
#         self.char_id_seqs = char_id_seqs
# 
#     def length(self):
#         return len(self.words)
# 
# Path: neuronlp2/io/common.py
# ROOT = "_ROOT"
# 
# ROOT_POS = "_ROOT_POS"
# 
# ROOT_CHAR = "_ROOT_CHAR"
# 
# ROOT_TYPE = "_<ROOT>"
# 
# END = "_END"
# 
# END_POS = "_END_POS"
# 
# END_CHAR = "_END_CHAR"
# 
# END_TYPE = "_<END>"
# 
# Path: neuronlp2/io/common.py
# DIGIT_RE = re.compile(r"\d")
# 
# MAX_CHAR_LENGTH = 45


from neuronlp2.io.instance import DependencyInstance, NERInstance
from neuronlp2.io.instance import Sentence
from neuronlp2.io.common import ROOT, ROOT_POS, ROOT_CHAR, ROOT_TYPE, END, END_POS, END_CHAR, END_TYPE
from neuronlp2.io.common import DIGIT_RE, MAX_CHAR_LENGTH
            pos_ids.append(self.__pos_alphabet.get_index(END_POS))
            types.append(END_TYPE)
            type_ids.append(self.__type_alphabet.get_index(END_TYPE))
            heads.append(0)

        return DependencyInstance(Sentence(words, word_ids, char_seqs, char_id_seqs), postags, pos_ids, heads, types, type_ids)


class CoNLL03Reader(object):
    def __init__(self, file_path, word_alphabet, char_alphabet, pos_alphabet, chunk_alphabet, ner_alphabet):
        self.__source_file = open(file_path, 'r')
        self.__word_alphabet = word_alphabet
        self.__char_alphabet = char_alphabet
        self.__pos_alphabet = pos_alphabet
        self.__chunk_alphabet = chunk_alphabet
        self.__ner_alphabet = ner_alphabet

    def close(self):
        self.__source_file.close()

    def getNext(self, normalize_digits=True):
        line = self.__source_file.readline()
        # skip multiple blank lines.
        while len(line) > 0 and len(line.strip()) == 0:
            line = self.__source_file.readline()
        if len(line) == 0:
            return None

        lines = []
        while len(line.strip()) > 0:

# Path: neuronlp2/io/instance.py
# class DependencyInstance(object):
#     def __init__(self, sentence, postags, pos_ids, heads, types, type_ids):
#         self.sentence = sentence
#         self.postags = postags
#         self.pos_ids = pos_ids
#         self.heads = heads
#         self.types = types
#         self.type_ids = type_ids
# 
#     def length(self):
#         return self.sentence.length()
# 
# class NERInstance(object):
#     def __init__(self, sentence, postags, pos_ids, chunk_tags, chunk_ids, ner_tags, ner_ids):
#         self.sentence = sentence
#         self.postags = postags
#         self.pos_ids = pos_ids
#         self.chunk_tags = chunk_tags
#         self.chunk_ids = chunk_ids
#         self.ner_tags = ner_tags
#         self.ner_ids = ner_ids
# 
#     def length(self):
#         return self.sentence.length()
# 
# Path: neuronlp2/io/instance.py
# class Sentence(object):
#     def __init__(self, words, word_ids, char_seqs, char_id_seqs):
#         self.words = words
#         self.word_ids = word_ids
#         self.char_seqs = char_seqs
#         self.char_id_seqs = char_id_seqs
# 
#     def length(self):
#         return len(self.words)
# 
# Path: neuronlp2/io/common.py
# ROOT = "_ROOT"
# 
# ROOT_POS = "_ROOT_POS"
# 
# ROOT_CHAR = "_ROOT_CHAR"
# 
# ROOT_TYPE = "_<ROOT>"
# 
# END = "_END"
# 
# END_POS = "_END_POS"
# 
# END_CHAR = "_END_CHAR"
# 
# END_TYPE = "_<END>"
# 
# Path: neuronlp2/io/common.py
# DIGIT_RE = re.compile(r"\d")
# 
# MAX_CHAR_LENGTH = 45


# Path: neuronlp2/io/reader.py
from neuronlp2.io.instance import DependencyInstance, NERInstance
from neuronlp2.io.instance import Sentence
from neuronlp2.io.common import ROOT, ROOT_POS, ROOT_CHAR, ROOT_TYPE, END, END_POS, END_CHAR, END_TYPE
from neuronlp2.io.common import DIGIT_RE, MAX_CHAR_LENGTH

            pos_ids.append(self.__pos_alphabet.get_index(END_POS))
            types.append(END_TYPE)
            type_ids.append(self.__type_alphabet.get_index(END_TYPE))
            heads.append(0)

        return DependencyInstance(Sentence(words, word_ids, char_seqs, char_id_seqs), postags, pos_ids, heads, types, type_ids)


class CoNLL03Reader(object):
    def __init__(self, file_path, word_alphabet, char_alphabet, pos_alphabet, chunk_alphabet, ner_alphabet):
        self.__source_file = open(file_path, 'r')
        self.__word_alphabet = word_alphabet
        self.__char_alphabet = char_alphabet
        self.__pos_alphabet = pos_alphabet
        self.__chunk_alphabet = chunk_alphabet
        self.__ner_alphabet = ner_alphabet

    def close(self):
        self.__source_file.close()

    def getNext(self, normalize_digits=True):
        line = self.__source_file.readline()
        # skip multiple blank lines.
        while len(line) > 0 and len(line.strip()) == 0:
            line = self.__source_file.readline()
        if len(line) == 0:
            return None

        lines = []
        while len(line.strip()) > 0:

            line = line.strip()