Ejemplo n.º 1
0
 def __init__(self):
     super().__init__()
     self.converter = Converter()
     self.msgSpliter = MsgSpliter()
     self.redis_dealer = redis_deal()
     self.splt = splitter()
     self.desiner = Desiner()
     self.msAb = MeasureAb()
     self.cvt = Converter()
     self.dataTuning = DataTuning()
Ejemplo n.º 2
0
 def getBoundaries(self, configParas, gveConfigParas, messages):
     freGVotes, entryGVotes = self.getGVotes(configParas, messages)
     desiner = Desiner()
     paraFre = {}
     paraFre['diff_measure'] = gveConfigParas['diffMeasure']
     paraFre['vWay'] = gveConfigParas['vWayFre']
     paraFre['T'] = gveConfigParas['T']
     paraFre['r'] = gveConfigParas['r']
     freBoundaries = desiner.VoteSingleByDicParas(paraFre, freGVotes)
     paraFre['vWay'] = gveConfigParas['vWayEntry']
     entryBoundaries = desiner.VoteSingleByDicParas(paraFre, entryGVotes)
     return Converter().MergeLists(freBoundaries, entryBoundaries)
Ejemplo n.º 3
0
 def SplitByOrder(self, messages):
     key = ve_strategy().GetWordsKeys('OrderWords')
     if self.redis_read.is_exist_key(key):
         OrderWords = self.redis_read.read_from_redis(key)
     else:
         raw_keys = ve_strategy().GetWordsKeys('RawWords')
         raw_words = self.redis_read.read_from_redis(raw_keys)
         OrderWords = word_convert().ConvertRawWordsToOrder(raw_words, self.parameters['height'] + 1)
         self.redis_read.insert_to_redis(key, OrderWords)
     orderVoter = OrderVoter(OrderWords)
     PrimBorders = orderVoter.vote_for_messages(messages, self.parameters['height'])
     FinalBorders = Desiner().VoteMultiM(PrimBorders, self.parameters['diff_measure'],
                                         self.parameters['decision_type'],
                                         self.parameters['Threshold_T'], self.parameters['Threshod_R'])
     return Converter().ConvertListToOrder(FinalBorders)
Ejemplo n.º 4
0
 def split_by_frequent(self, messages):
     prefix = ve_strategy().GetWordsKeys('FrequentWords')
     entry_words = None
     if self.redis_read.is_exist_key(prefix):
         frequent_words = self.redis_read.read_from_redis(prefix)
     else:
         raw_keys = ve_strategy().GetWordsKeys('RawWords')
         raw_words = self.redis_read.read_from_redis(raw_keys)
         frequent_words = Converter().ConvertRawToNormalFrequent(raw_words, self.parameters['height'] + 1)
         self.redis_read.insert_to_redis(prefix, frequent_words)
     frequent_voter = frequence_voter(frequent_words)
     PrimBorders = frequent_voter.vote_for_messages(messages, self.parameters['height'])
     FinalBorders = Desiner().VoteMultiM(PrimBorders, self.parameters['diff_measure'],
                                         self.parameters['decision_type'],
                                         self.parameters['Threshold_T'], self.parameters['Threshod_R'])
     return Converter().ConvertListToOrder(FinalBorders)
Ejemplo n.º 5
0
 def split_by_entry(self, messages):
     keys = ve_strategy().GetWordsKeys("EntryWords")
     entry_words = None
     if self.redis_read.is_exist_key(keys):
         entry_words = self.redis_read.read_from_redis(keys)
     else:
         raw_keys = ve_strategy().GetWordsKeys("RawWords")
         raw_words = self.redis_read.read_from_redis(raw_keys)
         entry_words = word_convert().convert_raw_to_entry(
             raw_words, self.parameters['height'] + 1)
         self.redis_read.insert_to_redis(keys, entry_words)
     entry_voter = Entry_voter(entry_words)
     PrimBorders = entry_voter.vote_for_messages(messages,
                                                 self.parameters['height'])
     FinalBorders = Desiner().VoteMultiM(PrimBorders,
                                         self.parameters['diff_measure'],
                                         self.parameters['decision_type'],
                                         self.parameters['Threshold_T'],
                                         self.parameters['Threshod_R'])
     return Converter().ConvertListToOrder(FinalBorders)
Ejemplo n.º 6
0
class MegSplitLogic:
    def __init__(self):
        super().__init__()
        self.converter = Converter()
        self.msgSpliter = MsgSpliter()
        self.redis_dealer = redis_deal()
        self.splt = splitter()
        self.desiner = Desiner()
        self.msAb = MeasureAb()
        self.cvt = Converter()
        self.dataTuning = DataTuning()

    def getOrderBorders(self, gveConfigParas, messages):
        borderDicts = self.splt.getOrderVotesByMsgs(messages)
        paraFre = {}
        paraFre['diff_measure'] = gveConfigParas['diffMeasure']
        paraFre['vWay'] = gveConfigParas['vWayFre']
        paraFre['T'] = gveConfigParas['T']
        paraFre['r'] = gveConfigParas['r']
        return self.desiner.VoteMultyByDicParas(paraFre, borderDicts)

    def getEntryBorders(self, gveConfigParas, messages):
        entryDicts = self.splt.getEntryVotesByMsgs(messages)
        paraFre = {}
        paraFre['diff_measure'] = gveConfigParas['diffMeasure']
        paraFre['vWay'] = gveConfigParas['vWayFre']
        paraFre['T'] = gveConfigParas['T']
        paraFre['r'] = gveConfigParas['r']
        return self.desiner.VoteMultyByDicParas(paraFre, entryDicts)

    def getMbourders(self, gveConfigParas, messages):
        VeDicts = self.splt.getVeVotesByMsg(messages)
        paraFre = {}
        paraFre['diff_measure'] = gveConfigParas['diffMeasure']
        paraFre['vWay'] = gveConfigParas['vWayFre']
        paraFre['T'] = gveConfigParas['T']
        paraFre['r'] = gveConfigParas['r']
        print(VeDicts[0])
        return self.desiner.VoteMultyByDicParas(paraFre, VeDicts)

    def getFreBorders(self, gveConfigParas, messages):
        freDicts = self.splt.getFreVotesByMsg(messages)
        paraFre = {}
        paraFre['diff_measure'] = gveConfigParas['diffMeasure']
        paraFre['vWay'] = gveConfigParas['vWayFre']
        paraFre['T'] = gveConfigParas['T']
        paraFre['r'] = gveConfigParas['r']
        return self.desiner.VoteMultyByDicParas(paraFre, freDicts)

    def msgSplit(self, borders, msgs, maxRange=15):
        return self.msgSpliter.splitMessages(borders, msgs, maxRange)

    def getOrderBordersNyPath(self, filePath='', msgs=None, maxRange=15):
        # future update
        veParas = {'diffMeasure': 'abs', 'vWayFre': 'loose', 'T': 0, 'r': 0.3}
        # future update
        #if filePath != '':
        #    msgs = self.dataTuning.readDatas(filePath)
        borders = self.getOrderBorders(veParas, msgs)
        spltMsgs = self.msgSplit(borders, msgs, maxRange)
        return borders, spltMsgs