ヘルプ センターヘルプ センター
単語埋め込みファイルの書き込み
writeWordEmbedding(emb,filename)
例
writeWordEmbedding(emb,filename) は、単語埋め込み emb をファイル filename に書き込みます。この関数は、ボキャブラリを UTF-8 の word2vec テキスト形式で書き込みます。
emb
filename
すべて折りたたむ
単語埋め込みに学習させ、テキスト ファイルに書き込みます。
サンプル データを読み込みます。ファイル sonnetsPreprocessed.txt には、シェイクスピアのソネット集の前処理されたバージョンが格納されています。ファイルには、1 行に 1 つのソネットが含まれ、単語がスペースで区切られています。sonnetsPreprocessed.txt からテキストを抽出し、テキストを改行文字で文書に分割した後、文書をトークン化します。
sonnetsPreprocessed.txt
filename = "sonnetsPreprocessed.txt"; str = extractFileText(filename); textData = split(str,newline); documents = tokenizedDocument(textData);
trainWordEmbedding を使用して単語埋め込みに学習させます。
trainWordEmbedding
emb = trainWordEmbedding(documents)
Training: 100% Loss: 0 Remaining time: 0 hours 0 minutes.
emb = wordEmbedding with properties: Dimension: 100 Vocabulary: ["thy" "thou" "love" "thee" "doth" "mine" "shall" "eyes" "sweet" "time" "nor" "beauty" "yet" "art" "heart" "o" "thine" "hath" "fair" "make" "still" ... ] (1x401 string)
単語埋め込みをテキスト ファイルに書き込みます。
filename = "exampleSonnetsEmbedding.vec"; writeWordEmbedding(emb,filename)
readWordEmbedding を使用して単語埋め込みファイルを読み取ります。
readWordEmbedding
emb = readWordEmbedding(filename)
wordEmbedding
入力単語埋め込み。wordEmbedding オブジェクトとして指定します。
ファイルの名前。string スカラー、文字ベクトル、または文字ベクトルを含む 1 行 1 列の cell 配列として指定します。
データ型: string | char | cell
string
char
cell
R2017b で導入
fastTextWordEmbedding | doc2sequence | wordEmbeddingLayer | wordEncoding | word2vec | vec2word | readWordEmbedding | trainWordEmbedding | wordEmbedding | tokenizedDocument
fastTextWordEmbedding
doc2sequence
wordEmbeddingLayer
wordEncoding
word2vec
vec2word
tokenizedDocument
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは 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:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office