regex - Detecting accents in words (Python) -


This is the deal: I have written a program that finds all the algorithmic classes in the dictionary. However, I'm having trouble dealing with the accented letter, currently my code reads them, behaves like they are invisible, but still '\ xc3 \ ???' Finally print any type of replacement code. I would like to discard all words with accent, but I do not know how they will know.

Things I've tried:

  • Check if Unicode Type
  • Using a regex for words containing '\ xc3' / Li>
  • Decoding / Encoding (I do not fully understand Unicode, but whatever I tried was not working)

Question / Problem: I have to find out how to detect the accent, but my program command on the command line is odd '\ xc3 \ ???' Prints as Characters are not, which is not how the program behaves in them, because I can not find any word containing '\ xc3 \\'

Example: SE -> S \ xc3 \ Xa9, and SE and S are considered as anagrams by my program.

P>

  got \ xc3 \ xa9 ['pit', 'tip'] ['world'] ['s \ xc3 \ xa 9', 's'] ['\\ xc3 \\ xa9' ] ['Stop', 'top', 'pot'] ['from'] ['hello']  

Program self:

  import again From Anadik = {}; For Open Line ('FDICTT'): # / User / Share / Dict / Word '): word = line.stip (). Less (). ("", "", "") Line = '' if the word (if the word is, Unicode): Print word print "Unicode!" Pattern = re.compile (r'xc3 ') if pattern.findall (word): print' found 'print word if anadict.has_key (line): if not (word in the undo [row]): reject [line] .append (Word) Other: anadict [line] = [word] For the key in infamy: if (lane (anadic [key]) = 1: print anadatik [key]  

help?

then basically scratch my answer ... just look here:

The essence is that you can check each character, whether the four ord is less than 128, which allows you to check whether it is pronounced Crow is aracter. Or you can make a lot of efforts and can catch, which are looking for Unicode errors which will throw during vigorous characters. (The latter skilled answer is increasing)

This was definitely a learning experience for me :) Sorry for a very long time


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -