chore(i8n,learn): processed translations
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
15047f2d90
commit
e5c44a3ae5
@ -1,66 +1,88 @@
|
||||
---
|
||||
id: 5a23c84252665b21eecc7ec2
|
||||
title: Jaro距离
|
||||
title: Jaro distance
|
||||
challengeType: 5
|
||||
videoUrl: ''
|
||||
forumTopicId: 302292
|
||||
dashedName: jaro-distance
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
Jaro距离是两个弦之间相似性的度量。两个弦的Jaro距离越高,弦越相似。对得分进行归一化,使得**0**等于没有相似性, **1**等于完全匹配。定义两个给定字符串\\(s_1 \\)和\\(s_2 \\)的Jaro距离\\(d_j \\)是\\ begin {align} d_j = \\ begin {cases} 0 && \\ text {if} m = 0 \\\\\\ \\ {\\ frac {1} {3}} \\ left({\\ frac {m} {| s\_ {1} |}} + {\\ frac {m} {| s\_ {2} |}} + {\\ frac { mt} {m}} \\ right)&& \\ text {otherwise} \\ end {cases} \\ end {align}其中:
|
||||
The Jaro distance is a measure of similarity between two strings. The higher the Jaro distance for two strings is, the more similar the strings are. The score is normalized such that `0` equates to no similarity and `1` is an exact match.
|
||||
|
||||
- \\(m \\)是*匹配字符*的数量;
|
||||
- \\(t \\)是*换位*次数的一半。
|
||||
**Definition**
|
||||
|
||||
分别来自\\(s_1 \\)和\\(s_2 \\)的两个字符只有在相同且不远于\\(\\ left \\ lfloor \\ frac {\\ max(| s_1 |,| s_2 |)}时才被认为是*匹配的* {2} \\右\\ rfloor-1 \\)。将\\(s_1 \\)的每个字符与\\(s_2 \\)中的所有匹配字符进行比较。匹配(但不同的序列顺序)字符除以2的数量定义了*转置*的数量。 **示例**给定字符串\\(s_1 \\) *DWAYNE*和\\(s_2 \\) *DUANE*我们发现:
|
||||
The Jaro distance \\( d_j \\) of two given strings \\(s_1\\) and \\(s_2\\) is
|
||||
|
||||
- \\(m = 4 \\)
|
||||
- \\(| s_1 | = 6 \\)
|
||||
- \\(| s_2 | = 5 \\)
|
||||
- \\(t = 0 \\)
|
||||
\\begin{align}d_j = \\begin{cases}0& & \\text{if }m=0 \\\\\\\\{\\frac {1}{3}}\\left({\\frac {m}{|s\_{1}|}}+{\\frac {m}{|s\_{2}|}}+{\\frac {m-t}{m}}\\right)& & \\text{otherwise}\\end{cases}\\end{align}
|
||||
|
||||
我们发现Jaro得分为:\\(d_j = \\ frac {1} {3} \\ left(\\ frac {4} {6} + \\ frac {4} {5} + \\ frac {4-0} {4} \\ right)= 0.822 \\)。编写一个函数a,它接受两个字符串作为参数并返回相关的Jaro距离。
|
||||
Where:
|
||||
|
||||
<ul>
|
||||
<li>\(m\) is the number of <i>matching characters</i>;</li>
|
||||
<li> \(t\) is half the number of <i>transpositions</i>.</li>
|
||||
</ul>
|
||||
|
||||
Two characters from \\(s_1\\) and \\(s_2\\) respectively, are considered *matching* only if they are the same and not farther than \\(\\left\\lfloor\\frac{\\max(|s_1|,|s_2|)}{2}\\right\\rfloor-1\\).
|
||||
|
||||
Each character of \\(s_1\\) is compared with all its matching characters in \\(s_2\\) . The number of matching (but different sequence order) characters divided by 2 defines the number of *transpositions*.
|
||||
|
||||
**Example**
|
||||
|
||||
Given the strings \\(s_1\\) *DWAYNE* and \\(s_2\\) *DUANE* we find:
|
||||
|
||||
<ul>
|
||||
<li>\(m = 4\)</li>
|
||||
<li>\(|s_1| = 6\)</li>
|
||||
<li>\(|s_2| = 5\)</li>
|
||||
<li>\(t = 0\)</li>
|
||||
</ul>
|
||||
|
||||
We find a Jaro score of: \\(d_j = \\frac{1}{3}\\left(\\frac{4}{6} + \\frac{4}{5} + \\frac{4-0}{4}\\right) = 0.822\\).
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a function a that takes two strings as parameters and returns the associated Jaro distance.
|
||||
|
||||
# --hints--
|
||||
|
||||
`jaro`应该是一个功能。
|
||||
`jaro` should be a function.
|
||||
|
||||
```js
|
||||
assert(typeof jaro == 'function');
|
||||
```
|
||||
|
||||
`jaro(""+tests[0][0]+"",""+tests[0][1]+"")`应返回一个数字。
|
||||
`jaro("MARTHA", "MARHTA")` should return a number.
|
||||
|
||||
```js
|
||||
assert(typeof jaro('MARTHA', 'MARHTA') == 'number');
|
||||
```
|
||||
|
||||
`jaro(""+tests[0][0]+"",""+tests[0][1]+"")`应该返回`"+results[0]+"` 。
|
||||
`jaro("MARTHA", "MARHTA")` should return `0.9444444444444445`.
|
||||
|
||||
```js
|
||||
assert.equal(jaro('MARTHA', 'MARHTA'), 0.9444444444444445);
|
||||
```
|
||||
|
||||
`jaro(""+tests[1][0]+"",""+tests[1][1]+"")`应返回`"+results[1]+"` 。
|
||||
`jaro("DIXON", "DICKSONX")` should return `0.7666666666666666`.
|
||||
|
||||
```js
|
||||
assert.equal(jaro('DIXON', 'DICKSONX'), 0.7666666666666666);
|
||||
```
|
||||
|
||||
`jaro(""+tests[2][0]+"",""+tests[2][1]+"")`应返回`"+results[2]+"` 。
|
||||
`jaro("JELLYFISH", "SMELLYFISH")` should return `0.8962962962962964`.
|
||||
|
||||
```js
|
||||
assert.equal(jaro('JELLYFISH', 'SMELLYFISH'), 0.8962962962962964);
|
||||
```
|
||||
|
||||
`jaro(""+tests[3][0]+"",""+tests[3][1]+"")`应返回`"+results[3]+"` 。
|
||||
`jaro("HELLOS", "CHELLO")` should return `0.888888888888889`.
|
||||
|
||||
```js
|
||||
assert.equal(jaro('HELLOS', 'CHELLO'), 0.888888888888889);
|
||||
```
|
||||
|
||||
`jaro(""+tests[4][0]+"",""+tests[4][1]+"")`应该返回`"+results[4]+"` 。
|
||||
`jaro("ABCD", "BCDA")` should return `0.8333333333333334`.
|
||||
|
||||
```js
|
||||
assert.equal(jaro('ABCD', 'BCDA'), 0.8333333333333334);
|
||||
|
Reference in New Issue
Block a user