diff --git a/.gitignore b/.gitignore index cf141a4..c352e3d 100644 --- a/.gitignore +++ b/.gitignore @@ -129,4 +129,5 @@ dmypy.json .pyre/ upload.sh -build/ \ No newline at end of file +build/ +Backup/ \ No newline at end of file diff --git a/Africa Educational Research Journal/chicago-author-date-aerj-ja-test.docx b/Africa Educational Research Journal/chicago-author-date-aerj-ja-test.docx deleted file mode 100644 index a337d6a..0000000 Binary files a/Africa Educational Research Journal/chicago-author-date-aerj-ja-test.docx and /dev/null differ diff --git a/Africa Educational Research Journal/chicago-author-date-aerj-ja.csl b/Africa Educational Research Journal/chicago-author-date-aerj-ja.csl deleted file mode 100644 index 5d4eac5..0000000 --- a/Africa Educational Research Journal/chicago-author-date-aerj-ja.csl +++ /dev/null @@ -1,958 +0,0 @@ - - diff --git a/IC Zemi at HUS.OU/README.MD b/IC Zemi at HUS.OU/README.MD deleted file mode 100644 index 070ea2d..0000000 --- a/IC Zemi at HUS.OU/README.MD +++ /dev/null @@ -1,61 +0,0 @@ -# ICゼミ(日本語) -## ダウンロード - ダウンロードは[こちら](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-iczemi-ja.csl)に右クリックして、名前をつけて保存してください。サンプルのワードファイルは[こちら](https://github.com/frianasoa/Zotero-Styles-JP/raw/main/IC%20Zemi%20at%20HUS.OU/chicago-author-date-iczemi-ja.docx)からダウンロードできる。
- -## インストール -ダウンロードしたファイルをダブルクリックでよいが、できない場合は図1の①→②→③を押して、ファイルを選択して、インストールする。
-
- -図1. スタイルをインストールする -

- -### インストールエラー - このスタイルは日本語と英語を両方表示できるように、CSLの原則を守らない書き方をしなければならない。インストールする際、エラーはでるが、図2のように「OK」を押せば、インストールは無事にできる。
- -
- -図2. インストールエラー -

- -## 日本語の文献について - 日本語の文献の情報には「name-kana」(並べ替のキー)の値を設定する必要がある。このフィールドの値がある文献は日本語のスタイルになる。
-例えば 図3のように、「山下彰一(1999)」の「その他」のところに「name-kana:やましたしょういち」と入力する。
- -
- -図3. 読み方(並べ替のキー)を設定する -
- -## カタカナの名前について - Zoteroは著者名が日本語だと自動的に「姓 → 名」の順で名前を表示する。しかし、ICゼミのスタイルではカタカナの名前は筆頭者だけ、「姓、名」というふうになって、その後は「名・姓」という表記になる。これは自動的にできないため、手入力で、「、」や「・」を入れる。
- -### 著者が3人以上の場合 -著者が3人以上の場合は図4のように対応する。筆頭者の「名」の前に「、」を入れる①。2人目からは「単独のフィールド」(著者名を「姓、名」にわけない[表示を切り替えるには③を押す])を使って「名・姓」②のようにいれる。
- -
- -図4. 手入力でカタカナの名前を入れる -
- -### 著者が2人の場合 -著者が2人の場合は筆頭者の「名」の前に「、」を入れるだけ、そして、最終的に参考文献を修正する。 - -### なぜ手入力がいるか? - 現在のZoteroのバージョンは限界があるため(正しくはCSLの限界)、手入力がいる。将来のバージョンでは要らなくなる可能性はあるが、その時にこのスタイルを更新する。そうすると、お使いのZoteroの情報も通常(手入力した点を削除)に戻さないといけないが、更新したらまた通知する。 - -## その他のスタイルをダウンロード -ダウンロードするには、右クリックで名前をつけて保存! - -* ICゼミ [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-iczemi-ja.csl) - -* 共生学ジャーナル(日本語) [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-kyosei-ja.csl) - -* 共生学ジャーナル(英語) [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-kyosei-en.csl) - -* ジャーナル『未来共創』 [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-kyoso-ja.csl) - -* アフリカ教育研究 [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-aerj-ja.csl) - -* 国際開発研究(日本語) [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-jids-ja.csl) - -* 国際開発研究(英語) [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-jids-en.csl) diff --git a/IC Zemi at HUS.OU/chicago-author-date-iczemi-en.docx b/IC Zemi at HUS.OU/chicago-author-date-iczemi-en.docx deleted file mode 100644 index b76a594..0000000 Binary files a/IC Zemi at HUS.OU/chicago-author-date-iczemi-en.docx and /dev/null differ diff --git a/IC Zemi at HUS.OU/chicago-author-date-iczemi-ja.docx b/IC Zemi at HUS.OU/chicago-author-date-iczemi-ja.docx deleted file mode 100644 index c3a7eea..0000000 Binary files a/IC Zemi at HUS.OU/chicago-author-date-iczemi-ja.docx and /dev/null differ diff --git a/Journal - Mirai Kyoso/chicago-author-date-kyoso-ja-test.docx b/Journal - Mirai Kyoso/chicago-author-date-kyoso-ja-test.docx deleted file mode 100644 index 59314a4..0000000 Binary files a/Journal - Mirai Kyoso/chicago-author-date-kyoso-ja-test.docx and /dev/null differ diff --git a/Journal - Mirai Kyoso/chicago-author-date-kyoso-ja.csl b/Journal - Mirai Kyoso/chicago-author-date-kyoso-ja.csl deleted file mode 100644 index 8316581..0000000 --- a/Journal - Mirai Kyoso/chicago-author-date-kyoso-ja.csl +++ /dev/null @@ -1,923 +0,0 @@ - - diff --git a/Journal of International Development Studies/chicago-author-date-jids-en.csl b/Journal of International Development Studies/chicago-author-date-jids-en.csl deleted file mode 100644 index d96f366..0000000 --- a/Journal of International Development Studies/chicago-author-date-jids-en.csl +++ /dev/null @@ -1,695 +0,0 @@ - - diff --git a/Journal of International Development Studies/chicago-author-date-jids-ja-test.docx b/Journal of International Development Studies/chicago-author-date-jids-ja-test.docx deleted file mode 100644 index 0b9c4c1..0000000 Binary files a/Journal of International Development Studies/chicago-author-date-jids-ja-test.docx and /dev/null differ diff --git a/Journal of International Development Studies/chicago-author-date-jids-ja.csl b/Journal of International Development Studies/chicago-author-date-jids-ja.csl deleted file mode 100644 index 86687d8..0000000 --- a/Journal of International Development Studies/chicago-author-date-jids-ja.csl +++ /dev/null @@ -1,967 +0,0 @@ - - diff --git a/Journal of Kyosei Studies/README.MD b/Journal of Kyosei Studies/README.MD deleted file mode 100644 index 619d2e3..0000000 --- a/Journal of Kyosei Studies/README.MD +++ /dev/null @@ -1,63 +0,0 @@ -# 共生学ジャーナル(日本語) -## ダウンロード - ダウンロードは[こちら](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-kyosei-ja.csl)に右クリックして、名前をつけて保存してください。 - -## インストール -ダウンロードしたファイルをダブルクリックでよいが、できない場合は図1の①→②→③を押して、ファイルを選択して、インストールする。
-
- -図1. スタイルをインストールする -

- -### インストールエラー - このスタイルは日本語と英語を両方表示できるように、CSLの原則を守らない書き方をしなければならない。インストールする際、エラーはでるが、図2のように「OK」を押せば、インストールは無事にできる。
- -
- -図2. インストールエラー -

- -## 日本語の文献について - 日本語の文献の情報には「name-kana」(並べ替のキー)の値を設定する必要がある。このフィールドの値がある文献は日本語のスタイルになる。
- 例えば 図3のように、「山下彰一(1999)」の「その他」のところに「name-kana:やましたしょういち」と入力する。
-  -
- -図3. 読み方(並べ替のキー)を設定する -
- -## カタカナの名前について - Zoteroは著者名が日本語だと自動的に「姓 → 名」の順で名前を表示する。筆頭者だけは「姓、名」というふうにできる。その後は自動的にできないため、手入力で、「、」や「・」を入れる。
- -### 著者が2人以上の場合 - 著者が2人以上の表記は今の時点で共生学ジャーナルの規定で定められていない。あまりないかもしれない。
-例として、別のジャーナルのスタイルをあげる。著者名は「、」でわけられている。カタカナの名前の場合、筆頭者意外は「名・姓」となっている。
- 図4のように対応してみる。筆頭者の「名」の前に「、」を入れる①。2人目からは「単独のフィールド」(著者名を「姓、名」にわけない[表示を切り替えるには③を押す])を使って「名・姓」②のようにいれる。
- -
- -図4. 手入力でカタカナの名前を入れる -

- -最終的に手入力で参考文献を修正する必要がある。 - -### なぜ手入力がいるか? - 共生学ジャーナルでは参考文献のところで「姓 名」の間に半角スペースを入れる。簡単のようで、今のZoteroの技術にはできない。 - 現在のZoteroのバージョンは限界があるため(正しくはCSLの限界)、その他にも手入力がいる。将来のバージョンでは要らなくなる可能性はあるが、その時にこのスタイルを更新する。そうすると、お使いのZoteroの情報も通常(手入力した点を削除)に戻さないといけないが、更新したらまた通知する。 - -## その他のスタイルをダウンロード -ダウンロードするには、右クリックで名前をつけて保存! - -* 共生学ジャーナル [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-kyosei-ja.csl) - -* 共生学ジャーナル(英語) [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-kyosei-en.csl) - -* ICゼミ [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-iczemi-ja.csl) - -* ジャーナル『未来共創』 [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-kyoso-ja.csl) - -* アフリカ教育研究 [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-aerj-ja.csl) - -* 国際開発研究(日本語) [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-jids-ja.csl) - -* 国際開発研究(英語) [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-jids-en.csl) diff --git a/Journal of Kyosei Studies/chicago-author-date-kyosei-en-test.docx b/Journal of Kyosei Studies/chicago-author-date-kyosei-en-test.docx deleted file mode 100644 index b438a1a..0000000 Binary files a/Journal of Kyosei Studies/chicago-author-date-kyosei-en-test.docx and /dev/null differ diff --git a/Journal of Kyosei Studies/chicago-author-date-kyosei-en.csl b/Journal of Kyosei Studies/chicago-author-date-kyosei-en.csl deleted file mode 100644 index b708905..0000000 --- a/Journal of Kyosei Studies/chicago-author-date-kyosei-en.csl +++ /dev/null @@ -1,683 +0,0 @@ - - diff --git a/Journal of Kyosei Studies/chicago-author-date-kyosei-ja-test.docx b/Journal of Kyosei Studies/chicago-author-date-kyosei-ja-test.docx deleted file mode 100644 index ce6b992..0000000 Binary files a/Journal of Kyosei Studies/chicago-author-date-kyosei-ja-test.docx and /dev/null differ diff --git a/Journal of Kyosei Studies/chicago-author-date-kyosei-ja.csl b/Journal of Kyosei Studies/chicago-author-date-kyosei-ja.csl deleted file mode 100644 index 9abbb63..0000000 --- a/Journal of Kyosei Studies/chicago-author-date-kyosei-ja.csl +++ /dev/null @@ -1,925 +0,0 @@ - - diff --git a/Osaka University - International Collaboration and Development Studies/README.MD b/Osaka University - International Collaboration and Development Studies/README.MD deleted file mode 100644 index 87786f7..0000000 --- a/Osaka University - International Collaboration and Development Studies/README.MD +++ /dev/null @@ -1,59 +0,0 @@ -# ICゼミ(日本語) -## ダウンロード - ダウンロードは[こちら](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-iczemi-ja.csl)に右クリックして、名前をつけて保存してください。サンプルのワードファイルは[こちら](https://github.com/frianasoa/Zotero-Styles-JP/raw/main/IC%20Zemi%20at%20HUS.OU/chicago-author-date-iczemi-ja.docx)からダウンロードできる。
- -## インストール -ダウンロードしたファイルをダブルクリックでよいが、できない場合は図1の①→②→③を押して、ファイルを選択して、インストールする。
-
- -図1. スタイルをインストールする -

