def infer_words_by_ve(self, data_path, r_way, h, combine, model, v_way, T,
                       r):
     if type(data_path) == 'str':
         datas = read_datas(data_path, r_way)
     else:
         datas = read_multity_dirs(data_path, r_way)
     datas = get_puredatas(datas)
     ABtest_now = ABtest()
     datas = datas[0:int(len(datas) * ABtest_now.ratio)]
     #messages = add_tail(datas, h) # change
     messages = datas
     message_splitter = splitter()
     message_split = message_splitter.split_by_ve(messages, h, combine,
                                                  model, v_way, T, r)
     t_now = time.strftime("%Y-%m-%d %H:%m:%s", time.localtime(time.time()))
     m_logger = get_logger(log_path + '/messge_splited_log' + t_now,
                           'msg_split')
     for message in message_split:
         m_logger.error(message)
     T_word_convert = word_convert()
     words_prim = T_word_convert.convert_words_byloc(message_split)
     p_logger = get_logger(log_path + '/p_log' + t_now, 'word_count')
     for key in words_prim:
         p_logger.error(key + str(words_prim[key].content))
     words_count = T_word_convert.get_words_count(words_prim)
     t_ranker = ranker()
     words_rank = t_ranker.rank_dic(words_count, True)
     return words_rank
示例#2
0
def raw_to_log(file_path, r_way, protocol):
    datas = read_datas(file_path, r_way)
    datas = get_puredatas(datas)
    raw_datas = []
    converter = Converter()
    logger_raw = get_logger(log_path + '/' + protocol, 'raw_message_logger')
    i = 0
    for data in datas:
        logger_raw.error(str(i) + ':' + converter.convert_raw_to_text(data))
示例#3
0
def ve_word():
    word_dis = words_discover()
    word_redis = redis_deal()
    word_r = word_dis.infer_words_by_ve(["/home/wxw/data/modbusdata", "/home/wxw/data/modbus_github"], "single", 3, "yes", "abs", "loose", 0, 0)
    word_redis.insert_to_redis(ve_stra_str + 'word_rank_correct', word_r)
    word_pures = [word[0] for word in word_r]
    word_redis.insert_to_redis(ve_stra_str + 'word_pure_rank_correct', word_pures)
    word_transer = transer()
    modbus_w = modbus()
    word_t = word_transer.field_keys(modbus_w.fields)
    word_redis.insert_to_redis(ve_stra_str + 'word_true_correct', word_t)
    t_measure = Fields_measure(word_t, word_pures)
    t_cnt = t_measure.measure(1000)
    print(t_cnt)
    t_now = time.strftime("%Y-%m-%d %H:%m:%s", time.localtime(time.time()))
    words_logger = get_logger(log_path + '/word_log' + vote_pre + t_now, 'word_logger')
    words_logger.error(word_r)
示例#4
0
import numpy as np
import time
from log_info.logger import get_logger, vote_pre
from common.readdata import *
from Config.ve_strategy import ve_strategy
from Config.log_config import log_path
from Config.encode_types import Message_encoder
from common.Converter.base_convert import Converter
from Data_base.Data_redis.redis_deal import redis_deal
from Config.UserConfig import UserConfig
from Config.VeConfig import VeConfig
from common.Converter.word_converter import word_convert
import sys

now_time = time.strftime("%Y-%m-%d %H:%m:%s", time.localtime(time.time()))
voter_logger = get_logger(log_path + '/message_vote' + vote_pre + now_time,
                          'messagedetaillogger')
ve_parameter = ve_strategy().vote_parameters
redis_writer = redis_deal()
redis_prefix = ve_strategy().get_strategy_str()


class voters:
    def __init__(self):
        self.words_fre = None
        self.words_table = None
        self.words_entry = None
        self.glvotes = None
        self.svotes = None
        self.redisDeal = redis_deal()
        self.wCvert = word_convert()
示例#5
0
import sys
sys.path.append('../common/measure_tool/')
from common.measure_tool.measure_base import Base_measure
from Config.ve_strategy import ve_strategy
from log_info.logger import get_logger
import time
from Config.const_config import log_path
VE_strategy = ve_strategy().get_strategy_str()

words_logger = get_logger(
    log_path + '/words_compare' + str(VE_strategy) +
    time.strftime("%Y-%m-%d %H:%m:%s", time.localtime(time.time())),
    'word_compare')


class Fields_measure(Base_measure):
    def __init__(self, words_true, words_pre):
        super().__init__(words_true, words_pre)
        words_logger.error("True: ")
        words_logger.error(str(words_true))
        words_logger.error('\n')
        words_logger.error("Predict: ")
        words_logger.error(str(words_pre))

    def measure(self, topk):
        print(topk)
        true_dic = {}
        for item in self.true_data:
            true_dic[item] = 1
        i = 0
        infer_cnt = 0