<commit_before># -*- coding: utf-8 -*-

# Copyright(C) 2010  <NAME>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

import re

from .pages.contact_list import ContactItem
from .pages.profile import ProfilePage


__all__ = ['AntiSpam']


class AntiSpam(object):
    def check(self, obj):
        for key, value in self.OBJECTS.iteritems():
            if isinstance(obj, key):
                return value(self, obj)

        raise TypeError('Unsupported object %r' % obj)

    def check_contact(self, contact):
        resume = contact.get_resume()

        # Check if there is an email address in the offer.
        if re.match('[\w\d\._]+@[\w\d\.]+ vous offre la possibilit', resume):
            return False

        return True

    def check_profile(self, profile):
        # TODO
        return True

    OBJECTS = {ContactItem: check_contact,
               ProfilePage: check_profile,
              }<commit_msg>new pattern 'chercher un mac tres chowd'<commit_after># -*- coding: utf-8 -*-

# Copyright(C) 2010  <NAME>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

import re

from .pages.contact_list import ContactItem
from .pages.profile import ProfilePage


__all__ = ['AntiSpam']


class AntiSpam(object):
    def check(self, obj):
        for key, value in self.OBJECTS.iteritems():
            if isinstance(obj, key):
                return value(self, obj)

        raise TypeError('Unsupported object %r' % obj)

    def check_contact(self, contact):
        resume = contact.get_resume()

        # Check if there is an email address in the offer.
        if re.match('[\w\d\._]+@[\w\d\.]+ vous offre la possibilit', resume):
            return False

        return True

    def check_profile(self, profile):
        # This pattern in bad french is in several spambots description.
        if profile.description.find('chercher un mac tres chowd') >= 0:
            return False
        return True

    OBJECTS = {ContactItem: check_contact,
               ProfilePage: check_profile,
              }
{'fraction_non_alphanumeric': 0.08271604938271605, 'fraction_numerical': 0.012654320987654321, 'mean_word_length': 2.8355029585798817, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3845038', 'n_tokens_mistral': 911, 'n_tokens_neox': 858, 'n_words': 386}