コード例 #1
0
ファイル: models_1.py プロジェクト: kykamath/spam_model
 def process(self, currentTimeStep, currentTopics, currentUsers, **conf):
     if not currentTopics: Topic.addNewTopics(currentTopics, conf.get('noOfTopics', 5000))
     random.shuffle(currentUsers)
     for user in currentUsers:
         message = self.messageSelectionMethod(currentTimeStep, user, currentTopics, **conf)
         if message:
             topic = message.topic
             topic.countDistribution[currentTimeStep]+=1
             topic.totalCount+=1
             self.topicToMessagesMap[topic.id].append(message)
             self.totalMessages+=1
             if message.payLoad.isSpam: self.messagesWithSpamPayload+=1
             self.topicsDistributionInTheTimeSet[topic.id]+=1
コード例 #2
0
ファイル: models_1.py プロジェクト: kykamath/spam_model
def run(model, numberOfTimeSteps=100, addUsersMethod=User.addNormalUsers, noOfUsers=10000, analysisMethods = [], **conf):
    currentTopics, currentUsers = [], []
    addUsersMethod(currentUsers, noOfUsers, **conf)
    random.shuffle(currentUsers)
    conf['spamDectectionMethod'] = SpamDetectionModel.filterMethod
    analysis = []
    for method, frequency in analysisMethods: analysis.append(FixedIntervalMethod(method, frequency))
    
    for currentTimeStep in range(numberOfTimeSteps):
        print currentTimeStep
        Topic.incrementTopicAge(currentTopics)
        model.process(currentTimeStep, currentTopics, currentUsers, **conf)
        for method in analysis: method.call(currentTimeStep, iterationData=(currentTimeStep, model, currentTopics, currentUsers, False, conf))
    currentTimeStep+=1
    for method in analysis: method.call(currentTimeStep, iterationData=(currentTimeStep, model, currentTopics, currentUsers, True, conf))
コード例 #3
0
ファイル: objects_tests.py プロジェクト: kykamath/spam_model
 def test_generate(self):
     topics = []
     Topic.addNewTopics(topics, 2)
     Topic.addNewTopics(topics, 5)
     self.assertEqual(7, len(topics))
     for i in range(7): self.assertEqual(i, topics[i].id)