Skip to content

Commit 04c64cd

Browse files
authored
Merge pull request #6 from Microsoft/csharp-update
Csharp update
2 parents 64c1cbd + 14bfe61 commit 04c64cd

125 files changed

Lines changed: 7440 additions & 2500 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto
5+
6+
###############################################################################
7+
# Set default behavior for command prompt diff.
8+
#
9+
# This is need for earlier builds of msysgit that does not have it on by
10+
# default for csharp files.
11+
# Note: This is only used by command line
12+
###############################################################################
13+
#*.cs diff=csharp
14+
15+
###############################################################################
16+
# Set the merge driver for project and solution files
17+
#
18+
# Merging from the command prompt will add diff markers to the files if there
19+
# are conflicts (Merging from VS is not affected by the settings below, in VS
20+
# the diff markers are never inserted). Diff markers may cause the following
21+
# file extensions to fail to load in VS. An alternative would be to treat
22+
# these files as binary and thus will always conflict and require user
23+
# intervention with every merge. To do so, just uncomment the entries below
24+
###############################################################################
25+
#*.sln merge=binary
26+
#*.csproj merge=binary
27+
#*.vbproj merge=binary
28+
#*.vcxproj merge=binary
29+
#*.vcproj merge=binary
30+
#*.dbproj merge=binary
31+
#*.fsproj merge=binary
32+
#*.lsproj merge=binary
33+
#*.wixproj merge=binary
34+
#*.modelproj merge=binary
35+
#*.sqlproj merge=binary
36+
#*.wwaproj merge=binary
37+
38+
###############################################################################
39+
# behavior for image files
40+
#
41+
# image files are treated as binary by default.
42+
###############################################################################
43+
#*.jpg binary
44+
#*.png binary
45+
#*.gif binary
46+
47+
###############################################################################
48+
# diff behavior for common document formats
49+
#
50+
# Convert binary document formats to text before diffing them. This feature
51+
# is only available from the command line. Turn it on by uncommenting the
52+
# entries below.
53+
###############################################################################
54+
#*.doc diff=astextplain
55+
#*.DOC diff=astextplain
56+
#*.docx diff=astextplain
57+
#*.DOCX diff=astextplain
58+
#*.dot diff=astextplain
59+
#*.DOT diff=astextplain
60+
#*.pdf diff=astextplain
61+
#*.PDF diff=astextplain
62+
#*.rtf diff=astextplain
63+
#*.RTF diff=astextplain

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,11 @@ typings/
7070

7171
# dotenv environment variables file
7272
.env
73+
74+
# .net
75+
bin/
76+
obj/
77+
packages/
78+
*.Cache
79+
*.nupkg
80+
*.csproj.user

README.md

Lines changed: 79 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Docs can be found at: https://microsoft.github.io/PhoneticMatching/
99
Supported API:
1010
* C++
1111
* Node.js (>=8.11.2)
12+
* C# .NET Core (>=2.1)
1213

1314
Supported Languages
1415
* English
@@ -34,32 +35,51 @@ npm install phoneticmatching
3435
## Usage
3536
See the typings for more details. <br> Classes prefixed with `En` make certain assumptions that are specific to the English language.
3637
```ts
37-
import maluuba, { EnPronouncer, EnPhoneticDistance, FuzzyMatcher, AcceleratedFuzzyMatcher, EnHybridDistance, StringDistance } from "phoneticmatching";
38+
import { EnPronouncer, EnPhoneticDistance, FuzzyMatcher, AcceleratedFuzzyMatcher, EnHybridDistance, StringDistance } from "phoneticmatching";
3839
```
39-
__maluuba__ Default export, contains everything below.
40-
4140
__Speech__ The namespace containing the type interfaces of the library objects.
4241

43-
__FuzzyMatcher__ Main use case for this library. Returns matches against a list of targets for a given query. The comparisions are not remembered and therefore better for one-off use cases.
42+
__EnPronouncer__ Pronounces a string, as a General English speaker, into its IPA string or array of Phones format.
4443

45-
__AcceleratedFuzzyMatcher__ Same interface as `FuzzyMatcher` but the list of targets are precomputed, so beneficial for multiple queries at the cost of a higher initialization time.
44+
__matchers__ module:
4645

47-
__EnPronouncer__ Pronounces a string, as a General English speaker, into its IPA string or array of Phones format.
46+
* __FuzzyMatcher__ Main use case for this library. Returns matches against a list of targets for a given query. The comparisions are not remembered and therefore better for one-off use cases.
47+
48+
* __AcceleratedFuzzyMatcher__ Same interface as `FuzzyMatcher` but the list of targets are precomputed, so beneficial for multiple queries at the cost of a higher initialization time.
49+
50+
* __EnContactMatcher__ A domain specialization of using the `AcceleratedFuzzyMatcher` for English speakers searching over a list of names. Does additional preprocessing and setups up the distance function for you.
51+
52+
* __EnPlaceMatcher__ A domain specialization of using the `AcceleratedFuzzyMatcher` for English speakers searching over a list of places. Does additional preprocessing and setups up the distance function for you.
53+
54+
__distance__ module:
55+
56+
* __EnPhoneticDistance__ Returns a metric distance score between two English pronunciations.
57+
58+
* __StringDistance__ Returns a metric distance score between two strings (edit distance).
59+
60+
* __EnHybridDistance__ Returns a metric distance score based on a combination of the two above distance metrics (English pronunciations and strings).
4861

49-
__EnPhoneticDistance__ Returns a metric distance score between two English pronunciations.
62+
* __DistanceInput__ Input object for EnHybridDistance. Hold the text and the pronunciation of that text
5063

