Skip to content

Commit 1ffaf68

Browse files
committed
Merge pull request #1943 from pguyot/w44/add-stub-for-string-jaro_similarity-2
Add stub for `string:jaro_similarity/2` These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents 50d44b2 + b910c51 commit 1ffaf68

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

doc/src/stubbed-functions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ The following functions are currently stubbed in AtomVM and always return a fixe
3131
|--------|----------|--------------|-------|
3232
| `io` | `set_ops/1,2` | `ok` | Standard IO options are currently ignored |
3333

34+
### Other functions
35+
36+
| Module | Function | Return Value | Notes |
37+
|--------|----------|--------------|-------|
38+
| `string` | `jaro_similarity/2` | `0.0` | |
39+
3440
## Important Considerations
3541

3642
When using AtomVM, be aware that stubbed functions will not provide the functionality you might

libs/estdlib/src/string.erl

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@
2727
%%-----------------------------------------------------------------------------
2828
-module(string).
2929

30-
-export([to_upper/1, to_lower/1, split/2, split/3, trim/1, trim/2, find/2, find/3, length/1]).
30+
-export([
31+
to_upper/1,
32+
to_lower/1,
33+
split/2, split/3,
34+
trim/1, trim/2,
35+
find/2, find/3,
36+
length/1,
37+
jaro_similarity/2
38+
]).
3139

3240
%%-----------------------------------------------------------------------------
3341
%% @param Input a string or character to convert
@@ -262,3 +270,15 @@ length(String) when is_list(String) ->
262270
erlang:length(String);
263271
length(String) when is_binary(String) ->
264272
erlang:length(unicode:characters_to_list(String)).
273+
274+
%%-----------------------------------------------------------------------------
275+
%% @param String1 first string to compare
276+
%% @param String2 second string to compare
277+
%% @doc Calculate the Jaro similarity between two strings (stub implementation).
278+
%%
279+
%% This is a stub implementation that always returns 0.0, used for compatibility.
280+
%% @end
281+
%%-----------------------------------------------------------------------------
282+
-spec jaro_similarity(String1 :: unicode:chardata(), String2 :: unicode:chardata()) -> float().
283+
jaro_similarity(_String1, _String2) ->
284+
0.0.

0 commit comments

Comments
 (0)