Exemple #1
0
 def __init__(self, theNick, theRoom, theCommand, isPm=0):
     Command.Command.__init__(self, theNick, theRoom, theCommand, isPm)
     self.commands = {
         "spam": {"method": BayesCommand.trainSpam, "acl": 1, "aclkey": Acl.TRAINSPAM},
         "ham": {"method": BayesCommand.trainHam, "acl": 1, "aclkey": Acl.TRAINHAM},
         "hammer": {"method": BayesCommand.addHammer, "acl": 1, "aclkey": Acl.HAMMER},
         "spammer": {"method": BayesCommand.addSpammer, "acl": 1, "aclkey": Acl.SPAMMER},
         "probability": {"method": BayesCommand.probability, "acl": 1, "aclkey": Acl.SPAMPROBABILITY},
     }
     self.spamFilter = SpamFilter.getInstance()
Exemple #2
0
    
    protocol = config.getString("login", "protocol")
    
    #init the protocol we are going to use
    Protocol.initProtocol( protocol )
    
    protocol = Protocol.getProtocol()   
    
    
    #first get the cookie and id's     
    nick = config.getString( "login", "username" )
    passwd = config.getString( "login", "password" )

    events = Events.getEvents()
    events.addListener( Display.getDisplay() )
    events.addListener( SpamFilter.getInstance() )

    #create the socket
    sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
    sock.settimeout( 120.0 )
    chatserver = config.getString( "login", "chatserver" )
    chatport = config.getInt( "login", "chatport" ) 


    #recreate the acl?
    if sys.argv.count( "-newacl" ):
        os.unlink( Acl.ACLFILE )

    chatRoom = config.getString( "login", "chatroom" )

    if len( sys.argv ) > 1:
Exemple #3
0
# SPLITTING DATASET INTO TEST AND TRAINING SET -----------------------------------------
trainingSet = dataset[0:int(len(dataset) * TRAINING_SET_SIZE)]
testSet = dataset[int(len(dataset) * TRAINING_SET_SIZE):]

# LISTING TARGET VALUES AND ATTRIBUTES ----------------------------------------------
tv = ["ham", "spam"]
attributes = []

for i in range(0, len(trainingSet)):
    attributes.extend([
        x for x in dataset[i] if x != 'CLASS' if not x in tv
        if not x in attributes
    ])

# TRAINING SPAM FILTER --------------------------------------------------------------
sf = SpamFilter.MultinomialSpamFilter(tv, attributes, trainingSet, 1)
sf.Learn()

# TESTING SPAM FILTER --------------------------------------------------------------
numTotalTries = len(testSet)
numTotalSuccesses = 0

falsePositives = 0  # when a ham is classified as spam
falseNegatives = 0  # when spam is classified as ham

realPositives = 0  # number of spam
realNegatives = 0  # number of ham

confusionMatrix = [[0, 0], [0, 0]]  # rows are the real classes 0->HAM 1->SPAM
# columns are the stimated classes 0->HAM 1->SPAM
Exemple #4
0
ajoin = [
    "#mobsters", "#nova"
]  #First channel in Array will be the active game channel, 2nd channel is the OPs channel

#Two bots are required. First bot will be the main game bot, while the second one is the missions bot
bots = [[rizon, Utility.Identity("mobsters", "mobster", None, ajoin)],
        [rizon, Utility.Identity("DonVito", "dv", None, ajoin)]]

eng = Engine.Engine(event, bots, scheduler,
                    logger)  #event, bots, sched, logger
eng.soft_start()  # This is a mobster's mod
bots = eng.get_bots()
#(CORE) modules we are loading
scheduler.schedule_event(AuthSys.AuthSys(eng))
scheduler.schedule_event(KeepAlive.KeepAlive(eng))
event.add_mod(SpamFilter.SpamFilter(bots[0], eng))  #SpamFilter (mobsters only)
event.add_mod(Basic.Basic(eng))

## GAME WORK

#create the game instance
mobs = Mobster.Mobster(eng, bots[0], ajoin[0],
                       Security.Security(bots[0], ajoin))
msnclk = MissionClock.MissionClock(bots[1], mobs.host_channel)
regen = Regen.Regen(mobs, bots[0])

#Module Instances
event.add_mod(mobs)  #Mobster Game (mobsters only)
event.add_mod(LegalAffairs.LegalAffairs(bots[0], mobs,
                                        regen))  #Mobs (mobsters only)
event.add_mod(Missions.Missions(bots[1], mobs, msnclk))  #DonVito
Exemple #5
0
# SPLITTING DATASET INTO TEST AND TRAINING SET -----------------------------------------
trainingSet = dataset[0: int(len(dataset)*TRAINING_SET_SIZE)]
testSet     = dataset[int(len(dataset)*TRAINING_SET_SIZE):]



# LISTING TARGET VALUES AND ATTRIBUTES ----------------------------------------------
tv = ["ham","spam"]
attributes = []

for i in range(0,len(trainingSet)):
    attributes.extend([x for x in dataset[i] if not x in tv if not x in attributes])


# TRAINING SPAM FILTER --------------------------------------------------------------
sf = SpamFilter.BinomialSpamFilter(tv,attributes,trainingSet)
sf.Learn()



# TESTING SPAM FILTER --------------------------------------------------------------
numTotalTries = len(testSet)
numTotalSuccesses = 0

falsePositives = 0              # when a ham is classified as spam
falseNegatives = 0              # when spam is classified as ham


realPositives = 0              # number of spam
realNegatives = 0              # number of ham