MetaphonePtBr 2.0.3
dotnet add package MetaphonePtBr --version 2.0.3
NuGet\Install-Package MetaphonePtBr -Version 2.0.3
<PackageReference Include="MetaphonePtBr" Version="2.0.3" />
<PackageVersion Include="MetaphonePtBr" Version="2.0.3" />
<PackageReference Include="MetaphonePtBr" />
paket add MetaphonePtBr --version 2.0.3
#r "nuget: MetaphonePtBr, 2.0.3"
#:package MetaphonePtBr@2.0.3
#addin nuget:?package=MetaphonePtBr&version=2.0.3
#tool nuget:?package=MetaphonePtBr&version=2.0.3
MetaphonePtBr
MetaphonePtBr is a .NET library that converts a Brazilian Portuguese word into a phonetic token.
This helps match words that sound alike even when they are spelled differently.
Install
Add the NuGet package to your project.
Use
Call GetMetaphoneToken() on a single word:
string metaphoneToken = "Cristopher".GetMetaphoneToken();
Example
These variations produce the same token, KSF:
- Christofer
- Christofr
- Christopher
- Christophr
- Cristofer
- Cristofr
- Cristophr
This is useful for:
- Name search
- Address search
- Product or brand matching
- Typo-tolerant lookups
Input Rules
- Input must be a single word
- Input must contain letters only
- Accented characters are supported
- The output is a phonetic token, not the original word
How It Works
The algorithm reads the word letter by letter and applies Brazilian Portuguese phonetic rules.
For each letter, it may look at:
- The current character
- The previous character
- The character before the previous one
- The next character
- The character after the next one
Rule Reference
Symbols
| Symbol | Meaning |
|---|---|
| Letter | Letter |
^ |
Beginning of the word |
$ |
End of the word |
[] |
One occurrence of any |
v |
Any vowel |
c |
Any consonant |
. |
Any letter |
0 |
Bypass |
- If a mutable letter does not match a special rule, it keeps its default sound
- Rules are evaluated by priority
C
| Rule | Result |
|---|---|
| C[AOUc] | K |
| C[EI] | S |
| CHR | K |
| CH | X |
| C$ | K |
| Ç | S |
G
| Rule | Result |
|---|---|
| G[AOU] | G |
| G[EI] | J |
| GH[EI] | J |
| GH[c] | G |
H
| Rule | Result |
|---|---|
| ^H[v] | v |
| H | 0 |
Immutables
| Rule | Result |
|---|---|
| B | B |
| D | D |
| F | F |
| J | J |
| K | K |
| M | M |
| V | V |
L
| Rule | Result |
|---|---|
| L[v] | v |
| LH | 0 |
N
| Rule | Result |
|---|---|
| N$ | M |
| NH | 0 |
P
| Rule | Result |
|---|---|
| PH | F |
Q
| Rule | Result |
|---|---|
| Q | K |
R
| Rule | Result |
|---|---|
| ^R | 0 |
| R$ | 0 |
| RR | 0 |
S
| Rule | Result |
|---|---|
| SH | X |
| SC[EI] | S |
| SC[AOU] | SK |
| SCH | X |
| S[c] | S |
T
| Rule | Result |
|---|---|
| TH | T |
Vowels
| Rule | Result |
|---|---|
| ^[v] | v |
W
| Rule | Result |
|---|---|
| W[LRv] | V |
| W[c] | 0 |
X
| Rule | Result |
|---|---|
| X$ | X |
| ^EX[v] | Z |
| .EX[v] | X |
| [CGKLRXv][AIOU]X | X |
| [DFMNPQSTVZ][AIOU]X | KS |
| EX[EI] | X |
| EX[CPT] | S |
| EX[.] | KS |
Y
| Rule | Result |
|---|---|
| Y | I |
Z
| Rule | Result |
|---|---|
| Z$ | S |
Credits
This project is a .NET library based on metaphone-ptbr by Carlos Costa Jordao.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.