MATLAB ヘルプ センター
編集距離範囲による最近傍の検出
idx = rangesearch(eds,words,maxDist)
[idx,d] = rangesearch(eds,words,maxDist)
idx = rangesearch(eds,words,maxDist) は、eds 内の単語のうち、words 内の単語から maxDist の距離以内にあるすべての単語を検出します。
idx
eds
words
maxDist
例
[idx,d] = rangesearch(eds,words,maxDist) は、対応する単語の編集距離も返します。
d
すべて折りたたむ
編集距離探索器を作成し、最大編集距離を 3 に指定します。
vocabulary = ["MathWorks" "MATLAB" "Simulink" "text" "analytics" "analysis"]; maxDist = 3; eds = editDistanceSearcher(vocabulary,maxDist);
編集距離が 1 以下で、"test"、"analytic"、および "analyze" に最も近い単語を検出します。
"test"
"analytic"
"analyze"
words = ["test" "analytic" "analyze"]; maxDist = 1; idx = rangesearch(eds,words,maxDist)
idx = 3×1 cell array {[ 4]} {[ 5]} {1×0 double}
"analyze" については、探索器に指定された範囲内の単語がありません。"test" と "analytic" については、それぞれ 1 件の結果があります。返されたインデックスを使用して、"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" の両方については、探索器に指定された範囲内の単語が 1 つあります。"analytic" については、2 件の結果があります。返されたインデックスと編集距離を使用して、"analytic" (2 番目の単語) の対応する単語を表示します。
i = 2; nearestWords = eds.Vocabulary(idx{i})
nearestWords = 1×2 string "analytics" "analysis"
d{i}
ans = 1×2 1 2
editDistanceSearcher
編集距離探索器。editDistanceSearcher オブジェクトとして指定します。
入力単語。string ベクトル、文字ベクトル、または文字ベクトルの cell 配列として指定します。words を文字ベクトルとして指定した場合、関数は引数を 1 つの単語として扱います。
データ型: string | char | cell
string
char
cell
最大検索距離。非負の数値として指定します。
この関数は、eds 内の単語のうち、words の要素との編集距離が maxDist 以下である単語のインデックスを検出し、編集距離の昇順で並べ替えます。
データ型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
single
double
int8
int16
int32
int64
uint8
uint16
uint32
uint64
探索器内の最近傍のインデックス。ベクトルの cell 配列として返されます。
idx{i} は、eds 内の単語のうち、words(i) との編集距離が maxDist 以下である単語のインデックスのベクトルで、編集距離の昇順で並べ替えられています。
idx{i}
words(i)
データ型: cell
近傍までの編集距離。ベクトルの cell 配列として返されます。
d{i} は、words(i) と、ボキャブラリ インデックス idx{i} で指定された eds 内の対応する単語との間の編集距離のベクトルです。
R2019a で導入
correctSpelling | editDistance | editDistanceSearcher | knnsearch | splitGraphemes | tokenizedDocument
correctSpelling
editDistance
knnsearch
splitGraphemes
tokenizedDocument
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
ヨーロッパ
アジア太平洋地域
最寄りの営業オフィスへのお問い合わせ