Ejemplo n.º 1
0
    def __init__(self):
        self.config = Config()
        if "glove" in self.config.WORD_VEC_MODEL_PATH:
            self.w2vmodel = w2VModel(self.config.WORD_VEC_MODEL_PATH, False)
        else:
            self.w2vmodel = w2VModel(self.config.WORD_VEC_MODEL_PATH)
        self.embDim = 200
        self.aim = 'train'  # train or test.
        # our vocabulary dictionary, dictionary value is 0 means padding idx.
        self.cateVocab = {}
        # self.path = self.config.get_train_path()
        # self.path1 = self.config.TEST_FILE_PATH
        # our vocabulary dictionary, dictionary value is 0 means padding idx.
        self.vocabToOld = {}
        self.vocabToNew = {}
        self.train_data, self.train_label = self.readFile(
            self.config.get_train_path())
        self.test_data, self.test_label = self.readFile(
            self.config.get_test_path())
        self.data = self.train_data + self.test_data
        self.label = self.train_label + self.test_label
        self.buildVocab()
        self.numVocab = len(self.w2vmodel.w2vmodel.vocab)

        # [self.testData, self.testLabel] =  self.readFile(testDataPath)
        self.weight = self.getW2V()
def main():
    config = Config()
    config.running_mode = "test"
    config.list_all_member()
    word_dict = geniaDataset()
    model = AttentionNestedNERModel(config, word_dict).cuda() if config.cuda else AttentionNestedNERModel(config,
                                                                                                          word_dict)

    config.test_data, config.test_str, config.test_label = data_prepare(config, config.get_test_path(), word_dict)
    del word_dict
    start_test(config, model)