Beispiel #1
0
def createQuestionsDict():
    """
    创建问题字典(包含回答字典)
    """
    reader = DataReader()
    reader.set_pos()
    dealer = DataDealer(ANSWERS_DICT_PATH)
    start_id = reader.get_next_pic_id()
    qa = reader.get_pic_qa(start_id)
    for q in qa:
        question = q['question']
        dealer.deal(question)
    now_id = reader.get_next_pic_id()
    i = 0
    while now_id != start_id:
        qa = reader.get_pic_qa(now_id)
        for q in qa:
            question = q['question']
            dealer.deal(question)
        now_id = reader.get_next_pic_id()
        i = i + 1
        if i % 1000 == 0:
            print('*', end='')
    dealer.saveData(QUESTIONS_DICT_PATH)
    print('over!')
Beispiel #2
0
 def __init__(self):
     # 获取字典
     self.dealer = DataDealer(ANSWERS_DICT_PATH)
     if not os.path.exists(LSTM_MODEL_PATH):
         exit()
     self.model_word2vec = gensim.models.KeyedVectors.load_word2vec_format(
         GLOVE_WIKI_GENSIM_DATA_PATH)
     self.img = None
     self.path = '.\\'
     YukiVisual.__init__(self)
Beispiel #3
0
 def __init__(self):
     # 获取字典
     self.dealer = DataDealer(ANSWERS_DICT_PATH)
     # 获取样本集信息
     self.reader = DataReader(TRAIN_DATA_TYPE)
     self.reader.set_pos()
     self.weight_vgg = None
     self.biase_vgg = None
     self.model_word2vec = gensim.models.KeyedVectors.load_word2vec_format(
         GLOVE_WIKI_GENSIM_DATA_PATH)
Beispiel #4
0
def createAnswersDict():
    """
    创建回答字典
    """
    reader = DataReader()
    reader.set_pos()
    dealer = DataDealer(ANSWERS_DICT_PATH)
    start_id = reader.get_next_pic_id()
    qa = reader.get_pic_qa(start_id)
    for q in qa:
        answers = dict()
        for a in q['answers']:
            answer = a['answer']
            weight = 0
            if a['answer_confidence'] == 'yes':
                weight = 1
            elif a['answer_confidence'] == 'maybe':
                weight = 0.5
            if not answer in answers.keys():
                answers[answer] = 0
            answers[answer] = answers[answer] + weight
            answers_list = []
        for key in answers.keys():
            if answers[key] >= 3:
                dealer.deal(key)
    now_id = reader.get_next_pic_id()
    i = 0
    while now_id != start_id:
        qa = reader.get_pic_qa(now_id)
        for q in qa:
            answers = dict()
            for a in q['answers']:
                answer = a['answer']
                weight = 0
                if a['answer_confidence'] == 'yes':
                    weight = 1
                elif a['answer_confidence'] == 'maybe':
                    weight = 0.5
                if not answer in answers.keys():
                    answers[answer] = 0
                answers[answer] = answers[answer] + weight
                answers_list = []
            for key in answers.keys():
                if answers[key] >= 3:
                    dealer.deal(key)
        now_id = reader.get_next_pic_id()
        i = i + 1
        if i % 1000 == 0:
            print('*', end='')
    dealer.saveData()
    print('over!')
Beispiel #5
0
 def __init__(self):
     # 获取字典
     self.dealer = DataDealer(ANSWERS_DICT_PATH)
Beispiel #6
0
 def __init__(self, model_path=RPN_BATCH_PATH, init_model_path=RES_NET_101):
     self.dealer = DataDealer()
     self.model_path = model_path
     self.init_model_path = init_model_path