Which is all well and good. For the most part, it works beautifully. The problem is that some phonemes in IPA are represented with two symbols (for example, ʣ), and perl is treating these as separate characters when calculating the edit distance.
I've just tested Text::Levenshtein::Damerau with the ʣ digraph, and it treats it as a single character:
use lib 'lib'; use strict; use warnings; use 5.010; use Text::Levenshtein::Damerau qw/edistance/; use charnames ":full"; use utf8; say edistance("e\N{LATIN SMALL LETTER DZ DIGRAPH}gar", 'edgar'); # output: 1
So the problem seems to be that you don't pass properly decoded strings to edistance
Is unicode the best way to do this? Are there any easier ideas that I am simply missing? Do I have to "use Encode"? I have seen some sample scripts that use it, and others that don't.
Unicode is the best way to do this, yes.
If your data comes in as a byte string, yes, you'll need use Encode and decode the data before passing it to edistance. And yes, some scripts use it, and others not, because not all example scripts do the same thing in the same way.
I hope this article answers some of your questions. In the end you'll just have to learn about character encodings and how perl handles them, and then fix your problem with that knowledge.
In reply to Re: Reading IPA characters in Perl (Unicode?)
by moritz
in thread Reading IPA characters in Perl (Unicode?)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |