Пример #1
0
def manual_train_filter_no_func(ham, spam=False):
    """Trains the filter with words given in function parameters"""
    import story_filter
    weight = 6
    story_filter.train_filter((" "+ham+" ")*weight,"ham",removeDuplicates=False)
    if spam:
        story_filter.train_filter((" "+spam+" ")*weight,"spam",removeDuplicates=False)
Пример #2
0
def manual_train_filter(trainforspam=False,inputfunc=raw_input):
    """Ask the user for a few words for filter initialization"""
    import story_filter
    import types
    weight=6
    while True:
        ham=inputfunc("Enter a few space separated words describing topics you like: ")
        if type(ham) == types.StringType and ham != "" : break
    print ham
    story_filter.train_filter((" "+ham+" ")*weight,"ham",removeDuplicates=False)
    if trainforspam:
        while True:
            spam=inputfunc("Enter a few space separated words describing topics you DON'T like: ")
            if type(spam) == types.StringType and spam != "" : break
        story_filter.train_filter((" "+spam+" ")*weight,"spam",removeDuplicates=False)
Пример #3
0
def train_filter(story,pool):
    import story_filter
    story.get_additional_info()
    story_filter.train_filter(story.bogorepresentation(),pool)
    add_old(story)