Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'url:pypi': 0.03; 'third- party': 0.04; 'ignored': 0.07; 'string': 0.09; 'archiving': 0.09; 'subject:trying': 0.09; 'url:2)': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'fuzzy': 0.16; 'jellyfish.': 0.16; 'roy': 0.16; 'subject:non': 0.16; 'language': 0.16; 'wrote:': 0.18; 'import': 0.22; 'putting': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; 'matching': 0.30; 'work.': 0.31; 'chase': 0.31; 'libraries': 0.31; 'supposed': 0.32; 'url:python': 0.33; 'sense': 0.34; 'core': 0.34; "i'd": 0.34; 'problem': 0.35; 'something': 0.35; 'case,': 0.35; 'there': 0.35; 'are,': 0.36; 'charset:us-ascii': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'little': 0.38; 'expect': 0.39; 'how': 0.40; 'future': 0.60; 'algorithms': 0.60; "you'll": 0.62; 'skip:n 10': 0.64; 'box,': 0.64; 'url:0': 0.67; 'combining': 0.68; 'smith': 0.68; 'article': 0.77; 'bookmarking': 0.84; 'received:50.22': 0.84; 'subject:.. ': 0.84 Date: Sat, 26 Oct 2013 21:17:29 -0500 From: Tim Chase To: Roy Smith Subject: Re: trying to strip out non ascii.. or rather convert non ascii In-Reply-To: References: <526c412a$0$29972$c3e8da3$5496439d@news.astraweb.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382840149 news.xs4all.nl 15890 [2001:888:2000:d::a6]:49435 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57703 On 2013-10-26 21:54, Roy Smith wrote: > In article , > Tim Chase wrote: >> I'd be just as happy if Python provided a "sloppy string compare" >> that ignored case, diacritical marks, and the like. > > The problem with putting fuzzy matching in the core language is > that there is no general agreement on how it's supposed to work. > > There are, however, third-party libraries which do fuzzy matching. > One popular one is jellyfish > (https://pypi.python.org/pypi/jellyfish/0.1.2). Bookmarking and archiving your email for future reference. > Don't expect you can just download and use it right out of the box, > however. You'll need to do a little thinking about which of the > several algorithms it includes makes sense for your application. I'd be content with a baseline that denormalizes and then strips out combining diacritical marks, something akin to MRAB's from unicodedata import normalize "".join(c for c in normalize("NFKD", s) if ord(c) < 0x80) and tweaking it if that was insufficient. Thanks for the link to Jellyfish. -tkc