- -### インストールエラー - このスタイルは日本語と英語を両方表示できるように、CSLの原則を守らない書き方をしなければならない。インストールする際、エラーはでるが、図2のように「OK」を押せば、インストールは無事にできる。
- -
- -図2. インストールエラー -

- -## 日本語の文献について - 日本語の文献の情報には「name-kana」(並べ替のキー)の値を設定する必要がある。このフィールドの値がある文献は日本語のスタイルになる。
-例えば 図3のように、「山下彰一(1999)」の「その他」のところに「name-kana:やましたしょういち」と入力する。
- -
- -図3. 読み方(並べ替のキー)を設定する -
- -## カタカナの名前について - Zoteroは著者名が日本語だと自動的に「姓 → 名」の順で名前を表示する。しかし、ICゼミのスタイルではカタカナの名前は筆頭者だけ、「姓、名」というふうになって、その後は「名・姓」という表記になる。これは自動的にできないため、手入力で、「、」や「・」を入れる。
- -### 著者が3人以上の場合 -著者が3人以上の場合は図4のように対応する。筆頭者の「名」の前に「、」を入れる①。2人目からは「単独のフィールド」(著者名を「姓、名」にわけない[表示を切り替えるには③を押す])を使って「名・姓」②のようにいれる。
- -
- -図4. 手入力でカタカナの名前を入れる -
- -### 著者が2人の場合 -著者が2人の場合は筆頭者の「名」の前に「、」を入れるだけ、そして、最終的に参考文献を修正する。 - -### なぜ手入力がいるか? - 現在のZoteroのバージョンは限界があるため(正しくはCSLの限界)、手入力がいる。将来のバージョンでは要らなくなる可能性はあるが、その時にこのスタイルを更新する。そうすると、お使いのZoteroの情報も通常(手入力した点を削除)に戻さないといけないが、更新したらまた通知する。 - -## その他のスタイルをダウンロード -ダウンロードするには、右クリックで名前をつけて保存! - -* ICゼミ [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-iczemi-ja.csl) - -* 共生学ジャーナル [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-kyosei-ja.csl) - -* ジャーナル『未来共創』 [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-kyoso-ja.csl) - -* アフリカ教育研究 [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-aerj-ja.csl) - -* 国際開発研究(日本語) [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-jids-ja.csl) - -* 国際開発研究(英語) [ダウンロード](https://github.com/frianasoa/Zotero-Styles-JP/releases/latest/download/chicago-author-date-jids-en.csl) diff --git a/Osaka University - International Collaboration and Development Studies/chicago-author-date-iczemi-ja.csl b/Osaka University - International Collaboration and Development Studies/chicago-author-date-iczemi-ja.csl deleted file mode 100644 index fd609a5..0000000 --- a/Osaka University - International Collaboration and Development Studies/chicago-author-date-iczemi-ja.csl +++ /dev/null @@ -1,977 +0,0 @@ - - diff --git a/Osaka University - International Collaboration and Development Studies/chicago-author-date-iczemi-ja.docx b/Osaka University - International Collaboration and Development Studies/chicago-author-date-iczemi-ja.docx deleted file mode 100644 index c3a7eea..0000000 Binary files a/Osaka University - International Collaboration and Development Studies/chicago-author-date-iczemi-ja.docx and /dev/null differ diff --git a/README.md b/README.md index a386788..4d72540 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,16 @@ # About -## Migrating to a new repository +## Migrated to a new repository Please check this new repository for newer style files.
[https://github.com/frianasoa/pycsl](https://github.com/frianasoa/pycsl) -## Zotero styles for Japanese publications -This is a repository for Zotero styles used by several Academic Societies I belong to. I originally created these styles for personal use but considered sharing them to benefit more people. \ -It also includes the python scripts I used to generate each style. I am cleaning the code from time to time. I will add new styles as they become available. I did my best to rigorously follow the guidelines of the societies but in doubt please see the societies' manuals and edit accordingly.\ -These styles can be used if you write in English, Japanese or both. Due to limitations (style specifications and how Zotero handles the styles), no other languages can be added (not easily anyway). Due to the way the style is written it is not eligible to be submitted to Zotero style repository either.\ -I created these styles because I want to stick with Zotero. However, if you are in need for more control with multilingual citations and bibliography, please consider checking Juris-m (https://juris-m.github.io/). - -## Africa Educational Research Journal -In this folder, you will find the (unofficial) styles for the Africa Educational Research Journal, a journal of the Japan Society for Africa Educational Research. I have only set the bibliography and citation for book, book chapter, and journal article following the note to contributors. I have aditionally added style for web page. \ -Source: https://www.japan-society-for-africa-educational-research.org/app/download/8349858856/AERJ13.pdf \ -Page 91-96 - -## Journal of International Development Studies -In this folder, you will find the (unofficial) styles for the Journal of International Development Studies. I have only set the bibliography and citation for book, book chapter, journal article, and web page. \ -Source (en): https://drive.google.com/file/d/1VAu6cAs5beGPgYpwNwfOXISZgXEaOKnL/view \ -Source (ja): https://drive.google.com/file/d/1M0SKuOO7Bi_vsBWZ98cW99kGKXXwst-Y/view (pp. 195-197) - -## Journal of Kyosei Studies -In this folder, you will find the (unofficial) styles for the Journal of Kyosei Studies of Osaka University. Due to current limitation of it is not possible to insert space between last name and given name suggested by the guidelines. Inserting comma after the last name of an author in katakana is also impossible for the moment. Please edit them manually at the end of your workflow. \ -Source: http://kyosei.hus.osaka-u.ac.jp/wp-content/uploads/2021/07/3505fd795307005aa71cd3a930f2557a.pdf - -## Mirai Kyoso Journal (ジャーナル『未来共創』) -In this folder, you will find the (unofficial) styles for Journal Mirai Kyoso of Osaka University. Due to current limitations of csl and Zotero, the double indent seems impossible to achieve. Inserting comma after the last name of an author in katakana is also impossible for the moment. Please edit them manually at the end of your workflow. \ -Source: http://www.hus.osaka-u.ac.jp/mirai-kyoso/ja/journal/mirai-kyoso-journaltoko_11.pdf - -## International Collaboration and Development Studies -[Click here (Japanese)](https://github.com/frianasoa/Zotero-Styles-JP/tree/main/IC%20Zemi%20at%20HUS.OU) - -# Instructions -## Install -* Head to the release page: https://github.com/frianasoa/Zotero-Styles-JP/releases/ -* Download the latest version of the *.csl file. -* Install the *.csl file into your Zotero. \ -Please check this link if you do not know how to install the file. \ -Install instructions: https://www.zotero.org/support/styles#alternative_installation_methods. - -## Use -* For each entry in Japanese, please add "name-kana:ひらがな" into the extra field (ひらがな: hiragana reading of the first author's name). The style uses this information to format and sort Japanese entries. -* If the extra field already contains other information, please add a line break and write on the next line. -* Enjoy adding citations and bibliography normally. - -# Disclaimer -I am just sharing the csl files I used for my own publications. This repository is not affiliated with the journal or the academic society. Always manually check the display before submitting. Anything not supported by the style should be edited by hand. I will put them in the todo list for the next version. \ -This style may change in the future, in a way that you may have to change the value of extra, should you plan to update to the latest version later. This is due to the change in availability of accepted syntax in the csl format. \ No newline at end of file +## Download from here +* [International Collaboration and Development Studies @ Osaka University (Japanese)](https://github.com/frianasoa/pycsl/releases/latest/download/chicago-author-date-iczemi-ja.csl) +* [International Collaboration and Development Studies @ Osaka University (English)](https://github.com/frianasoa/pycsl/releases/latest/download/chicago-author-date-iczemi-en.csl) +* [Journal of Kyosei Studies @ Osaka University (Japanese)](https://github.com/frianasoa/pycsl/releases/latest/download/chicago-author-date-kyosei-ja.csl) +* [Journal of Kyosei Studies @ Osaka University (English)](https://github.com/frianasoa/pycsl/releases/latest/download/chicago-author-date-kyosei-en.csl) +* [Journal - Mirai Kyoso @ Osaka University (Japanese)](https://github.com/frianasoa/pycsl/releases/latest/download/chicago-author-date-kyoso-ja.csl) +* [Journal - Mirai Kyoso @ Osaka University (English)](https://github.com/frianasoa/pycsl/releases/latest/download/chicago-author-date-kyoso-en.csl) +* [Africa Educational Research Journal (Japanese)](https://github.com/frianasoa/pycsl/releases/latest/download/chicago-author-date-aerj-ja.csl) +* [Africa Educational Research Journal (English)](https://github.com/frianasoa/pycsl/releases/latest/download/chicago-author-date-aerj-en.csl) +* [Journal of International Development Studies (Japanese)](https://github.com/frianasoa/pycsl/releases/latest/download/chicago-author-date-jids-ja.csl) +* [Journal of International Development Studies (English)](https://github.com/frianasoa/pycsl/releases/latest/download/chicago-author-date-jids-en.csl) \ No newline at end of file diff --git a/assets/adding-extra.png b/assets/adding-extra.png deleted file mode 100644 index e7e5081..0000000 Binary files a/assets/adding-extra.png and /dev/null differ diff --git a/assets/install-error.png b/assets/install-error.png deleted file mode 100644 index 3429fe1..0000000 Binary files a/assets/install-error.png and /dev/null differ diff --git a/assets/installing-style.png b/assets/installing-style.png deleted file mode 100644 index c9e6f7b..0000000 Binary files a/assets/installing-style.png and /dev/null differ diff --git a/assets/katakana-names.png b/assets/katakana-names.png deleted file mode 100644 index 9f6721f..0000000 Binary files a/assets/katakana-names.png and /dev/null differ diff --git a/create.py b/create.py deleted file mode 100644 index bdc5890..0000000 --- a/create.py +++ /dev/null @@ -1,72 +0,0 @@ -from scripts.aerj import Aerj -from scripts.jids import Jids -from scripts.jidsen import JidsEn -from scripts.kyosei import Kyosei -from scripts.kyoseien import Kyoseien -from scripts.kyoso import Kyoso -from scripts.iczemi import ICZemi - -Aerj( - input = 'scripts/source/chicago-author-date.csl', - journal = "Africa Educational Research Journal", - suffix = {"id": "aerj-ja", "title":"AERJ (日本語)", "language": "Japanese"}, - doclinks = [ - "https://www.japan-society-for-africa-educational-research.org/app/download/8289809356/AERJ12.pdf" - ] -).create() - -Jids( - input = 'scripts/source/chicago-author-date.csl', - journal = "Journal of International Development Studies", - suffix = {"id": "jids-ja", "title":"JIDS (日本語)", "language": "Japanese"}, - doclinks = [ - "https://drive.google.com/file/d/1VAu6cAs5beGPgYpwNwfOXISZgXEaOKnL/view", - "https://drive.google.com/file/d/1M0SKuOO7Bi_vsBWZ98cW99kGKXXwst-Y/view", - ] -).create() - -JidsEn( - input = 'scripts/source/chicago-author-date.csl', - journal = "Journal of International Development Studies", - suffix = {"id": "jids-en", "title":"JIDS (English)", "language": "English"}, - doclinks = [ - "https://drive.google.com/file/d/1VAu6cAs5beGPgYpwNwfOXISZgXEaOKnL/view", - "https://drive.google.com/file/d/1M0SKuOO7Bi_vsBWZ98cW99kGKXXwst-Y/view", - ] -).create() - -Kyosei( - input = 'scripts/source/chicago-author-date.csl', - journal = "Journal of Kyosei Studies", - suffix = {"id": "kyosei-ja", "title":"OU Kyosei Studies (日本語)", "language": "Japanese"}, - doclinks = [ - "http://kyosei.hus.osaka-u.ac.jp/wp-content/uploads/2021/07/3505fd795307005aa71cd3a930f2557a.pdf" - ] -).create() - -Kyoseien( - input = 'scripts/source/chicago-author-date.csl', - journal = "Journal of Kyosei Studies", - suffix = {"id": "kyosei-en", "title":"OU Kyosei Studies (English)", "language": "English"}, - doclinks = [ - "http://kyosei.hus.osaka-u.ac.jp/wp-content/uploads/2021/07/3505fd795307005aa71cd3a930f2557a.pdf" - ] -).create() - -Kyoso( - input = 'scripts/source/chicago-author-date.csl', - journal = "Journal - Mirai Kyoso", - suffix = {"id": "kyoso-ja", "title":"KYOSO (日本語)", "language": "Japanese"}, - doclinks = [ - "http://www.hus.osaka-u.ac.jp/mirai-kyoso/ja/journal/mirai-kyoso-journaltoko_11.pdf" - ] -).create() - -ICZemi( - input = 'scripts/source/chicago-author-date.csl', - journal = "Osaka University - International Collaboration and Development Studies", - suffix = {"id": "iczemi-ja", "title":"IC Zemi (日本語)", "language": "Japanese"}, - doclinks = [ - "https://drive.google.com/file/d/1ZsYZXG98x1zHz4VdmBgeqyGlYDkyU8nD" - ] -).create() \ No newline at end of file diff --git a/scripts/__init__.py b/scripts/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/scripts/aerj.py b/scripts/aerj.py deleted file mode 100644 index cde7f1d..0000000 --- a/scripts/aerj.py +++ /dev/null @@ -1,10 +0,0 @@ -from .chicago import Chicago - -class Aerj(Chicago): - def __init__(self, input, journal, suffix, doclinks): - super().__init__(input, journal, suffix, doclinks) - - def custom(self): - suffix = {"if": {"tag":"text", "attrib": {"value":"頁"}}, "else": {}} - prefix = {"if": {}, "else": {"tag":"label", "attrib": {"variable": "locator", "form": "short", "suffix":" "}}} - self.shortpagelabel(prefix=prefix, suffix=suffix) \ No newline at end of file diff --git a/scripts/chicago.py b/scripts/chicago.py deleted file mode 100644 index 5233b46..0000000 --- a/scripts/chicago.py +++ /dev/null @@ -1,730 +0,0 @@ -import os, copy, datetime, pytz -from lxml import etree as ET -from lxml.etree import SubElement, QName - -class Chicago: - def __init__(self, input, journal, suffix, doclinks, config={}): - self.conds = {} - self.config = config - self.ns = {"z": "http://purl.org/net/xbiblio/csl"} - self.input = input - self.journal = journal - self.suffix = suffix - self.doclinks = doclinks - parser = ET.XMLParser(remove_blank_text=True) - self.tree = ET.parse(self.input, parser) - self.root = self.tree.getroot() - self.info = self.tree.findall('z:info', self.ns)[0] - self.macros = self.getmacros() - self.locales = self.getlocales() - self.citation = self.tree.findall('z:citation', self.ns)[0] - self.bibliography = self.tree.findall('z:bibliography', self.ns)[0] - self.setdoclinks() - - def custom(self): - pass - - def setdoclinks(self): - for l in self.doclinks: - self.render({"tag": "link", "attrib": {"href":l, "rel": "documentation"}}, self.info, previous=self.child(self.info, "z:link[2]")) - - def create(self): - self.create_() - self.custom() - self.save() - - def create_(self): - self.setroot() - self.doctitle() - self.id() - self.contributor() - self.summary() - self.locale() - self.setbiblio() - self.setcitation() - self.updated() - - # macros - self.setissue() - self.setdate() - self.access() - self.setcontainertitle() - self.locatorsarticle() - self.locatorschapter() - self.locators() - self.containercontributors() - self.contributors() - self.contributorsshort() - self.publisher() - self.title() - self.secondarycontributors() - self.translator() - self.edition() - self.shortpageprefix() - self.dateintext() - - def updated(self): - up = self.child(self.info, "z:updated") - up.text = datetime.datetime.now().astimezone().replace(microsecond=0).isoformat() - - def setcitation(self): - self.setattr(self.citation, ".", { - "et-al-min":"3", - "disambiguate-add-year-suffix":"false", - "disambiguate-add-names":"false", - "disambiguate-add-givenname":"false", - }) - - """ - Add comma after name - """ - - self.setattr(self.citation, "z:layout/z:group/z:choose/z:if/z:group/z:text[@macro='contributors-short']", {"suffix":self.config.get("short-author-suffix", ", ")}) - self.setattr(self.citation, "z:layout", {"prefix": "(", "suffix": ")"}) - - """ - Add condition - """ - c = self.addcondition(self.citation, "z:layout/z:group/z:choose/z:if/z:group") - self.setattr(c["if"], "z:group", {"delimiter": ""}) - self.setattr(c["else"], "z:group", {"delimiter": " "}) - - - - def setbiblio(self): - self.move(self.bibliography, "z:layout/z:text[@macro='issue']", "z:layout/z:text[@macro='edition']") - self.move(self.bibliography, "z:layout/z:text[@macro='container-title']", "z:layout/z:text[@macro='container-contributors']") - self.setattr(self.bibliography, "z:layout/z:text[@macro='container-title']", {"prefix":""}) - self.setattr(self.bibliography, "z:layout/z:group", {"delimiter":""}) - - self.delattr(self.bibliography, ".", "subsequent-author-substitute") - - parent = self.bibliography.xpath("z:sort", namespaces=self.ns)[0] - after = self.bibliography.xpath("z:sort/z:key[@macro='contributors']", namespaces=self.ns)[0] - self.render({"tag":"key", "attrib":{"variable": "name-kana"}}, parent, after=after) - - def summary(self): - for summary in self.tree.findall('z:info/z:summary', self.ns): - summary.text = summary.text+" - Edited for "+self.journal+" ("+self.suffix["language"]+")" - - def doctitle(self): - for title in self.tree.findall('z:info/z:title', self.ns): - title.text = self.journal+" ("+self.suffix["language"]+")" - - def id(self): - for id in self.tree.findall('z:info/z:id', self.ns): - id.text = id.text+"-"+self.suffix["id"] - - def contributor(self): - last_contributor = self.info.findall("z:contributor", self.ns)[-1] - moi = { - "tag": "contributor", "children": [ - {"tag": "name", "text": "Fanantenana Rianasoa Andriariniaina"}, - {"tag": "uri", "text": "https://orcid.org/0000-0002-8665-0922"}, - ] - } - self.render(moi, self.info, last_contributor) - - def q(self, v): - return QName("http://www.w3.org/XML/1998/namespace", v) - - def locale(self): - en = self.locales["en"] - self.delelement(en, ".") - - locale = { - "tag":"locale", - "attrib": {self.q("lang"): "en"}, - "children": [ - { - "tag": "terms", - "children": - [ - {"tag": "term", "attrib": {"name": "editortranslator", "form":"verb"}, "text": "編訳"}, - {"tag": "term", "attrib": {"name": "editortranslator", "form":"verb-short"}, "text": "Edited and translated by"}, - {"tag": "term", "attrib": {"name": "translator", "form":"verb"}, "text": "訳"}, - {"tag": "term", "attrib": {"name": "translator", "form":"verb-short"}, "text": "Translated by"}, - {"tag": "term", "attrib": {"name": "and others"}, "text": "ほか"}, - {"tag": "term", "attrib": {"name": "editor", "form":"short"}, "children": [ - {"tag": "single", "text": "ed."}, - {"tag": "multiple", "text": "eds."}, - ]} - ]} - ]} - self.render(locale, self.root, self.info) - - def dateintext(self): - dit = self.macros.get("date-in-text", None) - self.setattr(dit, "z:choose/z:if/z:group", {"delimiter": None}) - self.setattr(dit, "z:choose/z:if/z:group/z:date[@variable='original-date']", {"prefix": None, "suffix": "="}) - - def setroot(self): - self.root.attrib["default-locale"] = "en-US" - self.root.attrib["page-range-format"] = "expanded" - self.root.attrib["katakana-display"] = "normal-order" - - def setissue(self): - issue = self.macros.get("issue", None) - c = self.addcondition(issue, "z:choose/z:else/z:group") - self.setattr(c["if"], "z:group", {"prefix": "", "delimiter": ""}) - self.setattr(c["else"], "z:group", {"prefix": ". ", "delimiter": ", "}) - - def setdate(self): - date = self.macros.get("date", None) - c = self.addcondition(date, "z:choose/z:if[@variable='issued']/z:group") - self.conds["date"] = c - - # if Japanese - self.setattr(c["if"], "z:group", {"delimiter": ""}) - self.setattr(c["if"], "z:group/z:date[@variable='original-date']", {"prefix": "(", "suffix": ")"}) - self.setattr(c["if"], "z:group/z:date[@variable='issued']", {"prefix": "(", "suffix": ")"}) - - # if not Japanese - self.setattr(c["else"], "z:group", {"delimiter": ""}) - self.setattr(c["else"], "z:group/z:date[@variable='original-date']", {"prefix": " (", "suffix": ")."}) - self.setattr(c["else"], "z:group/z:date[@variable='issued']", {"prefix": " (", "suffix": "). "}) - - def title(self): - t = self.macros.get("title", None) - c1 = self.child(t, "z:choose/z:else-if[@type='bill book graphic legislation motion_picture song']") - - text = self.addcondition(c1, "z:text") - self.conds["title-1"] = text - - group = self.addcondition(c1, "z:group") - self.conds["title-2"] = group - - self.setattr(text["if"], "z:text", {"text-case": None, "prefix": "『", "suffix": "』"}) - - self.setattr(group["if"], "z:group", { - "prefix": "(", "suffix": ")" - }) - - c2 = self.child(t, "z:choose/z:else") - t = self.addcondition(c2, "z:text") - self.conds["title-3"] = t - - self.setattr(t["if"], "z:text", {"quotes":"false", "prefix": "「", "suffix": "」"}) - self.setattr(t["else"], "z:text", {"quotes":"false"}) - self.conds["title"] = t - - def edition(self): - e = self.macros.get("edition", None) - c = self.addcondition(e, "z:choose/z:else-if/z:choose/z:else/z:text") - self.setattr(c["if"], "z:text", {"prefix": "(", "suffix": ")"} ) - self.setattr(c["else"], "z:text", {"prefix": " (", "suffix": ") "} ) - self.conds["edition"] = c - - def translator(self): - return - t = self.macros.get("translator", None) - c = self.addcondition(t, "z:names") - self.render({"tag": "text", "attrib": {"term": "translated by "}}, c["else"]) - - - def secondarycontributors(self): - p = self.macros.get("secondary-contributors", None) - c = self.addcondition(p, "z:choose/z:if/z:group") - self.setattr(c["if"], "z:group", {"delimiter": "・", "suffix": None}) - self.setattr(c["if"], "z:group/z:names[@variable='editor translator']", {"delimiter": None, "suffix": "、"}) - self.setattr(c["if"], "z:group/z:names[@variable='director']", {"delimiter": None, "suffix": None}) - self.move(c["if"], "z:group/z:names[@variable='editor translator']/z:label", "z:group/z:names[@variable='editor translator']/z:name" ) - - # else - self.setattr(c["else"], "z:group/z:names[@variable='editor translator']", {"delimiter": ", ", "prefix":". "}) - self.setattr(c["else"], "z:group/z:names[@variable='editor translator']/z:label", {"form": "verb-short"}) - - self.conds["secondary-contributors"] = c - - self.setattr(self.bibliography, "z:layout/z:text[@macro='secondary-contributors']", {"prefix": None}) - - def publisher(self): - p = self.macros.get("publisher", None) - c = self.addcondition(p, "z:group") - self.conds["publisher"] = c - - def contributorsshort(self): - cs = self.macros.get("contributors-short", None) - c = self.addcondition(cs, "z:names") - self.conds["contributors-short"] = c - - self.setattr(c["if"], "z:names/z:name", {"form":"short", "delimiter":"・", "and": None, "initialize-with": None}) - - self.setattr(c["else"], "z:names/z:name", {"and":"symbol"}) - - names = c["if"].xpath("z:names/z:name", namespaces=self.ns) - if len(names)<=0: - return - else: - name = names[0] - - self.render({"tag": "et-al", "attrib":{"term": "and others"}}, name.getparent(), name) - - def contributors(self): - c = self.macros.get("contributors", None) - v = self.addcondition(c, "z:group/z:names[@variable='author']") - - self.setattr(v["if"], "z:names/z:name", { - "name-as-sort-order":"all", "delimiter":"・", "delimiter-precedes-last":"never", "and": None, "sort-separator":None - }) - - editors = v["if"].xpath("z:names/z:substitute/z:names[@variable='editor']", namespaces=self.ns) - if len(editors)>0: - editor = editors[0] - self.setattr(editor, ".", {"suffix":"編"}) - self.render({"tag": "name", "attrib": { "name-as-sort-order":"all", "delimiter":"・", "delimiter-precedes-last":"never"}}, editor, where=0) - - self.setattr(v["else"], "z:names/z:name", {"and": "symbol", "name-as-sort-order": "all", "delimiter-precedes-last": "never", "initialize-with": ". "}) - - self.delelement(v["if"], "z:names/z:label") - - c = v["if"].getparent().getparent().getparent() - self.move(c, "z:group/z:text", "z:group/choose") - - self.conds["contributors"] = v - - def containercontributors(self): - cc = self.macros.get("container-contributors", None) - c = self.addcondition(cc, "z:choose/z:if[@type='chapter entry-dictionary entry-encyclopedia paper-conference']/z:group") - - self.setattr(c["if"], "z:group", {"prefix":"", "delimiter":""}) - self.setattr(c["if"], "z:group/z:names[@variable='container-author']", {"delimiter":"・"}) - self.setattr(c["if"], "z:group/z:names[@variable='container-author']/z:name", {"and":None, "delimiter":"・"}) - - self.setattr(c["if"], "z:group/z:names[@variable='editor translator']", {"delimiter":"・", "suffix": "編"}) - self.setattr(c["if"], "z:group/z:names[@variable='editor translator']/z:name", {"and":None, "delimiter": "・", "sort-separator":", ", "delimiter-precedes-last":"never"}) - self.delelement(c["if"], "z:group/z:names[@variable='editor translator']/z:label") - - self.setattr(c["else"], "z:group", {"prefix":" "}) - self.move(c["else"], "z:group/z:names[@variable='editor translator']/z:label", "z:group/z:names[@variable='editor translator']/z:name") - - self.setattr(c["else"], "z:group/z:names[@variable='editor translator']/z:name", { - "and":"symbol", "delimiter":", ", "sort-separator":", ", "delimiter-precedes-last": "never", "initialize-with":". "}) - - self.setattr(c["else"], "z:group/z:names[@variable='editor translator']/z:label", { - "form": "short", "prefix": None, "suffix": None}) - - self.setattr(c["else"], "z:group/z:names[@variable='editor translator']/z:label", { - "form": "short", "prefix": " (", "suffix":"). "}) - - self.render({"tag": "text", "attrib":{"value": "In", "suffix":" ", "prefix": ". "}}, c["else"], where=0) - self.conds["container-contributors"] = c - - def getchild(self, parent, xpath): - return parent.xpath(xpath, namespaces=self.ns)[0] - - def locators(self): - l = self.macros.get("locators", None) - group = self.render({"tag":"group"}, l, path="z:choose/z:if[@type='article-journal']") - group.insert(0, self.child(l, "z:choose/z:if[@type='article-journal']/z:choose")) - - aj = self.addcondition(l, "z:choose/z:if[@type='article-journal']/group") - self.conds["locators"] = aj - - self.setattr(aj["if"], "group/z:choose/z:if[@variable='volume']/z:text", {"prefix": None, "suffix": "巻"}) - - self.delelement(aj["if"], "group/z:choose/z:if[@variable='volume']/z:group") - - # change issue tag from else-if to if - self.child(aj["if"], "group/z:choose/z:else-if[@variable='issue']").tag = "if" - - issue = self.child(aj["if"], "group/z:choose/if[@variable='issue']") - issued = self.child(aj["if"], "group/z:choose/z:else") - - self.setattr(issue, "z:group/z:text[@variable='issue']", {"suffix":"号"}) - - self.move(issue, "z:group/z:text[@variable='issue']", "z:group") - - self.delelement(issue, "z:group") - - # add new choose - newchoose = self.render({"tag": "choose"}, aj["if"]) - newchoose.insert(0, issue) - newchoose.insert(1, issued) - - # add to group - self.child(newchoose.getparent(), "group").insert(1, newchoose) - - other = self.child(aj["if"], "z:choose/z:else") - self.setattr(other, "z:date", {"prefix":None}) - - self.setattr(aj["else"], "z:choose/z:if[@variable='volume']/z:group", {"prefix": "(", "suffix":")"}) - - # bill book graphic legal_case legislation motion_picture report song - c = self.addcondition(l, "z:choose/z:else-if[@type='bill book graphic legal_case legislation motion_picture report song']/z:group") - self.setattr(c["if"], "z:group", {"prefix":"", "delimiter":""}) - - self.delelement(c["if"], "z:group/z:group/z:text[@term='volume']") - self.setattr(c["if"], "z:group/z:group/z:number", {"prefix":"(", "suffix":")"}) - - number = self.child(c["if"], "z:group/z:group/z:number[@variable='number-of-volumes']") - self.conds["locator-bill-etc"] = c - if number is None: - return - group = number.getparent() - - - self.render({"tag": "text", "attrib": {"term": "volume", "form": "short", "prefix": " ", "plural": "true"}}, group) - - def locatorschapter(self): - lc = self.macros.get("locators-chapter", None) - c = self.addcondition(lc, "z:choose/z:if/z:choose/z:if/z:group") - self.setattr(c["if"], "z:group", {"prefix": "、", "suffix": "頁"}) - self.setattr(c["else"], "z:group", {"prefix": ", pp. "}) - self.conds["locators-chapter"] = c - - def locatorsarticle(self): - la = self.macros.get("locators-article", None) - c = self.addcondition(la, "z:choose/z:else-if[@type='article-journal']/z:choose/z:if/z:text") - self.setattr(c["if"], "z:text", {"prefix": "、", "suffix": "頁"}) - self.setattr(c["else"], "z:text", {"prefix": ", ", "suffix": ""}) - d = self.addcondition(la, "z:choose/z:else-if[@type='article-journal']/z:choose/z:else/z:text") - self.conds["locators-article"] = c - - def access(self): - a = self.macros.get("access", None) - self.setattr(a, "z:group", {"delimiter": " "}) - c = self.addcondition(a, "z:group/z:choose[4]") - self.setattr(c["else"], "z:choose/z:if/z:choose/z:else/z:text", {"suffix": " "}) - self.render({"tag": "date", "attrib": {"variable": "accessed", "prefix": " (", "suffix": ")", "form":"text"}}, c["else"], path="z:choose/z:if/z:choose/z:else") - - # Japanese - self.setattr(c["if"], "z:choose/z:if/z:choose/z:else/z:text", {"suffix": " "}) - self.render( - { - "tag": "date", "attrib": {"variable": "accessed", "prefix": "(", "suffix": ")"}, - "children": [ - {"tag": "date-part", "attrib": {"form":"long", "name":"year", "suffix": "年"}}, - {"tag": "date-part", "attrib": {"form":"numeric", "name":"month", "suffix": "月"}}, - {"tag": "date-part", "attrib": {"form":"numeric", "name":"day", "suffix": "日"}} - ] - }, - c["if"], path="z:choose/z:if/z:choose/z:else") - #remove date - self.delelement(a, "z:group/z:choose[2]") - self.conds["access"] = c - - def setcontainertitle(self): - # Remove container-prefix "in" - ct = self.macros.get("container-title", None) - self.delelement(ct, "z:choose/z:if[@type='chapter entry-dictionary entry-encyclopedia paper-conference' and @match='any']", delparent=True) - - # Add condition - c = self.addcondition(ct, "z:choose/z:else-if[@type='legal_case' and @match='none']/z:group") - - # for japanese - jaja = c["if"].xpath("z:group/z:text", namespaces=self.ns) - if len(jaja)<=0: - return - else: - jaja = jaja[0] - self.setattr(jaja, ".", {"font-style": None, "prefix":"『", "suffix": "』"}) - - group = jaja.getparent() - choose = self.render({"tag": "choose"}, group) - ifel = self.render({"tag": "if", "attrib":{"type":"article-journal"}}, choose) - elseel = self.render({"tag": "else"}, choose) - ifel.insert(0, jaja) - elseel.insert(0, copy.deepcopy(jaja)) - - # other than japanese - jaelse = c["else"].xpath("z:group/z:text", namespaces=self.ns)[0] - self.setattr(jaelse, ".", {"prefix":". ", "suffix": ", "}) - - group = jaelse.getparent() - choose = self.render({"tag": "choose"}, group) - ifel = self.render({"tag": "if", "attrib":{"type":"article-journal"}}, choose) - elseel = self.render({"tag": "else"}, choose) - ifel.insert(0, jaelse) - - # other than journal journal - jaelseelse = copy.deepcopy(jaelse) - self.setattr(jaelseelse, ".", {"prefix":None, "suffix": None}) - elseel.insert(0, jaelseelse) - self.conds["container-title"] = c - - # Suffix - self.setattr(c["else"], "z:group/z:choose[position()=2]/z:if/z:text", {"suffix": "*"}) - - # for webpage - cwp = self.addcondition(ct, "z:choose/z:if[@type='webpage']/z:text") - self.setattr(cwp["if"], "z:text", {"suffix": "、", "prefix": "、"}) - self.setattr(cwp["else"], "z:text", {"prefix": " "}) - self.conds["container-title-webpage"] = cwp - - def originallocators(self): - aj = self.conds["locators"] - t = aj["if"].getparent().getparent() - self.delelement(t, "choose") - self.render({"tag": "group", "children":[{"tag": "choose", "children": [ - {"tag": "if", "attrib":{"variable": "volume issue", "match": "all"}, "children": [{"tag":"text", "attrib":{"variable": "volume"}}, {"tag":"text", "attrib":{"variable": "issue", "prefix": "(", "suffix": ")"}}]}, - {"tag": "else-if", "attrib":{"variable": "volume"}, "children": [{"tag":"text", "attrib":{"variable": "volume"}}]}, - {"tag": "else-if", "attrib":{"variable": "issue"}, "children": [{"tag":"text", "attrib":{"variable": "issue"}}]}, - {"tag": "else", "children": [{"tag":"date", "attrib":{"variable": "issued", "prefix": "(", "suffix": ")"}, "children":[{"tag": "date-part", "attrib":{"name": "month"}}]}]}, - - ]}]}, t) - - def getmacros(self): - m = self.tree.findall('z:macro', self.ns) - m = {x.attrib["name"]:x for x in m} - return m - - def getlocales(self): - m = self.tree.findall('z:locale', self.ns) - m = {x.attrib[self.q("lang")]:x for x in m} - return m - - def addcondition(self, target, xpath, elifs={}): - """ - If the entry contains a field name-kana - """ - - element = target.xpath(xpath, namespaces=self.ns) - - if len(element)<=0: - print("Not found") - print(target) - print(xpath) - return { - "if": SubElement(self.root, "condition-error"), - "else": SubElement(self.root, "condition-error") - } - else: - element = element[0] - - elementcopy = copy.deepcopy(element) - parent = element.getparent() - choose = self.render({"tag": "choose"}, parent) - r = {} - - x = 0 - for t in elifs: - c = elifs[t] - if x==0: - elifel = self.render({"tag": "if", "attrib":{"variable": c}}, choose) - else: - elifel = self.render({"tag": "else-if", "attrib":{"variable": c}}, choose) - elifel.insert(0, copy.deepcopy(element)) - r[t]= elifel - x+=1 - - # else if but kept as "if" for consistency - if len(elifs)==0: - ifel = self.render({"tag": "if", "attrib":{"variable": "name-kana"}}, choose) - else: - ifel = self.render({"tag": "else-if", "attrib":{"variable": "name-kana"}}, choose) - ifel.insert(0, elementcopy) - r["if"] = ifel - - elseel = self.render({"tag": "else"}, choose) - elseel.insert(0, element) - r["else"] = elseel - return r - - def splitlocales(self, target, xpath, locales): - element = target.xpath(xpath, namespaces=self.ns) - - if len(element)<=0: - print("Not found") - print(target) - print(xpath) - return { - "if": SubElement(self.root, "condition-error"), - "else": SubElement(self.root, "condition-error") - } - else: - element = element[0] - - r = {"default": element} - - for l in locales: - elementcopy = copy.deepcopy(element) - self.setattr(elementcopy, ".", {"locale": l}) - parent = element.getparent() - parent.insert(0, elementcopy) - r[l] = elementcopy - return r - - def render(self, d, parent, previous=None, after=None, where=None, path=None): - if path is not None: - parent = self.child(parent, path) - - tag = d.get("tag", None) - attrib = d.get("attrib", {}) - text = d.get("text", None) - children = d.get("children", []) - element = None - - if where is not None: - index = where - elif after is not None: - index = parent.getchildren().index(after) - elif previous is not None: - index = previous.getparent().getchildren().index(previous)+1 - else: - try: - previous = parent.getchildren()[len(parent.getchildren())-1] - index = parent.getchildren().index(previous)+1 - except: - index = 0 - - if tag is not None: - element = SubElement(parent, tag) - parent.insert(index, element) - - if text is not None: - setattr(element, "text", text) - - for key in attrib: - value = attrib[key] - element.attrib[key] = value - - for child in children: - self.render(child, element) - return element - - def unwrap(self, element, clean=True): - parent = element.getparent() - children = element.getchildren() - index = element.getparent().getchildren().index(element) - for c in children: - parent.insert(index, c) - index+=1 - if clean: - parent.remove(element) - - def wrap(self, element, w="group", attrib={}): - children = element.getchildren() - # group = self.render({"tag": w}, element) - group = SubElement(self.root, w) - for c in children: - group.insert(-1, c) - element.insert(0, group) - for a in attrib: - group.attrib[a] = attrib[a] - - def revertconditions(self, keeptag="else"): - ifs = self.tree.xpath("//if[@variable='name-kana']") - for i in ifs: - parent = i.getparent() - keep = None - for c in parent: - if c.tag==keeptag: - keep = c - else: - parent.remove(c) - self.unwrap(parent, clean=True) - if keep is not None: - self.unwrap(keep, clean=True) - - # Remove sort key - keys = self.tree.xpath("//key[@variable='name-kana']") - for k in keys: - k.getparent().remove(k) - - def shortpagelabel(self, prefix=None, suffix=None): - pl = self.macros.get("point-locators", None) - c = self.addcondition(pl, "z:choose/z:if/z:text") - - if prefix is not None: - pref = self.render(prefix["if"], c["if"], where=-2) - pref = self.render(prefix["else"], c["else"], where=-2) - if suffix is not None: - pref = self.render(suffix["if"], c["if"], where=-1) - pref = self.render(suffix["else"], c["else"], where=-1) - - def shortpageprefix(self, prefix=", ", label=""): - self.setattr(self.citation, "z:layout/z:group", {"delimiter": prefix}) - - def changetag(self, parent, elementxpath, newtag): - elements = parent.xpath(elementxpath, namespaces=self.ns) - if len(elements)>0: - elements[0].tag = newtag - else: - print("No element for "+elementxpath) - - def move(self, parent, elementxpath, previousxpath): - if parent is None: - return - element = parent.xpath(elementxpath, namespaces=self.ns) - previous = parent.xpath(previousxpath, namespaces=self.ns) - - if len(element)==0: - print("Element does not exist: "+elementxpath+" in ") - print(parent) - print(parent.getchildren()) - print([x.getchildren() for x in parent.getchildren()]) - - elif len(previous)==0: - print("Element does not exist: "+previousxpath+" in ") - print(parent) - print(parent.getchildren()) - print([x.getchildren() for x in parent.getchildren()]) - - else: - element = element[0] - previous = previous[0] - index = previous.getparent().getchildren().index(previous)+1 - previous.getparent().insert(index, element) - - - def setattrs(self, parent, values): - for key in values: - v = values[key] - parent.attrib[key] = v - return parent - - def setattr(self, parent, element, attr): - if parent is None: - return - - elt = parent.xpath(element, namespaces=self.ns) - if len(elt)<=0: - return - else: - elt = elt[0] - for key in attr: - value = attr[key] - if value is None: - self.delattr(parent, element, key) - else: - elt.attrib[key] = value - - def delelement(self, parent, xpath, delparent=False): - if parent is None: - return - elements = parent.xpath(xpath, namespaces=self.ns) - if len(elements)>0: - p = elements[0].getparent() - [x.getparent().remove(x) for x in elements] - if delparent: - p.getparent().remove(p) - else: - print("Not found!") - print(parent) - print(xpath) - - def child(self, parent, path): - c = parent.xpath(path, namespaces=self.ns) - if len(c)>0: - return c[0] - else: - return None - - def delattr(self, parent, element, attr): - element = parent.xpath(element, namespaces=self.ns)[0] - if type(attr)==type([]): - for a in attr: - if a in element.attrib: - element.attrib.pop(a) - else: - if attr in element.attrib: - element.attrib.pop(attr) - - def save(self): - os.makedirs(self.journal, exist_ok=True) - outfile = self.journal+"/"+os.path.splitext(os.path.basename(self.input))[0]+"-"+self.suffix["id"]+".csl" - buildoutfile = "build"+"/"+os.path.splitext(os.path.basename(self.input))[0]+"-"+self.suffix["id"]+".csl" - self.tree.write(outfile, pretty_print=True, xml_declaration=True, encoding="UTF-8") - self.tree.write(buildoutfile, pretty_print=True, xml_declaration=True, encoding="UTF-8") - \ No newline at end of file diff --git a/scripts/iczemi.py b/scripts/iczemi.py deleted file mode 100644 index 143ce4c..0000000 --- a/scripts/iczemi.py +++ /dev/null @@ -1,208 +0,0 @@ -from .chicago import Chicago - -class ICZemi(Chicago): - def __init__(self, input, journal, suffix, doclinks): - super().__init__(input, journal, suffix, doclinks) - - def setcitation(self): - self.setattr(self.citation, ".", { - "et-al-min":"3", - "disambiguate-add-year-suffix":"false", - "disambiguate-add-names":"false", - "disambiguate-add-givenname":"false", - "after-collapse-delimiter":"; ", #ICZemi - }) - - """ - Add comma after name - """ - self.setattr(self.citation, "z:layout/z:group/z:choose/z:if/z:group/z:text[@macro='contributors-short']", {"suffix":""}) - - #ICZemi delimiter ":" for page number - # in self.shortpageprefix - - #ICZemi - self.setattr(self.citation, "z:layout", {"prefix": "(", "suffix": ")", "delimiter": ", "}) - - c = self.addcondition(self.citation, "z:layout/z:group/z:choose/z:if/z:group") - self.setattr(c["if"], "z:group", {"delimiter": ""}) - self.setattr(c["else"], "z:group", {"delimiter": " "}) - - def contributors(self): - c = self.macros.get("contributors", None) - v = self.addcondition(c, "z:group/z:names[@variable='author']", {"elif": "name-katakana"}) - - #Katakana authors /waiting for csl to support this in asian script/ - self.setattr(v["elif"], "z:names/z:name", { - "name-delimiter": "、", "sort-separator":"、","name-as-sort-order":"first", "delimiter":"、", "and": None, "delimiter-precedes-last": "never", "initialize":"false" - }) - - editors = v["elif"].xpath("z:names/z:substitute/z:names[@variable='editor']", namespaces=self.ns) - if len(editors)>0: - editor = editors[0] - self.setattr(editor, ".", {"suffix":"編"}) - self.render({"tag": "name", "attrib": { "name-as-sort-order":"all", "delimiter":"、", "delimiter-precedes-last":"never"}}, editor, where=0) - - #Regular japanese - self.setattr(v["if"], "z:names/z:name", { - "name-as-sort-order":"all", "delimiter":"、", "delimiter-precedes-last":"never", "and": None, "sort-separator":None - }) - - editors = v["if"].xpath("z:names/z:substitute/z:names[@variable='editor']", namespaces=self.ns) - if len(editors)>0: - editor = editors[0] - self.setattr(editor, ".", {"suffix":"編"}) - self.render({"tag": "name", "attrib": { "name-as-sort-order":"all", "delimiter":"・", "delimiter-precedes-last":"never"}}, editor, where=0) - - #ICZemi "name-as-sort-order": "first" - self.setattr(v["else"], "z:names/z:name", {"and": "symbol", "name-as-sort-order": "first", "delimiter-precedes-last": "never", "initialize-with": ". "}) - - self.delelement(v["if"], "z:names/z:label") - - c = v["if"].getparent().getparent().getparent() - self.move(c, "z:group/z:text", "z:group/choose") - - self.conds["contributors"] = v - - - def access(self): - a = self.macros.get("access", None) - self.setattr(a, "z:group", {"delimiter": " "}) - c = self.addcondition(a, "z:group/z:choose[4]") - self.setattr(c["else"], "z:choose/z:if/z:choose/z:else/z:text", {"suffix": " "}) - self.render({"tag": "date", "attrib": {"variable": "accessed", "prefix": " (", "suffix": ")", "form":"text"}}, c["else"], path="z:choose/z:if/z:choose/z:else") - - # Japanese - self.setattr(c["if"], "z:choose/z:if/z:choose/z:else/z:text", {"suffix": " "}) - self.render( - { - "tag": "date", "attrib": {"variable": "accessed", "prefix": "(", "suffix": "閲覧)"}, - "children": [ - {"tag": "date-part", "attrib": {"form":"numeric", "name":"year", "suffix": "年"}}, - {"tag": "date-part", "attrib": {"form":"numeric", "name":"month", "suffix": "月"}}, - {"tag": "date-part", "attrib": {"form":"numeric", "name":"day", "suffix": "日"}} - ] - }, - c["if"], path="z:choose/z:if/z:choose/z:else") - - # English - #remove date - self.delelement(a, "z:group/z:choose[2]") - - - self.render( - { - "tag": "date", "attrib": {"variable": "accessed", "prefix": "(", "suffix": "閲覧)"}, - "children": [ - {"tag": "date-part", "attrib": {"form":"numeric", "name":"year", "suffix": "年"}}, - {"tag": "date-part", "attrib": {"form":"numeric", "name":"month", "suffix": "月"}}, - {"tag": "date-part", "attrib": {"form":"numeric", "name":"day", "suffix": "日"}} - ] - }, - c["else"], path="z:choose/z:if/z:choose/z:else") - self.setattr(c["else"], "z:choose/z:if/z:choose/z:if/z:text", {"prefix": ", https://doi.org/", "suffix": None}) - self.conds["access"] = c - - def custom(self): - # remove comma after name (setcitation) - self.setattr(self.citation, "z:layout/z:group/z:choose/z:if/z:group/z:text[@macro='contributors-short']", {"suffix":""}) - - # prefix = {"if": {"tag":"label", "attrib": {"variable": "locator", "form": "short", "suffix":" ", "prefix":":"}}, "else": {"tag":"label", "attrib": {"variable": "locator", "form": "short", "suffix":" ", "prefix":":"}}} - - # self.shortpagelabel(prefix=prefix) - - # No pp to page - c = self.conds["locators-article"] - self.setattr(c["else"], "z:text", {"prefix": ":", "suffix": ""}) - self.setattr(c["if"], "z:text", {"prefix": ":", "suffix": ""}) - - # ----//--- book chapter - c = self.conds["locators-chapter"] - self.setattr(c["if"], "z:group", {"prefix": "、pp. ", "suffix": ""}) - - # Issue number - aj = self.conds["locators"] - self.setattr(aj["else"], "group/z:choose/z:if[@variable='volume']/z:group/z:choose/z:if[@variable='issue']/z:text", {"prefix": ", No. ", "suffix": None}) - self.setattr(aj["else"], "group/z:choose/z:if[@variable='volume']/z:group/z:choose/z:else/z:date", {"prefix": ", (", "suffix": ")"}) - - # Issue number [ja] - self.setattr(aj["if"], "group/z:choose/z:if[@variable='volume']/z:text", {"prefix": None, "suffix": None}) - self.setattr(aj["if"], "group/choose/if/z:text", {"prefix": "(", "suffix": ")"}) - self.setattr(aj["if"], "group", {"delimiter": None}) - - - # Japanese dot at the end [ja & en]  in bibliography - #remove general suffix - self.setattr(self.bibliography, "z:layout", {"suffix": None}) - text = self.render({"tag": "text"}, self.bibliography, path="z:layout") - c = self.addcondition(text, ".") - self.setattr(c["if"], "text", {"value": "."}) - self.setattr(c["else"], "text", {"value": "."}) - - # remove dot prefix in access - self.setattr(self.bibliography, "z:layout/z:text[@macro='access']", {"prefix": None}) - - # add space in front of URL - # c = self.conds["access"] - # self.setattr(c["else"], "z:choose/z:if/z:choose/z:if/z:text", {"prefix":". "}) - # self.setattr(c["else"], "z:choose/z:if/z:choose/z:else/z:text", {"prefix":". "}) - - # Volume - self.setattr(aj["else"], "group/z:choose/z:if[@variable='volume']/z:text[@variable='volume']", {"prefix": None, "suffix": None}) - self.setattr(aj["else"], "group/z:choose/z:if[@variable='volume']/z:group", {"prefix": None, "suffix": None}) - - # Issue - self.setattr(aj["else"], "group/z:choose/z:if[@variable='volume']/z:group/z:choose/z:if/z:text", {"prefix": "(", "suffix": ")"}) - - # Title - t = self.conds["title"] - self.setattr(t["else"], "z:text", {"quotes":"false", "prefix": "“", "suffix":".”"}) - - # Journal name - t = self.conds["container-title"] - self.setattr(t["else"], "z:group/choose/if/z:text", {"prefix":" ", "suffix":", "}) - - # webpage container title [ja] - ctw = self.conds["container-title-webpage"] - self.setattr(ctw["if"], "z:text", {"prefix":"、", "suffix":"。"}) - - # Journal name (no comma in front) [ja] - # t = self.conds["container-title"] - # self.setattr(t["if"], "z:group/choose/if/z:text", {"prefix":"『"}) - - # Date with parentheses - c = self.conds["date"] - self.setattr(c["else"], "z:group", {"prefix": " (", "suffix": ") "}) - self.setattr(c["else"], "z:group/z:date[@variable='original-date']", {"prefix": "", "suffix": "="}) - self.setattr(c["else"], "z:group/z:date[@variable='issued']", {"prefix": "", "suffix": ""}) - - # Date with comma [ja] added original-date - self.setattr(c["if"], "z:group", {"prefix": "(", "suffix": ")"}) - self.setattr(c["if"], "z:group/z:date[@variable='original-date']", {"prefix": "", "suffix": "="}) - self.setattr(c["if"], "z:group/z:date[@variable='issued']", {"prefix": "", "suffix": ""}) - - # Bibliography author - c = self.conds["contributors"] - self.setattr(c["else"], "z:names", {"suffix": " "}) - self.setattr(c["else"], "z:names/z:name", {"initialize": "false", "and": "symbol"}) - self.setattr(c["else"], "z:names/z:label", {"form": None}) - - # remove dot before "In" - c = self.conds["container-contributors"] - self.setattr(c["else"], "text", {"prefix": " "}) - self.setattr(c["else"], "z:group/z:names[@variable='editor translator']/z:name", {"and": "text", "initialize": "false", "name-as-sort-order": "none"}) - - self.setattr(c["else"], "z:group/z:names[@variable='editor translator']/z:label", {"suffix": "), "}) - - # add "In" etc - - - # add 、 in front of contributors [ja] - self.setattr(c["if"], "z:group", {"prefix": "、", "suffix": ""}) - - # no 、 in front of publisher [ja] - c = self.conds["publisher"] - self.setattr(c["if"], "z:group", {"prefix": None}) - - #ICZemi change page prefix - self.shortpageprefix(prefix=":") \ No newline at end of file diff --git a/scripts/jids.py b/scripts/jids.py deleted file mode 100644 index 111b0cb..0000000 --- a/scripts/jids.py +++ /dev/null @@ -1,92 +0,0 @@ -from .chicago import Chicago - -class Jids(Chicago): - def __init__(self, input, journal, suffix, doclinks): - super().__init__(input, journal, suffix, doclinks) - - def custom(self): - # remove comma after name (setcitation) - self.setattr(self.citation, "z:layout/z:group/z:choose/z:if/z:group/z:text[@macro='contributors-short']", {"suffix":""}) - - prefix = {"if": {"tag":"label", "attrib": {"variable": "locator", "form": "short", "suffix":" "}}, "else": {"tag":"label", "attrib": {"variable": "locator", "form": "short", "suffix":" "}}} - - self.shortpagelabel(prefix=prefix) - - # Add pp to page - c = self.conds["locators-article"] - self.setattr(c["else"], "z:text", {"prefix": ", pp. ", "suffix": ""}) - - # Issue number - aj = self.conds["locators"] - self.setattr(aj["else"], "group/z:choose/z:if[@variable='volume']/z:group/z:choose/z:if[@variable='issue']/z:text", {"prefix": ", No. ", "suffix": None}) - self.setattr(aj["else"], "group/z:choose/z:if[@variable='volume']/z:group/z:choose/z:else/z:date", {"prefix": ", (", "suffix": ")"}) - - # Issue number [ja] - self.setattr(aj["if"], "group/z:choose/z:if[@variable='volume']/z:text", {"prefix": "第", "suffix": "巻"}) - self.setattr(aj["if"], "group/choose/if/z:text", {"prefix": "第", "suffix": "号"}) - self.setattr(aj["if"], "group", {"delimiter": "、"}) - - - # Japanese dot at the end [ja & en] - #remove general suffix - self.setattr(self.bibliography, "z:layout", {"suffix": None}) - text = self.render({"tag": "text"}, self.bibliography, path="z:layout") - c = self.addcondition(text, ".") - self.setattr(c["if"], "text", {"value": "。"}) - self.setattr(c["else"], "text", {"value": "."}) - - # remove dot prefix in access - self.setattr(self.bibliography, "z:layout/z:text[@macro='access']", {"prefix": None}) - - # add space in front of URL - c = self.conds["access"] - self.setattr(c["else"], "z:choose/z:if/z:choose/z:if/z:text", {"prefix":". "}) - self.setattr(c["else"], "z:choose/z:if/z:choose/z:else/z:text", {"prefix":". "}) - - # Volume - self.setattr(aj["else"], "group/z:choose/z:if[@variable='volume']/z:text[@variable='volume']", {"prefix": " Vol. ", "suffix": None}) - self.setattr(aj["else"], "group/z:choose/z:if[@variable='volume']/z:group", {"prefix": None, "suffix": None}) - - # Title - t = self.conds["title"] - self.setattr(t["else"], "z:text", {"quotes":"false", "prefix": "“", "suffix":"”"}) - - # Journal name - t = self.conds["container-title"] - self.setattr(t["else"], "z:group/choose/if/z:text", {"prefix":" ", "suffix":". "}) - - # webpage container title [ja] - ctw = self.conds["container-title-webpage"] - self.setattr(ctw["if"], "z:text", {"prefix":"、", "suffix":"。"}) - - # Journal name (Add comma in front) [ja] - t = self.conds["container-title"] - self.setattr(t["if"], "z:group/choose/if/z:text", {"prefix":"、『"}) - - # Date no parentheses - c = self.conds["date"] - self.setattr(c["else"], "z:group/z:date[@variable='original-date']", {"prefix": " ", "suffix": ". "}) - self.setattr(c["else"], "z:group/z:date[@variable='issued']", {"prefix": " ", "suffix": ". "}) - - # Date with comma [ja] - self.setattr(c["if"], "z:group/z:date[@variable='original-date']", {"prefix": "、", "suffix": "、"}) - self.setattr(c["if"], "z:group/z:date[@variable='issued']", {"prefix": "、", "suffix": "、"}) - - # Bibliography author - c = self.conds["contributors"] - self.setattr(c["else"], "z:names", {"suffix": ". "}) - self.setattr(c["else"], "z:names/z:name", {"initialize": "false", "and": "text"}) - self.setattr(c["else"], "z:names/z:label", {"form": None}) - - # remove dot before "In" - c = self.conds["container-contributors"] - self.setattr(c["else"], "text", {"prefix": " "}) - self.setattr(c["else"], "z:group/z:names[@variable='editor translator']/z:name", {"and": "text", "initialize": "false", "name-as-sort-order": "all"}) - - # add 、 in front of contributors [ja] - self.setattr(c["if"], "z:group", {"prefix": "、", "suffix": "、"}) - - # add 、 in front of publisher [ja] - c = self.conds["publisher"] - self.setattr(c["if"], "z:group", {"prefix": "、"}) - \ No newline at end of file diff --git a/scripts/jidsen.py b/scripts/jidsen.py deleted file mode 100644 index 694d1a1..0000000 --- a/scripts/jidsen.py +++ /dev/null @@ -1,29 +0,0 @@ -from .jids import Jids - -class JidsEn(Jids): - def __init__(self, input, journal, suffix, doclinks): - super().__init__(input, journal, suffix, doclinks) - - def setcitation(self): - self.setattr(self.citation, ".", { - "et-al-min":"3", - "disambiguate-add-year-suffix":"false", - "disambiguate-add-names":"false", - "disambiguate-add-givenname":"false", - }) - - """ - Add comma after name - """ - self.setattr(self.citation, "z:layout/z:group/z:choose/z:if/z:group/z:text[@macro='contributors-short']", {"suffix":", "}) - self.setattr(self.citation, "z:layout", {"prefix": "(", "suffix": ")"}) - - def custom(self): - super().custom() - - # Clean bibliography layout - self.delelement(self.bibliography, "z:layout/choose") - self.render({"tag": "text", "attrib": {"value": "."}}, self.bibliography.xpath("z:layout", namespaces=self.ns)[0]) - - # Remove all conditions to leave only English - self.revertconditions(keeptag="else") \ No newline at end of file diff --git a/scripts/kyosei.py b/scripts/kyosei.py deleted file mode 100644 index c169a33..0000000 --- a/scripts/kyosei.py +++ /dev/null @@ -1,167 +0,0 @@ -from .chicago import Chicago -import copy - -class Kyosei(Chicago): - def __init__(self, input, journal, suffix, doclinks): - config = { - "short-author-suffix": " ", - } - super().__init__(input, journal, suffix, doclinks, config) - - def custom(self): - # remove comma after name (setcitation) - self.setattr(self.citation, "z:layout/z:group/z:choose/z:if/z:group/z:text[@macro='contributors-short']", {"suffix":""}) - self.setattr(self.citation, ".", {"et-al-subsequent-min":"3", "et-al-subsequent-use-first":"1", "et-al-min":None, "et-al-use-first": None}) - self.shortpageprefix(":") - - # Issue number - self.originallocators() - - # Japanese dot at the end [ja & en] - #remove general suffix - self.setattr(self.bibliography, "z:layout", {"suffix": None}) - text = self.render({"tag": "text"}, self.bibliography, path="z:layout") - c = self.addcondition(text, ".") - self.setattr(c["if"], "text", {"value": "。"}) - - # Do not add period at the end for webpages - self.changetag(c["else"], "text", "if") - self.setattr(c["else"], "if", {"type": "webpage"}) - self.render({"tag": "else", "children": [{"tag": "text", "attrib":{"value": "."}}]}, c["else"]) - - # remove dot prefix in access - self.setattr(self.bibliography, "z:layout/z:text[@macro='access']", {"prefix": None}) - - # add space in front of URL - - - # Volume - - - # Title - t = self.conds["title"] - self.setattr(t["else"], "z:text", {"quotes":"false", "prefix": None, "suffix": None}) - - # Journal name - t = self.conds["container-title"] - self.setattr(t["if"], "z:group/choose/if/z:text", {"prefix":None, "suffix":None}) - self.setattr(t["else"], "z:group/choose/if/z:text", {"prefix":". ", "suffix":" "}) - - # webpage container title [ja] - ctw = self.conds["container-title-webpage"] - self.setattr(ctw["if"], "z:text", {"prefix":"、", "suffix":"。"}) - self.setattr(ctw["else"], "z:text", {"prefix":". ", "suffix":""}) - - # Journal name (Add comma in front) [ja] - t = self.conds["container-title"] - self.setattr(t["if"], "z:group/choose/if/z:text", {"prefix":"『", "suffix":"』"}) - - # Date no parentheses - c = self.conds["date"] - self.setattr(c["else"], "z:group/z:date[@variable='original-date']", {"prefix": " ", "suffix": ". "}) - self.setattr(c["else"], "z:group/z:date[@variable='issued']", {"prefix": " ", "suffix": ". "}) - - # Date with comma [ja] - self.setattr(c["if"], "z:group/z:date[@variable='original-date']", {"prefix": " ", "suffix": ""}) - self.setattr(c["if"], "z:group/z:date[@variable='issued']", {"prefix": " ", "suffix": ""}) - - # Bibliography author - c = self.conds["contributors"] - self.setattr(c["if"], "z:names/z:name", {"name-as-sort-order": "first", "sort-separator":"、"}) - self.render({"tag": "name-part", "attrib": {"name": "family", "suffix": " "}}, c["if"], path="z:names/z:name") - self.render({"tag": "name-part", "attrib": {"name": "given"}}, c["if"], path="z:names/z:name") - - self.setattr(c["else"], "z:names", {"suffix": ". "}) - self.setattr(c["else"], "z:names/z:name", {"initialize": "false", "and": "text"}) - self.setattr(c["else"], "z:names/z:label", {"prefix": " (", "suffix":")", "form": "short"}) - - # remove dot before "In" - c = self.conds["container-contributors"] - hen = self.child(c["if"], "z:group/z:names[@variable='editor translator']") - yaku = copy.deepcopy(hen) - hen.getparent().insert(-1, yaku) - self.setattrs(yaku, {"variable": "translator", "delimiter": "・", "suffix": "訳、"}) - hen.attrib["variable"] = "editor" - - self.setattr(c["else"], "text", {"prefix": ". "}) - self.setattr(c["else"], "z:group/z:names[@variable='editor translator']/z:name", {"and": "text", "initialize": "false", "name-as-sort-order": None}) - - # add 、 in front of contributors [ja] - # self.setattr(c["if"], "z:group", {"prefix": "、", "suffix": "、"}) - - # remov 、 in front of publisher [ja] - c = self.conds["publisher"] - self.setattr(c["if"], "z:group", {"prefix": None}) - - # remove place if it is Japanese - self.delelement(c["if"], "z:group/z:text[@variable='publisher-place']", delparent=False) - - c = self.conds["secondary-contributors"] - self.setattr(c["if"], "z:group", {"suffix": "、"}) - - #move issue towards the end - self.move(self.bibliography, "z:layout/z:text[@macro='issue']", "z:layout/z:text[@macro='locators-article']") - - #remove delimiter before & - self.setattr(self.conds["contributors-short"]["else"], "z:names/z:name", {"delimiter-precedes-last":"never"}) - - - - def locatorschapter(self): - lc = self.macros.get("locators-chapter", None) - c = self.addcondition(lc, "z:choose/z:if/z:choose/z:if/z:group") - self.setattr(c["if"], "z:group", {"prefix": "pp. ", "suffix": "、"}) - self.setattr(c["else"], "z:group", {"prefix": ", pp. "}) - - def locatorsarticle(self): - la = self.macros.get("locators-article", None) - # self.setattr(la, "z:choose/z:else-if/z:choose/z:if/z:text", {"prefix": ":", "suffix":". "}) - c = self.addcondition(la, "z:choose/z:else-if/z:choose/z:if/z:text") - self.setattr(c["if"], "z:text", {"prefix": ":", "suffix": None}) - self.setattr(c["else"], "z:text", {"prefix": ":", "suffix":None}) - - # self.setattr(c["if"], "z:text", {"prefix": "、", "suffix": "頁"}) - # self.setattr(c["else"], "z:text", {"prefix": ", ", "suffix": ""}) - # d = self.addcondition(la, "z:choose/z:else-if[@type='article-journal']/z:choose/z:else/z:text") - # self.conds["locators-article"] = c - - def access(self): - a = self.macros.get("access", None) - self.setattr(a, "z:group", {"delimiter": " "}) - c = self.addcondition(a, "z:group/z:choose[4]") - - #doi & url - self.setattr(c["else"], "z:choose/z:if/z:choose/z:else/z:text", {"prefix": ". "}) - self.setattr(c["else"], "z:choose/z:if/z:choose/z:if/z:text", {"prefix": ". "}) - - self.setattr(c["else"], "z:choose/z:if/z:choose/z:else/z:text", {"suffix": " "}) - self.render({"tag": "date", "attrib": {"variable": "accessed", "prefix": " (", "suffix": ")", "form":"text"}}, c["else"], path="z:choose/z:if/z:choose/z:else") - - # Japanese - self.setattr(c["if"], "z:choose/z:if/z:choose/z:else/z:text", {"suffix": " "}) - self.render( - { - "tag": "date", "attrib": {"variable": "accessed", "prefix":"(", "suffix":" アクセス)", "delimiter": "/"}, - "children": [ - {"tag": "date-part", "attrib": {"form":"long", "name":"year"}}, - {"tag": "date-part", "attrib": {"form":"numeric", "name":"month"}}, - {"tag": "date-part", "attrib": {"form":"numeric", "name":"day"}} - ] - }, - c["if"], path="z:choose/z:if/z:choose/z:else") - - self.delelement(c["else"], "z:choose/z:if/z:choose/z:else/date") - self.render( - { - "tag": "date", "attrib": {"variable": "accessed", "prefix":"(", "suffix":" アクセス)", "delimiter": "/"}, - "children": [ - {"tag": "date-part", "attrib": {"form":"long", "name":"year"}}, - {"tag": "date-part", "attrib": {"form":"numeric", "name":"month"}}, - {"tag": "date-part", "attrib": {"form":"numeric", "name":"day"}} - ] - }, - c["else"], path="z:choose/z:if/z:choose/z:else") - - #remove date - self.delelement(a, "z:group/z:choose[2]") - self.conds["access"] = c \ No newline at end of file diff --git a/scripts/kyoseien.py b/scripts/kyoseien.py deleted file mode 100644 index 2375b99..0000000 --- a/scripts/kyoseien.py +++ /dev/null @@ -1,36 +0,0 @@ -from .kyosei import Kyosei -import copy - -class Kyoseien(Kyosei): - def __init__(self, input, journal, suffix, doclinks): - super().__init__(input, journal, suffix, doclinks) - - def custom(self): - super().custom() - - # Removing all full-width parentheses - locators = self.conds["locator-bill-etc"] - self.setattr(locators["if"], "z:group/z:group/z:number", {"prefix" : " (", "suffix": ") "}) - - # Citation - self.setattr(self.citation, "z:layout", {"prefix" : " (", "suffix": ") "}) - - # access - access = self.conds["access"] - self.setattr(access["else"], "z:choose/z:if/z:choose/z:else/date", {"prefix" : " (Access ", "suffix": ") "}) - self.setattr(access["if"], "z:choose/z:if/z:choose/z:else/date", {"prefix" : " (Access ", "suffix": ") "}) - - #title - title = self.conds["title-2"] - self.setattr(title["if"], "z:group", {"prefix" : " (", "suffix": ") "}) - - #Edition - edition = self.conds["edition"] - self.setattr(edition["if"], "z:text", {"prefix" : " (", "suffix": ") "}) - - # Clean bibliography layout - self.delelement(self.bibliography, "z:layout/choose") - self.render({"tag": "text", "attrib": {"value": "."}}, self.bibliography.xpath("z:layout", namespaces=self.ns)[0]) - - # Remove all conditions to leave only English - self.revertconditions(keeptag="else") \ No newline at end of file diff --git a/scripts/kyoso.py b/scripts/kyoso.py deleted file mode 100644 index e66f4ab..0000000 --- a/scripts/kyoso.py +++ /dev/null @@ -1,166 +0,0 @@ -from .chicago import Chicago -import copy - -class Kyoso(Chicago): - def __init__(self, input, journal, suffix, doclinks): - super().__init__(input, journal, suffix, doclinks) - - def custom(self): - # remove comma after name (setcitation) - self.setattr(self.citation, "z:layout/z:group/z:choose/z:if/z:group/z:text[@macro='contributors-short']", {"suffix":""}) - self.setattr(self.citation, ".", {"et-al-subsequent-min":"3", "et-al-subsequent-use-first":"1", "et-al-min":None, "et-al-use-first": None}) - self.shortpageprefix(":") - - # Issue number - self.originallocators() - - # Japanese dot at the end [ja & en] - #remove general suffix - self.setattr(self.bibliography, "z:layout", {"suffix": None}) - text = self.render({"tag": "text"}, self.bibliography, path="z:layout") - c = self.addcondition(text, ".") - self.setattr(c["if"], "text", {"value": "。"}) - self.setattr(c["else"], "text", {"value": "."}) - - # remove dot prefix in access - self.setattr(self.bibliography, "z:layout/z:text[@macro='access']", {"prefix": None}) - - # add space in front of URL - - - # Volume - - # Title - t = self.conds["title"] - self.setattr(t["else"], "z:text", {"quotes":"false", "prefix": None, "suffix": None}) - - # Journal name - t = self.conds["container-title"] - self.setattr(t["if"], "z:group/choose/if/z:text", {"prefix":None, "suffix":None}) - self.setattr(t["else"], "z:group/choose/if/z:text", {"prefix":". ", "suffix":". "}) - - # webpage container title [ja] - ctw = self.conds["container-title-webpage"] - self.setattr(ctw["if"], "z:text", {"prefix":"、", "suffix":"。"}) - self.setattr(ctw["else"], "z:text", {"prefix":". ", "suffix":""}) - - # Journal name (Add comma in front) [ja] - t = self.conds["container-title"] - self.setattr(t["if"], "z:group/choose/if/z:text", {"prefix":"『", "suffix":"』"}) - - # Date no parentheses - c = self.conds["date"] - self.setattr(c["else"], "z:group/z:date[@variable='original-date']", {"prefix": " ", "suffix": " "}) - self.setattr(c["else"], "z:group/z:date[@variable='issued']", {"prefix": " ", "suffix": " "}) - - # Date with comma [ja] - self.setattr(c["if"], "z:group/z:date[@variable='original-date']", {"prefix": " ", "suffix": ""}) - self.setattr(c["if"], "z:group/z:date[@variable='issued']", {"prefix": " ", "suffix": ""}) - - # Bibliography author - c = self.conds["contributors"] - self.setattr(c["if"], "z:names/z:name", {"name-as-sort-order": None}) - self.render({"tag": "name-part", "attrib": {"name": "family"}}, c["if"], path="z:names/z:name") - self.render({"tag": "name-part", "attrib": {"name": "given", "prefix": " "}}, c["if"], path="z:names/z:name") - - self.setattr(c["else"], "z:names", {"suffix": ""}) - self.setattr(c["else"], "z:names/z:name", {"initialize": "false", "and": "text", "name-as-sort-order":"first"}) - self.setattr(c["else"], "z:names/z:label", {"prefix": " (", "suffix":")", "form": "short"}) - - # remove dot before "In" - c = self.conds["container-contributors"] - hen = self.child(c["if"], "z:group/z:names[@variable='editor translator']") - yaku = copy.deepcopy(hen) - hen.getparent().insert(-1, yaku) - self.setattrs(yaku, {"variable": "translator", "delimiter": "・", "suffix": "訳、"}) - hen.attrib["variable"] = "editor" - - self.setattr(c["else"], "text", {"prefix": ". "}) - self.setattr(c["else"], "z:group/z:names[@variable='editor translator']/z:name", {"and": "text", "initialize": "true", "name-as-sort-order": None}) - - # add 、 in front of contributors [ja] - # self.setattr(c["if"], "z:group", {"prefix": "、", "suffix": "、"}) - - # remov 、 in front of publisher [ja] - c = self.conds["publisher"] - self.setattr(c["if"], "z:group", {"prefix": None}) - - c = self.conds["secondary-contributors"] - self.setattr(c["if"], "z:group", {"suffix": "、"}) - - #move issue towards the end - self.move(self.bibliography, "z:layout/z:text[@macro='issue']", "z:layout/z:text[@macro='locators-article']") - - #remove delimiter before & - self.setattr(self.conds["contributors-short"]["else"], "z:names/z:name", {"delimiter-precedes-last":"never"}) - self.aaa() - - def aaa(self): - layout = self.child(self.bibliography, "z:layout") - group = self.child(self.bibliography, "z:layout/z:group") - self.unwrap(group) - self.wrap(layout, "group", {"display": "block"}) - - c = self.child(self.bibliography, "z:layout/group/z:text[@macro='contributors']") - layout.insert(0, c) - - self.setattr(self.bibliography, ".", {"hanging-indent": None, "subsequent-author-substitute":""}) - - def locatorschapter(self): - lc = self.macros.get("locators-chapter", None) - c = self.addcondition(lc, "z:choose/z:if/z:choose/z:if/z:group") - self.setattr(c["if"], "z:group", {"prefix": "pp. ", "suffix": "、"}) - self.setattr(c["else"], "z:group", {"prefix": ", pp. "}) - - def locatorsarticle(self): - la = self.macros.get("locators-article", None) - # self.setattr(la, "z:choose/z:else-if/z:choose/z:if/z:text", {"prefix": ":", "suffix":". "}) - c = self.addcondition(la, "z:choose/z:else-if/z:choose/z:if/z:text") - self.setattr(c["if"], "z:text", {"prefix": ":", "suffix": None}) - self.setattr(c["else"], "z:text", {"prefix": ":", "suffix":None}) - - # self.setattr(c["if"], "z:text", {"prefix": "、", "suffix": "頁"}) - # self.setattr(c["else"], "z:text", {"prefix": ", ", "suffix": ""}) - # d = self.addcondition(la, "z:choose/z:else-if[@type='article-journal']/z:choose/z:else/z:text") - # self.conds["locators-article"] = c - - def access(self): - a = self.macros.get("access", None) - self.setattr(a, "z:group", {"delimiter": " "}) - c = self.addcondition(a, "z:group/z:choose[4]") - - #doi & url - self.setattr(c["else"], "z:choose/z:if/z:choose/z:else/z:text", {"prefix": ". "}) - self.setattr(c["else"], "z:choose/z:if/z:choose/z:if/z:text", {"prefix": ". "}) - - self.setattr(c["else"], "z:choose/z:if/z:choose/z:else/z:text", {"suffix": " "}) - self.render({"tag": "date", "attrib": {"variable": "accessed", "prefix": " (", "suffix": ")", "form":"text"}}, c["else"], path="z:choose/z:if/z:choose/z:else") - - # Japanese - self.setattr(c["if"], "z:choose/z:if/z:choose/z:else/z:text", {"suffix": " "}) - self.render( - { - "tag": "date", "attrib": {"variable": "accessed", "prefix":"(", "suffix":" アクセス)", "delimiter": "/"}, - "children": [ - {"tag": "date-part", "attrib": {"form":"numeric", "name":"year"}}, - {"tag": "date-part", "attrib": {"form":"numeric", "name":"month"}}, - {"tag": "date-part", "attrib": {"form":"numeric", "name":"day"}} - ] - }, - c["if"], path="z:choose/z:if/z:choose/z:else") - - self.delelement(c["else"], "z:choose/z:if/z:choose/z:else/date") - self.render( - { - "tag": "date", "attrib": {"variable": "accessed", "prefix":"(", "suffix":" アクセス)", "delimiter": "/"}, - "children": [ - {"tag": "date-part", "attrib": {"form":"numeric", "name":"year"}}, - {"tag": "date-part", "attrib": {"form":"numeric", "name":"month"}}, - {"tag": "date-part", "attrib": {"form":"numeric", "name":"day"}} - ] - }, - c["else"], path="z:choose/z:if/z:choose/z:else") - - #remove date - self.delelement(a, "z:group/z:choose[2]") - self.conds["access"] = c \ No newline at end of file diff --git a/scripts/source/chicago-author-date.csl b/scripts/source/chicago-author-date.csl deleted file mode 100644 index 2ed7e6d..0000000 --- a/scripts/source/chicago-author-date.csl +++ /dev/null @@ -1,682 +0,0 @@ - -