Esempio n. 1
0
 def detect_non_vietnamese(self):
     vowel = [u'a', u'e', u'i', u'o', u'u', u'y']
     vowel2 = [u'a', u'e', u'i', u'o', u'y']
     vowel3 = [u'y']
     double_vowel = [w + w for w in vowel]
     double_vowel = list(set(double_vowel) - set([u'uu']))
     double_vowel2 = utils.add_to_list(vowel3, vowel)
     double_vowel2 = list(set(double_vowel2) - set([u'yy']))
     consonant = [u'b', u'c', u'd', u'g', u'h', u'k', u'l', u'm', u'n', u'p', u'q',
                  u'r', u's', u't', u'v', u'x']
     consonant2 = [u'b', u'd', u'g', u'h', u'k', u'l', u'q', u'r', u's', u'v', u'x']
     consotant3 = [u'm', u'p']
     consonant4 = [u'p', u'q']
     consonant5 = [u'b', u'c', u'd', u'g', u'n', u'r']
     special_pattern = [u'ch', u'gh', u'kh', u'nh', u'ng', u'ph', u'th', u'tr']
     special_pattern2 = [u'ae', u'ea', u'ei', u'ey', u'iy', u'oy', u'ya', u'yi', u'yo', u'yu']
     special_pattern3 = [u'gh', u'kh', u'ph', u'th', u'tr']
     special_pattern4 = [u'ge', u'gy', u'ka', u'ko', u'ku', u'ry']
     english_chars = [u'f', u'j', u'w', u'z']
     double_consonant = utils.add_to_list(consonant, consonant)
     double_consonant = list(set(double_consonant) - set(special_pattern))
     non_vietnamese = double_vowel + double_consonant + utils.add_to_list(vowel, consonant2)
     non_vietnamese += consotant3 + special_pattern2 + utils.add_to_list(vowel, special_pattern3)
     non_vietnamese += utils.add_to_list(vowel, utils.add_to_list(consonant, vowel))
     non_vietnamese += special_pattern4 + utils.add_to_list(consonant4, vowel2) + \
                       utils.add_to_list(consonant, double_vowel2) + utils.add_to_list(consonant5, vowel3)
     non_vietnamese = self.filter_non_vnese(set(non_vietnamese)) + english_chars
     s = u'|'.join(non_vietnamese)
     return re.compile(ur'\w*(' + s + ur')\w*', re.I)
Esempio n. 2
0
def add_item():
    req_data = request.get_json()
    item = req_data['item']

    res_data = utils.add_to_list(item)

    if res_data is None:
        response = Response("{'error': 'Item not added - " + item + "'}",
                            status=400,
                            mimetype='application/json')
        return response

    response = Response(json.dumps(res_data), mimetype='application/json')

    return response
Esempio n. 3
0
 def save(self):
     email = self.cleaned_data.get('email')
     first_name = self.cleaned_data.get('first_name', None)
     utils.add_to_list(email, first_name)