51-
__StringDistance__ Returns a metric distance score between two strings (edit distance).
64+
__nlp__ module:
5265

53-
__EnHybridDistance__ Returns a metric distance score based on a combination of the two above distance metrics (English pronunciations and strings).
66+
* __EnPreProcessor__ English Pre-processor.
67+
68+
* __EnPlacesPreProcessor__ English Pre-processor with specific rules for places.
69+
70+
* __SplittingTokenizer__ Tokenizing base-class that will split on the given RegExp.
71+
72+
Here are some example of how to import modules and classes:
5473

5574
```ts
56-
import { EnContactMatcher, EnPlaceMatcher } from "phoneticmatching/lib/matchers";
75+
import { EnContactMatcher, EnPlaceMatcher } from "phoneticmatching";
76+
```
77+
```ts
78+
import * as Matchers from "phoneticmatching/lib/matchers";
5779
```
58-
__EnContactMatcher__ A domain specialization of using the `AcceleratedFuzzyMatcher` for English speakers searching over a list of names. Does additional preprocessing and setups up the distance function for you.
59-
60-
__EnPlaceMatcher__ A domain specialization of using the `AcceleratedFuzzyMatcher` for English speakers searching over a list of places. Does additional preprocessing and setups up the distance function for you.
6180

6281
## Example
82+
JavaScript
6383
```js
6484
// Import core functionality from the library.
6585
const { EnPhoneticDistance, FuzzyMatcher } = require("phoneticmatching");
@@ -93,6 +113,48 @@ const result = matcher.nearest("blu airy");
93113
*/
94114
console.log(result);
95115
```
116+
C#
117+
```csharp
118+
using System;
119+
120+
// Import core functionality from the library.
121+
using Microsoft.PhoneticMatching.Matchers.FuzzyMatcher.Normalized;
122+
123+
public class Program
124+
{
125+
public static void Main(string[] args)
126+
{
127+
// The target list to match against.
128+
string[] targets =
129+
{
130+
"Apple",
131+
"Banana",
132+
"Blackberry",
133+
"Blueberry",
134+
"Grapefruit",
135+
"Pineapple",
136+
"Raspberry",
137+
"Strawberry",
138+
};
139+
140+
// Create the fuzzy matcher.
141+
var matcher = new EnPhoneticFuzzyMatcher<string>(targets);
142+
143+
// Find the nearest match.
144+
var result = matcher.FindNearest("blu airy");
145+
146+
/* The result should be:
147+
* {
148+
* // The object from the targets list.
149+
* element: 'Blueberry',
150+
* // The distance score the from distance function.
151+
* distance: 0.0416666666666667
152+
* }
153+
*/
154+
Console.WriteLine("element : [{0}] - distance : [{1}]", result.Element, result.Distance);
155+
}
156+
}
157+
```
96158

97159
## Build
98160
### TypeScript Transpiling
@@ -138,6 +200,10 @@ npm publish
138200
npm run package
139201
```
140202

203+
## NuGet Publish
204+
A .NET Core NuGet package is published for this project. The package is published by Microsoft. Hence, it must follow guidance at https://aka.ms/nuget and sign package content and package itself with an official Microsoft certificate. To ease signing and publishing process, we integrate ESRP signing to Azure DevOps build tasks.
205+
To publish a new version of the package, create a release for the latest build (Pipelines->Releases->PublishNuget->Create a release).
206+
141207
# Contributors
142208
This project welcomes contributions and suggestions. Most contributions require you to
143209
agree to a Contributor License Agreement (CLA) declaring that you have the right to,

binding.gyp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,28 @@
5656
},
5757
},
5858
"targets": [
59+
{
60+
"target_name": "maluubaspeech-csharp",
61+
"dependencies": [
62+
"maluubaspeech-source",
63+
],
64+
"sources": [
65+
"src/maluuba/speech/csharp/bindings.cpp"
66+
],
67+
"xcode_settings": {
68+
"CLANG_CXX_LANGUAGE_STANDARD": "c++17",
69+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES", # remove -fno-exceptions
70+
"GCC_ENABLE_CPP_RTTI": "YES", # remove -fno-rtti
71+
"OTHER_CFLAGS+": [
72+
"-Wall",
73+
"-pedantic",
74+
],
75+
"WARNING_CFLAGS!": [
76+
"-Wall",
77+
"-Wextra",
78+
],
79+
},
80+
},
5981
{
6082
"target_name": "maluubaspeech",
6183
"dependencies": [

docs/assets/js/search.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/classes/chainedrulebasedpreprocessor.html

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</s
236236
<li class=" tsd-kind-class">
237237
<a href="interval.html" class="tsd-kind-icon">Interval</a>
238238
</li>
239+
<li class=" tsd-kind-class">
240+
<a href="matcherconfig.html" class="tsd-kind-icon">Matcher<wbr>Config</a>
241+
</li>
239242
<li class=" tsd-kind-class">
240243
<a href="placematcherconfig.html" class="tsd-kind-icon">Place<wbr>Matcher<wbr>Config</a>
241244
</li>
@@ -305,12 +308,6 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</s
305308
<li class=" tsd-kind-variable">
306309
<a href="../globals.html#stringdistance" class="tsd-kind-icon">String<wbr>Distance</a>
307310
</li>
308-
<li class=" tsd-kind-object-literal">
309-
<a href="../globals.html#matchers" class="tsd-kind-icon">matchers</a>
310-
</li>
311-
<li class=" tsd-kind-object-literal">
312-
<a href="../globals.html#nlp" class="tsd-kind-icon">nlp</a>
313-
</li>
314311
</ul>
315312
</nav>
316313
</div>

0 commit comments

Comments
 (0)