TITLE:インポート (Importing)
原文 = http://ankisrs.net/docs/dev/manual.html#importing
----
目次
#contents
&br;&br;
Anki でインポートできるファイルは、エクスポート機能により作成された Anki単語帳パッケージ、Mnemosyne 2.0 の .db ファイル、そして SuperMemo の .xml ファイルです。ファイルをインポートするには、メニューのFile->Import をクリックしてください。
//Anki can import text files, packaged Anki decks created by the export feature, Mnemosyne 2.0 .db files, and SuperMemo .xml files. To import a file, click the File menu and then "Import".
* テキストファイルのインポート [#importing-text-files]
//* Importing text files
''プレーンテキスト'' ファイルであり、コンマ・セミコロン・タブ のいずれかによってフィールドが区切られたものなら、Anki にインポートできます。ただしいくつかの条件を満たす必要があります。
//Any ''plain text'' file that contains fields separated by commas, semicolons or tabs can be imported into Anki, provided some conditions are met.
-ファイルはプレーンテキスト (myfile.txt) でないといけません。他の形式、たとえば myfile.xls, myfile.rtf, myfile.doc などは、まずプレーンテキストとして保存する必要があります。
-文字コードは UTF-8 にしてください (後述)。
-Ankiは、最初の (コメントではない)行を見て、フィールドの個数を決めます。それ以降の行で、フィールドの個数が合っていない行があったら、すべて無視されます。
-最初の行は 区切り文字 も決めます --- 最初の行に ; (セミコロン) があれば Anki はそれを使います --- もし コンマがあれば それを使います、といったぐあいです。
//-The files must be plain text (myfile.txt). Other formats like myfile.xls, myfile.rtf, myfile.doc must be saved as a plain text file first.
//-The files must be in UTF-8 format (see below)
//-Anki determines the number of fields in the file by looking at the first (non-commented) line. Any lines in the file which have a different number of fields will be ignored.
//-The first line also defines the separating character - if Anki finds a ; on the first line it will use that - if it finds a comma it’ll use that, etc.
テキストファイルのフィールドはノート中のいずれかのフィールド(タグを含む)に割り当てられます。インポート時には、テキストファイル中のフィールドがノート中のフィールドのどのフィールドに対応するのかを選択します。
//Fields in your text file can be mapped to any field in your notes, including the tags field. You can choose which field in the text file corresponds to which field in the note when you import.
テキストファイルをインポートする際には、カードを入れる単語帳を選択することができます。1以上のテンプレートについて単語帳の上書きオプションを有効にしている場合、カードは選択した単語帳ではなくその単語帳に入る点に注意してください。
//When you import a text file, you can choose what deck to put the cards in. Keep in mind that if you have the deck override option set for one or more of your templates, the cards will go to that deck rather than the one you’ve selected.
以下は有効なファイルの例です:
//This is an example of a valid file:
foo bar; bar baz; baz quux
apple; banana; grape
フィールドの中に 改行 を入れる方法は 2つあります。
//There are two ways to include newlines in fields.
''複数行をエスケープする by placing the contents of the field in quotation marks''
//''Escape the multi-lines by placing the contents of the field in quotation marks:''
hello; "this is
a two line answer"
two; this is a one line one
''HTML形式の改行を使う''
//''Use HTML new lines:''
hello; this is<br>a two line answer
two; this is a one line one
HTML形式の改行を使うには、インポートダイアログの "allow HTML in fields" チェックボックスを有効にする必要があります。
//You need to turn on the "allow HTML in fields" checkbox in the import dialog for HTML newlines to work.
>''NOTE''
>複数行のエスケープは、複数ラインにわたる穴埋め問題を使用している場合には正しく動作しません。代わりに、HTML形式の改行を使用してください。
//>''NOTE''
//>Escaped multi-lines will not work correctly if you are using cloze deletions that span multiple lines. In this case, please use HTML newlines instead.
タグを別のフィールドに含め、インポートダイアログでそのフィールドをタグフィールドとして選択することができます:
//You can also include tags in another field and select it as a tags field in the import dialog:
first field; second field; tags
下の例は、1行目が無視 (#) されますが、有効なファイルです:
//This is an example of a valid file where the first line is ignored (#):
# this is a comment and is ignored
foo bar; bar baz; baz quux
field1; field2; field3
* 表計算シートとUTF-8 [#spreadsheets-and-utf-8]
//* Spreadsheets and UTF-8
ファイル中にラテン文字以外が含まれている場合(アクセント付きアルファベットや日本語など)、Anki はファイルが '''UTF-8 エンコード''' で保存されていることを期待します。これを行う最も簡単な方法は、Excelの代わりにフリーの表計算ソフトの LibreOffice を用いてファイルを編集することです。LibreOffice は UTF-8 に簡単に対応でき、更には Excel とは異なり複数行のコンテンツも正しくエクスポートすることができます。もし Excel を使い続けたい場合、[[このフォーラムの投稿(英語):https://docs.google.com/document/d/12YE_FS6A9ANLTESJNtPP116ti4nNmCBghyoJBRtno_k/edit?usp=sharing]]を参照してください。
//If you have non-Latin characters in your file (such as accents, Japanese and so on), Anki expects files to be saved in a '''UTF-8 encoding'''. The easiest way to do this is to use the free LibreOffice spreadsheet program instead of Excel to edit your file, as it supports UTF-8 easily, and also exports multi-line content properly, unlike Excel. If you wish to keep using Excel, please see [[this forum post:https://docs.google.com/document/d/12YE_FS6A9ANLTESJNtPP116ti4nNmCBghyoJBRtno_k/edit?usp=sharing]] for more information.
LibreOffice で Anki が対応するファイル形式に表計算シートを保存するには、ファイル>名前を付けて保存 (File>Save As) を選び、ファイルタイプとして "テキストCSV" を選択してください。デフォルトオプションを許可するとファイルが保存され、このファイルを Anki にインポートすることができます。
//To save your spreadsheet to a file Anki can read with LibreOffice, go to File>Save As, and then select CSV for the type of file. After accepting the default options, LibreOffice will save the file and you can then import the saved file into Anki.
* HTML [#html]
Anki はテキストファイルからインポートしたテキストを HTML (ウェブページに使われる言語) として扱います。これにより、テキストの太字、斜体や他の書式の設定されたテキストもテキストファイルにエクスポートでき、再度インポートすることができます。HTML の書式を含めたい場合は、インポート時に "allow HTML in fields" チェックボックスにチェックを入れてください。角カッコ(<, >)や他のHTML構文を含んだコンテンツをインポートしようとする場合は、このチェックボックスを外すのがよいでしょう。
//Anki can treat text imported from text files as HTML (the language used for web pages). This means that text with bold, italics and other formatting can be exported to a text file and imported again. If you want to include HTML formatting, you can check the "allow HTML in fields" checkbox when importing. You may wish to turn this off if you’re trying to import cards whose content contains angle brackets or other HTML syntax.
HTML の文字書式を使いつつ、角カッコも含んだファイルをインポートしたい場合は、角カッコを次のように表記してください:
- < ⇒ &lt;
- > ⇒ &gt;
//If you wish to use HTML for formatting your file but also wish to include angle brackets, you may write them differently: * < - < * > - >
* メディアのインポート [#importing-media]
//* Importing Media
もし テキストファイルのインポート時に 音声や画像を含めたければ、ファイルを [[collection.mediaフォルダ>2.0/ManagingFilesAndYourCollection#file-locations]] にコピーしてください。''メディアフォルダー内にサブディレクトリを入れないでください。一部の機能が動作しなくなります。''
//If you want to include audio and pictures from a text file import, copy the files into the collection.media folder, located in the same directory as your collection. If it doesn’t exist, you can create it. ''Do not put subdirectories in the media folder, or some features will not work.''
ファイルをコピーしたら、テキストファイルの中の ひとつのフィールドを 以下のように書き換えてください。
//After you’ve copied the files, change one of the fields in your text file as follows.
<img src="myimage.jpg">
または
//or
[sound:myaudio.mp3]
すべてのフィールドを同時に更新するには、他の方法として、検索 & 置換 の機能を使うこともできます。たとえばそれぞれのフィールドが "myaudio" といったテキストを含んでおり、これを音楽が再生されるように変更したければ、正規表現 (regular expressions) オプションを有効にして (.*) を検索し、これを "[sound:\1.mp3]" で置き換えてください。
//Alternatively, you can use the find & replace feature to update all the fields at once. If each field contains text like "myaudio", and you wish to make it play a sound, you’d search for (.*) and replace it with "[sound:\1.mp3]", with the '''regular expressions''' option enabled.
>''NOTE''
>これらの参照付きのテキストファイルをインポートする場合、必ず "Allow HTML" オプションを有効にしてください。
//>When importing a text file with these references, you must make sure to enable the "Allow HTML" option.
これと同じことをテンプレートを用いて、次のように行おうと考えるかもしれません:
//You might be tempted to do this in a template, like:
<img src="{{field name}}">
Ankiではこれを次の2つの理由によりサポートしていません:使用するメディアの検索はそれぞれのカードが描画されなければならないことから負荷が高く、またこのような機能は公開された単語帳の利用者にとってはわかりにくいからです。よって代わりに検索 & 置換 の機能を使ってください。
//Anki doesn’t support this for two reasons: searching for used media is expensive, as each card has to be rendered, and such functionality isn’t obvious to shared deck users. Please use the find & replace technique instead.
* バルクメディアのインポート [#bulk-media-imports]
//* Bulk media imports
大量のメディアを一度にインポートするときの他の方法は、[[メディアインポートのアドオン:https://ankiweb.net/shared/info/1531997860]] を使うことです。このアドオンは選択したフォルダの全てのファイルについて、表面がファイル名(拡張子抜き:"apple.jpg"→"apple")で裏面がイメージや音声となったノートを自動的に生成します。メディアやファイル名の配置を異なるものにしたい場合、一度ノートの作成後に [[ノートタイプの変更>2.0/Browser#other-menu-items]] をすることができます。
//Another option for importing large amounts of media at once is to use the [[media import add-on :https://ankiweb.net/shared/info/1531997860]]. This add-on will automatically create notes for all files in a folder you select, with the filenames on the front (minus the file extension, so if you have a file named apple.jpg, the front would say '''apple''') and the images or audio on the back. If you would like a different arrangement of media and filenames, you can [[change the note type :http://ankisrs.net/docs/manual.html#browsermisc]] of the created cards afterwards.
* タグの追加 [#adding-tags]
//* Adding Tags
インポートする全ての行に '''tag1''' と '''tag2''' を追加したいなら、テキストファイルの最初に以下を追加してください:
//If you want to add '''tag1''' and '''tag2''' to every line you’re importing, add the following to the top of the text file:
tags:tag1 tag2
* 重複と更新 [#duplicates-and-updating]
//* Duplicates and Updating
テキストファイルのインポート時、Ankiはノートが同一であるか否かの決定に最初のフィールドを用います。標準では、インポートするファイルの最初のフィールドがコレクション中のノートのフィールドと一致し、そのノートがインポートしようとしているものと同じノートタイプであれば、コレクション中のノートの他のフィールドがインポートするファイルの内容によって更新されます。インポート画面のドロップボックスではこの挙動を変えることができ、重複を完全に無視するか、既存のノートを更新する代わりに新しいノートとしてインポートすることを選択できます。
//When importing text files, Anki uses the first field to determine if a note is unique. By default, if the file you are importing has a first field that matches one of the existing notes in your collection and that existing note is the same type as the type you're importing, the existing note's other fields will be updated based on content of the imported file. A drop-down box in the import screen allows you to change this behaviour, to either ignore duplicates completely, or import them as new notes instead of updating existing ones.
>''ノート''
//>''NOTE''
>重複チェックは現在の単語帳だけでなく、"コレクションの全て" について行われます。カードをインポートしようとしているにも関わらずどのノートも更新されないときには、ノートがコレクションのどこかにすでに存在していないかどうかを確認してください。
//>The duplicate check is done for your 'entire collection', not just in the current deck. If Anki is indicating that notes have not changed when you expected them to be imported, please check that the notes are not already in your collection somewhere.
インポートしようとしているノートよりも古いバージョンがコレクションに既に存在している場合、インポートダイアログで設定された単語帳に移動されるのではなく、現在の単語帳で置き換えて更新されます。
//If you have updating turned on and older versions of the notes you're importing are already in your collection, they will be updated in place (in their current decks) rather than being moved to the deck you have set in the import dialog.
インポートしようとしているノートよりも古いバージョンがコレクションに既に存在している場合、インポートダイアログで設定された単語帳に移動されるのではなく、現在の単語帳で置き換えて更新されます。ノートが置き換え更新される場合、ノートに属するカードの学習スケジュール情報はそのまま維持されます。
//If you have updating turned on and older versions of the notes you're importing are already in your collection, they will be updated in place (in their current decks) rather than being moved to the deck you have set in the import dialog. If notes are updated in place, the existing scheduling information on all their cards will be preserved.
.apkg ファイルで重複がどのように扱われるのかについては、以下の [[単語帳パッケージ>2.0/Exporting#deck-package]] を参照してください。
//For info on how duplicates are handled in .apkg files, please see the [[Deck Packages :http://ankisrs.net/docs/manual.html#apkg-export]] section below.