rangesearch
편집 거리 범위로 최근접이웃 구하기
설명
예제
범위 내의 최근접이웃 구하기
편집 거리 탐색기를 만들고 최대 편집 거리를 3으로 지정합니다.
vocabulary = ["MathWorks" "MATLAB" "Simulink" "text" "analytics" "analysis"]; maxDist = 3; eds = editDistanceSearcher(vocabulary,maxDist);
편집 거리가 1 이하이면서 "test"
, "analytic"
, "analyze"
에 가장 가까운 단어를 찾습니다.
words = ["test" "analytic" "analyze"]; maxDist = 1; idx = rangesearch(eds,words,maxDist)
idx=3×1 cell array
{[ 4]}
{[ 5]}
{1x0 double}
"analyze"
의 경우 탐색기에서 지정한 범위 내에 단어가 없습니다. "test"
와 "analytic"
의 경우 각각 하나의 결과가 있습니다. 반환된 인덱스를 사용하여 "test"
에 대응되는 단어를 표시합니다.
nearestWords = eds.Vocabulary(idx{2})
nearestWords = "analytics"
편집 거리가 3 이하이면서 "test"
, "analytic"
, "analyze"
에 가장 가까운 단어를 찾고 각 단어에 대응되는 편집 거리를 구합니다.
words = ["test" "analytic" "analyze"]; maxDist = 3; [idx,d] = rangesearch(eds,words,maxDist)
idx=3×1 cell array
{[ 4]}
{[5 6]}
{[ 6]}
d=3×1 cell array
{[ 1]}
{[1 2]}
{[ 3]}
"test"
와 "analyze"
의 경우, 탐색기에서 지정한 범위 내에 단어가 한 개 있습니다. "analytic"
의 경우, 두 가지 결과가 있습니다. 반환된 인덱스와 해당 편집 거리를 사용하여 "analytic"
에 대응되는 단어를 표시합니다.
i = 2; nearestWords = eds.Vocabulary(idx{i})
nearestWords = 1x2 string
"analytics" "analysis"
d{i}
ans = 1×2
1 2
입력 인수
eds
— 편집 거리 탐색기
editDistanceSearcher
편집 거리 탐색기로, editDistanceSearcher
객체로 지정됩니다.
words
— 입력 단어
string형 벡터 | 문자형 벡터 | 문자형 벡터로 구성된 셀형 배열
입력 단어로, string형 벡터, 문자형 벡터 또는 문자형 벡터로 구성된 셀형 배열로 지정됩니다. words
를 문자형 벡터로 지정할 경우 이 함수는 인수를 단일 단어로 처리합니다.
데이터형: string
| char
| cell
출력 인수
d
— 이웃에 대한 편집 거리
벡터로 구성된 셀형 배열
이웃에 대한 편집 거리로, 벡터로 구성된 셀형 배열로 반환됩니다.
d{i}
는 words(i)
와 단어집 인덱스 idx{i}
에 의해 주어지는 eds
의 대응되는 단어 사이의 편집 거리로 구성된 벡터입니다.
데이터형: cell
버전 내역
R2019a에 개발됨
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)