├── .gitignore ├── LICENSE ├── README.md ├── conformer ├── __init__.py ├── activation.py ├── attention.py ├── convolution.py ├── embedding.py ├── encoder.py ├── feed_forward.py ├── model.py └── modules.py ├── docs ├── .DS_Store ├── Makefile ├── Model.html ├── Modules.html ├── Submodules.html ├── _sources │ ├── Model.rst.txt │ ├── Modules.rst.txt │ ├── Submodules.rst.txt │ └── index.rst.txt ├── _static │ ├── basic.css │ ├── css │ │ ├── badge_only.css │ │ ├── fonts │ │ │ ├── Roboto-Slab-Bold.woff │ │ │ ├── Roboto-Slab-Bold.woff2 │ │ │ ├── Roboto-Slab-Regular.woff │ │ │ ├── Roboto-Slab-Regular.woff2 │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.svg │ │ │ ├── fontawesome-webfont.ttf │ │ │ ├── fontawesome-webfont.woff │ │ │ ├── fontawesome-webfont.woff2 │ │ │ ├── lato-bold-italic.woff │ │ │ ├── lato-bold-italic.woff2 │ │ │ ├── lato-bold.woff │ │ │ ├── lato-bold.woff2 │ │ │ ├── lato-normal-italic.woff │ │ │ ├── lato-normal-italic.woff2 │ │ │ ├── lato-normal.woff │ │ │ └── lato-normal.woff2 │ │ └── theme.css │ ├── doctools.js │ ├── documentation_options.js │ ├── file.png │ ├── jquery-3.5.1.js │ ├── jquery.js │ ├── js │ │ ├── badge_only.js │ │ ├── html5shiv-printshiv.min.js │ │ ├── html5shiv.min.js │ │ └── theme.js │ ├── language_data.js │ ├── minus.png │ ├── plus.png │ ├── pygments.css │ ├── searchtools.js │ ├── underscore-1.3.1.js │ └── underscore.js ├── genindex.html ├── index.html ├── make.bat ├── objects.inv ├── search.html ├── searchindex.js └── source │ ├── Model.rst │ ├── Modules.rst │ ├── Submodules.rst │ ├── conf.py │ └── index.rst └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | experiment/ 2 | experiment/* 3 | data/sample 4 | data/sample/* 5 | data/data_list/debug_list.csv 6 | data/data_list/sample_list.csv 7 | *.bin 8 | *.zip 9 | *.idea 10 | docs/training 11 | docs/training/* 12 | __pycache__/ 13 | venv/* 14 | *.pyc 15 | .idea 16 | .ipynb_checkpoints 17 | # Byte-compiled / optimized / DLL files 18 | __pycache__/ 19 | *.py[cod] 20 | *$py.class 21 | 22 | # C extensions 23 | *.so 24 | 25 | # Distribution / packaging 26 | .Python 27 | build/ 28 | develop-eggs/ 29 | dist/ 30 | downloads/ 31 | eggs/ 32 | .eggs/ 33 | lib/ 34 | lib64/ 35 | parts/ 36 | sdist/ 37 | var/ 38 | wheels/ 39 | pip-wheel-metadata/ 40 | share/python-wheels/ 41 | *.egg-info/ 42 | .installed.cfg 43 | *.egg 44 | MANIFEST 45 | 46 | # PyInstaller 47 | # Usually these files are written by a python script from a template 48 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 49 | *.manifest 50 | *.spec 51 | 52 | # Installer logs 53 | pip-log.txt 54 | pip-delete-this-directory.txt 55 | 56 | # Unit test / coverage reports 57 | htmlcov/ 58 | .tox/ 59 | .nox/ 60 | .coverage 61 | .coverage.* 62 | .cache 63 | nosetests.xml 64 | coverage.xml 65 | *.cover 66 | *.py,cover 67 | .hypothesis/ 68 | .pytest_cache/ 69 | 70 | # Translations 71 | *.mo 72 | *.pot 73 | 74 | # Django stuff: 75 | *.log 76 | local_settings.py 77 | db.sqlite3 78 | db.sqlite3-journal 79 | 80 | # Flask stuff: 81 | instance/ 82 | .webassets-cache 83 | 84 | # Scrapy stuff: 85 | .scrapy 86 | 87 | # Sphinx documentation 88 | docs/_build/ 89 | 90 | # PyBuilder 91 | target/ 92 | 93 | # Jupyter Notebook 94 | .ipynb_checkpoints 95 | 96 | # IPython 97 | profile_default/ 98 | ipython_config.py 99 | 100 | # pyenv 101 | .python-version 102 | 103 | # pipenv 104 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 105 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 106 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 107 | # install all needed dependencies. 108 | #Pipfile.lock 109 | 110 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 111 | __pypackages__/ 112 | 113 | # Celery stuff 114 | celerybeat-schedule 115 | celerybeat.pid 116 | 117 | # SageMath parsed files 118 | *.sage.py 119 | 120 | # Environments 121 | .env 122 | .venv 123 | env/ 124 | venv/ 125 | ENV/ 126 | env.bak/ 127 | venv.bak/ 128 | 129 | # Spyder project settings 130 | .spyderproject 131 | .spyproject 132 | 133 | # Rope project settings 134 | .ropeproject 135 | 136 | # mkdocs documentation 137 | /site 138 | 139 | # mypy 140 | .mypy_cache/ 141 | .dmypy.json 142 | dmypy.json 143 | 144 | # Pyre type checker 145 | .pyre/ 146 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 |

5 | 6 | **PyTorch implementation of Conformer: Convolution-augmented Transformer for Speech Recognition.** 7 | 8 | 9 |
10 | 11 | *** 12 | 13 |

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | Transformer models are good at capturing content-based global interactions, while CNNs exploit local features effectively. Conformer combine convolution neural networks and transformers to model both local and global dependencies of an audio sequence in a parameter-efficient way. Conformer significantly outperforms the previous Transformer and CNN based models achieving state-of-the-art accuracies. 29 | 30 | 31 | 32 | This repository contains only model code, but you can train with conformer at [openspeech](https://github.com/openspeech-team/openspeech) 33 | 34 | ## Installation 35 | This project recommends Python 3.7 or higher. 36 | We recommend creating a new virtual environment for this project (using virtual env or conda). 37 | 38 | ### Prerequisites 39 | * Numpy: `pip install numpy` (Refer [here](https://github.com/numpy/numpy) for problem installing Numpy). 40 | * Pytorch: Refer to [PyTorch website](http://pytorch.org/) to install the version w.r.t. your environment. 41 | 42 | ### Install from source 43 | Currently we only support installation from source code using setuptools. Checkout the source code and run the 44 | following commands: 45 | 46 | ``` 47 | pip install -e . 48 | ``` 49 | 50 | ## Usage 51 | 52 | ```python 53 | import torch 54 | import torch.nn as nn 55 | from conformer import Conformer 56 | 57 | batch_size, sequence_length, dim = 3, 12345, 80 58 | 59 | cuda = torch.cuda.is_available() 60 | device = torch.device('cuda' if cuda else 'cpu') 61 | 62 | criterion = nn.CTCLoss().to(device) 63 | 64 | inputs = torch.rand(batch_size, sequence_length, dim).to(device) 65 | input_lengths = torch.LongTensor([12345, 12300, 12000]) 66 | targets = torch.LongTensor([[1, 3, 3, 3, 3, 3, 4, 5, 6, 2], 67 | [1, 3, 3, 3, 3, 3, 4, 5, 2, 0], 68 | [1, 3, 3, 3, 3, 3, 4, 2, 0, 0]]).to(device) 69 | target_lengths = torch.LongTensor([9, 8, 7]) 70 | 71 | model = Conformer(num_classes=10, 72 | input_dim=dim, 73 | encoder_dim=32, 74 | num_encoder_layers=3).to(device) 75 | 76 | # Forward propagate 77 | outputs, output_lengths = model(inputs, input_lengths) 78 | 79 | # Calculate CTC Loss 80 | loss = criterion(outputs.transpose(0, 1), targets, output_lengths, target_lengths) 81 | ``` 82 | 83 | ## Troubleshoots and Contributing 84 | If you have any questions, bug reports, and feature requests, please [open an issue](https://github.com/sooftware/conformer/issues) on github or 85 | contacts sh951011@gmail.com please. 86 | 87 | I appreciate any kind of feedback or contribution. Feel free to proceed with small issues like bug fixes, documentation improvement. For major contributions and new features, please discuss with the collaborators in corresponding issues. 88 | 89 | ## Code Style 90 | I follow [PEP-8](https://www.python.org/dev/peps/pep-0008/) for code style. Especially the style of docstrings is important to generate documentation. 91 | 92 | ## Reference 93 | - [Conformer: Convolution-augmented Transformer for Speech Recognition](https://arxiv.org/pdf/2005.08100.pdf) 94 | - [Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context](https://arxiv.org/abs/1901.02860) 95 | - [kimiyoung/transformer-xl](https://github.com/kimiyoung/transformer-xl) 96 | - [espnet/espnet](https://github.com/espnet/espnet) 97 | 98 | ## Author 99 | 100 | * Soohwan Kim [@sooftware](https://github.com/sooftware) 101 | * Contacts: sh951011@gmail.com 102 | -------------------------------------------------------------------------------- /conformer/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, Soohwan Kim. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .model import Conformer 16 | -------------------------------------------------------------------------------- /conformer/activation.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, Soohwan Kim. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import torch.nn as nn 16 | from torch import Tensor 17 | 18 | 19 | class Swish(nn.Module): 20 | """ 21 | Swish is a smooth, non-monotonic function that consistently matches or outperforms ReLU on deep networks applied 22 | to a variety of challenging domains such as Image classification and Machine translation. 23 | """ 24 | def __init__(self): 25 | super(Swish, self).__init__() 26 | 27 | def forward(self, inputs: Tensor) -> Tensor: 28 | return inputs * inputs.sigmoid() 29 | 30 | 31 | class GLU(nn.Module): 32 | """ 33 | The gating mechanism is called Gated Linear Units (GLU), which was first introduced for natural language processing 34 | in the paper “Language Modeling with Gated Convolutional Networks” 35 | """ 36 | def __init__(self, dim: int) -> None: 37 | super(GLU, self).__init__() 38 | self.dim = dim 39 | 40 | def forward(self, inputs: Tensor) -> Tensor: 41 | outputs, gate = inputs.chunk(2, dim=self.dim) 42 | return outputs * gate.sigmoid() 43 | -------------------------------------------------------------------------------- /conformer/attention.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, Soohwan Kim. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import math 16 | import torch 17 | import torch.nn as nn 18 | import torch.nn.functional as F 19 | from torch import Tensor 20 | from typing import Optional 21 | 22 | from .embedding import RelPositionalEncoding 23 | from .modules import Linear 24 | 25 | 26 | class RelativeMultiHeadAttention(nn.Module): 27 | """ 28 | Multi-head attention with relative positional encoding. 29 | This concept was proposed in the "Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context" 30 | 31 | Args: 32 | d_model (int): The dimension of model 33 | num_heads (int): The number of attention heads. 34 | dropout_p (float): probability of dropout 35 | 36 | Inputs: query, key, value, pos_embedding, mask 37 | - **query** (batch, time, dim): Tensor containing query vector 38 | - **key** (batch, time, dim): Tensor containing key vector 39 | - **value** (batch, time, dim): Tensor containing value vector 40 | - **pos_embedding** (batch, time, dim): Positional embedding tensor 41 | - **mask** (batch, 1, time2) or (batch, time1, time2): Tensor containing indices to be masked 42 | 43 | Returns: 44 | - **outputs**: Tensor produces by relative multi head attention module. 45 | """ 46 | def __init__( 47 | self, 48 | d_model: int = 512, 49 | num_heads: int = 16, 50 | dropout_p: float = 0.1, 51 | ): 52 | super(RelativeMultiHeadAttention, self).__init__() 53 | assert d_model % num_heads == 0, "d_model % num_heads should be zero." 54 | self.d_model = d_model 55 | self.d_head = int(d_model / num_heads) 56 | self.num_heads = num_heads 57 | self.sqrt_dim = math.sqrt(self.d_head) 58 | 59 | self.query_proj = Linear(d_model, d_model) 60 | self.key_proj = Linear(d_model, d_model) 61 | self.value_proj = Linear(d_model, d_model) 62 | self.pos_proj = Linear(d_model, d_model, bias=False) 63 | 64 | self.dropout = nn.Dropout(p=dropout_p) 65 | self.u_bias = nn.Parameter(torch.Tensor(self.num_heads, self.d_head)) 66 | self.v_bias = nn.Parameter(torch.Tensor(self.num_heads, self.d_head)) 67 | torch.nn.init.xavier_uniform_(self.u_bias) 68 | torch.nn.init.xavier_uniform_(self.v_bias) 69 | 70 | self.out_proj = Linear(d_model, d_model) 71 | 72 | def forward( 73 | self, 74 | query: Tensor, 75 | key: Tensor, 76 | value: Tensor, 77 | pos_embedding: Tensor, 78 | mask: Optional[Tensor] = None, 79 | ) -> Tensor: 80 | batch_size = value.size(0) 81 | 82 | query = self.query_proj(query).view(batch_size, -1, self.num_heads, self.d_head) 83 | key = self.key_proj(key).view(batch_size, -1, self.num_heads, self.d_head).permute(0, 2, 1, 3) 84 | value = self.value_proj(value).view(batch_size, -1, self.num_heads, self.d_head).permute(0, 2, 1, 3) 85 | pos_embedding = self.pos_proj(pos_embedding).view(batch_size, -1, self.num_heads, self.d_head) 86 | 87 | content_score = torch.matmul((query + self.u_bias).transpose(1, 2), key.transpose(2, 3)) 88 | pos_score = torch.matmul((query + self.v_bias).transpose(1, 2), pos_embedding.permute(0, 2, 3, 1)) 89 | pos_score = self._relative_shift(pos_score) 90 | 91 | score = (content_score + pos_score) / self.sqrt_dim 92 | 93 | if mask is not None: 94 | mask = mask.unsqueeze(1) 95 | score.masked_fill_(mask, -1e9) 96 | 97 | attn = F.softmax(score, -1) 98 | attn = self.dropout(attn) 99 | 100 | context = torch.matmul(attn, value).transpose(1, 2) 101 | context = context.contiguous().view(batch_size, -1, self.d_model) 102 | 103 | return self.out_proj(context) 104 | 105 | def _relative_shift(self, pos_score: Tensor) -> Tensor: 106 | batch_size, num_heads, seq_length1, seq_length2 = pos_score.size() 107 | zeros = pos_score.new_zeros(batch_size, num_heads, seq_length1, 1) 108 | padded_pos_score = torch.cat([zeros, pos_score], dim=-1) 109 | 110 | padded_pos_score = padded_pos_score.view(batch_size, num_heads, seq_length2 + 1, seq_length1) 111 | pos_score = padded_pos_score[:, :, 1:].view_as(pos_score)[:, :, :, : seq_length2 // 2 + 1] 112 | 113 | return pos_score 114 | 115 | 116 | class MultiHeadedSelfAttentionModule(nn.Module): 117 | """ 118 | Conformer employ multi-headed self-attention (MHSA) while integrating an important technique from Transformer-XL, 119 | the relative sinusoidal positional encoding scheme. The relative positional encoding allows the self-attention 120 | module to generalize better on different input length and the resulting encoder is more robust to the variance of 121 | the utterance length. Conformer use prenorm residual units with dropout which helps training 122 | and regularizing deeper models. 123 | 124 | Args: 125 | d_model (int): The dimension of model 126 | num_heads (int): The number of attention heads. 127 | dropout_p (float): probability of dropout 128 | 129 | Inputs: inputs, mask 130 | - **inputs** (batch, time, dim): Tensor containing input vector 131 | - **mask** (batch, 1, time2) or (batch, time1, time2): Tensor containing indices to be masked 132 | 133 | Returns: 134 | - **outputs** (batch, time, dim): Tensor produces by relative multi headed self attention module. 135 | """ 136 | def __init__(self, d_model: int, num_heads: int, dropout_p: float = 0.1): 137 | super(MultiHeadedSelfAttentionModule, self).__init__() 138 | self.positional_encoding = RelPositionalEncoding(d_model) 139 | self.layer_norm = nn.LayerNorm(d_model) 140 | self.attention = RelativeMultiHeadAttention(d_model, num_heads, dropout_p) 141 | self.dropout = nn.Dropout(p=dropout_p) 142 | 143 | def forward(self, inputs: Tensor, mask: Optional[Tensor] = None): 144 | batch_size = inputs.size(0) 145 | pos_embedding = self.positional_encoding(inputs) 146 | pos_embedding = pos_embedding.repeat(batch_size, 1, 1) 147 | 148 | inputs = self.layer_norm(inputs) 149 | outputs = self.attention(inputs, inputs, inputs, pos_embedding=pos_embedding, mask=mask) 150 | 151 | return self.dropout(outputs) 152 | -------------------------------------------------------------------------------- /conformer/convolution.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, Soohwan Kim. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import torch 16 | import torch.nn as nn 17 | from torch import Tensor 18 | from typing import Tuple 19 | 20 | from .activation import Swish, GLU 21 | from .modules import Transpose 22 | 23 | 24 | class DepthwiseConv1d(nn.Module): 25 | """ 26 | When groups == in_channels and out_channels == K * in_channels, where K is a positive integer, 27 | this operation is termed in literature as depthwise convolution. 28 | 29 | Args: 30 | in_channels (int): Number of channels in the input 31 | out_channels (int): Number of channels produced by the convolution 32 | kernel_size (int or tuple): Size of the convolving kernel 33 | stride (int, optional): Stride of the convolution. Default: 1 34 | padding (int or tuple, optional): Zero-padding added to both sides of the input. Default: 0 35 | bias (bool, optional): If True, adds a learnable bias to the output. Default: True 36 | 37 | Inputs: inputs 38 | - **inputs** (batch, in_channels, time): Tensor containing input vector 39 | 40 | Returns: outputs 41 | - **outputs** (batch, out_channels, time): Tensor produces by depthwise 1-D convolution. 42 | """ 43 | def __init__( 44 | self, 45 | in_channels: int, 46 | out_channels: int, 47 | kernel_size: int, 48 | stride: int = 1, 49 | padding: int = 0, 50 | bias: bool = False, 51 | ) -> None: 52 | super(DepthwiseConv1d, self).__init__() 53 | assert out_channels % in_channels == 0, "out_channels should be constant multiple of in_channels" 54 | self.conv = nn.Conv1d( 55 | in_channels=in_channels, 56 | out_channels=out_channels, 57 | kernel_size=kernel_size, 58 | groups=in_channels, 59 | stride=stride, 60 | padding=padding, 61 | bias=bias, 62 | ) 63 | 64 | def forward(self, inputs: Tensor) -> Tensor: 65 | return self.conv(inputs) 66 | 67 | 68 | class PointwiseConv1d(nn.Module): 69 | """ 70 | When kernel size == 1 conv1d, this operation is termed in literature as pointwise convolution. 71 | This operation often used to match dimensions. 72 | 73 | Args: 74 | in_channels (int): Number of channels in the input 75 | out_channels (int): Number of channels produced by the convolution 76 | stride (int, optional): Stride of the convolution. Default: 1 77 | padding (int or tuple, optional): Zero-padding added to both sides of the input. Default: 0 78 | bias (bool, optional): If True, adds a learnable bias to the output. Default: True 79 | 80 | Inputs: inputs 81 | - **inputs** (batch, in_channels, time): Tensor containing input vector 82 | 83 | Returns: outputs 84 | - **outputs** (batch, out_channels, time): Tensor produces by pointwise 1-D convolution. 85 | """ 86 | def __init__( 87 | self, 88 | in_channels: int, 89 | out_channels: int, 90 | stride: int = 1, 91 | padding: int = 0, 92 | bias: bool = True, 93 | ) -> None: 94 | super(PointwiseConv1d, self).__init__() 95 | self.conv = nn.Conv1d( 96 | in_channels=in_channels, 97 | out_channels=out_channels, 98 | kernel_size=1, 99 | stride=stride, 100 | padding=padding, 101 | bias=bias, 102 | ) 103 | 104 | def forward(self, inputs: Tensor) -> Tensor: 105 | return self.conv(inputs) 106 | 107 | 108 | class ConformerConvModule(nn.Module): 109 | """ 110 | Conformer convolution module starts with a pointwise convolution and a gated linear unit (GLU). 111 | This is followed by a single 1-D depthwise convolution layer. Batchnorm is deployed just after the convolution 112 | to aid training deep models. 113 | 114 | Args: 115 | in_channels (int): Number of channels in the input 116 | kernel_size (int or tuple, optional): Size of the convolving kernel Default: 31 117 | dropout_p (float, optional): probability of dropout 118 | 119 | Inputs: inputs 120 | inputs (batch, time, dim): Tensor contains input sequences 121 | 122 | Outputs: outputs 123 | outputs (batch, time, dim): Tensor produces by conformer convolution module. 124 | """ 125 | def __init__( 126 | self, 127 | in_channels: int, 128 | kernel_size: int = 31, 129 | expansion_factor: int = 2, 130 | dropout_p: float = 0.1, 131 | ) -> None: 132 | super(ConformerConvModule, self).__init__() 133 | assert (kernel_size - 1) % 2 == 0, "kernel_size should be a odd number for 'SAME' padding" 134 | assert expansion_factor == 2, "Currently, Only Supports expansion_factor 2" 135 | 136 | self.sequential = nn.Sequential( 137 | nn.LayerNorm(in_channels), 138 | Transpose(shape=(1, 2)), 139 | PointwiseConv1d(in_channels, in_channels * expansion_factor, stride=1, padding=0, bias=True), 140 | GLU(dim=1), 141 | DepthwiseConv1d(in_channels, in_channels, kernel_size, stride=1, padding=(kernel_size - 1) // 2), 142 | nn.BatchNorm1d(in_channels), 143 | Swish(), 144 | PointwiseConv1d(in_channels, in_channels, stride=1, padding=0, bias=True), 145 | nn.Dropout(p=dropout_p), 146 | ) 147 | 148 | def forward(self, inputs: Tensor) -> Tensor: 149 | return self.sequential(inputs).transpose(1, 2) 150 | 151 | 152 | class Conv2dSubampling(nn.Module): 153 | """ 154 | Convolutional 2D subsampling (to 1/4 length) 155 | 156 | Args: 157 | in_channels (int): Number of channels in the input image 158 | out_channels (int): Number of channels produced by the convolution 159 | 160 | Inputs: inputs 161 | - **inputs** (batch, time, dim): Tensor containing sequence of inputs 162 | 163 | Returns: outputs, output_lengths 164 | - **outputs** (batch, time, dim): Tensor produced by the convolution 165 | - **output_lengths** (batch): list of sequence output lengths 166 | """ 167 | def __init__(self, in_channels: int, out_channels: int) -> None: 168 | super(Conv2dSubampling, self).__init__() 169 | self.sequential = nn.Sequential( 170 | nn.Conv2d(in_channels, out_channels, kernel_size=3, stride=2), 171 | nn.ReLU(), 172 | nn.Conv2d(out_channels, out_channels, kernel_size=3, stride=2), 173 | nn.ReLU(), 174 | ) 175 | 176 | def forward(self, inputs: Tensor, input_lengths: Tensor) -> Tuple[Tensor, Tensor]: 177 | outputs = self.sequential(inputs.unsqueeze(1)) 178 | batch_size, channels, subsampled_lengths, sumsampled_dim = outputs.size() 179 | 180 | outputs = outputs.permute(0, 2, 1, 3) 181 | outputs = outputs.contiguous().view(batch_size, subsampled_lengths, channels * sumsampled_dim) 182 | 183 | output_lengths = input_lengths >> 2 184 | output_lengths -= 1 185 | 186 | return outputs, output_lengths 187 | -------------------------------------------------------------------------------- /conformer/embedding.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, Soohwan Kim. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import math 16 | import torch 17 | import torch.nn as nn 18 | from torch import Tensor 19 | 20 | 21 | class RelPositionalEncoding(nn.Module): 22 | """ 23 | Relative positional encoding module. 24 | Args: 25 | d_model: Embedding dimension. 26 | max_len: Maximum input length. 27 | """ 28 | 29 | def __init__(self, d_model: int = 512, max_len: int = 5000) -> None: 30 | super(RelPositionalEncoding, self).__init__() 31 | self.d_model = d_model 32 | self.pe = None 33 | self.extend_pe(torch.tensor(0.0).expand(1, max_len)) 34 | 35 | def extend_pe(self, x: Tensor) -> None: 36 | if self.pe is not None: 37 | if self.pe.size(1) >= x.size(1) * 2 - 1: 38 | if self.pe.dtype != x.dtype or self.pe.device != x.device: 39 | self.pe = self.pe.to(dtype=x.dtype, device=x.device) 40 | return 41 | 42 | pe_positive = torch.zeros(x.size(1), self.d_model) 43 | pe_negative = torch.zeros(x.size(1), self.d_model) 44 | position = torch.arange(0, x.size(1), dtype=torch.float32).unsqueeze(1) 45 | div_term = torch.exp( 46 | torch.arange(0, self.d_model, 2, dtype=torch.float32) * -(math.log(10000.0) / self.d_model) 47 | ) 48 | pe_positive[:, 0::2] = torch.sin(position * div_term) 49 | pe_positive[:, 1::2] = torch.cos(position * div_term) 50 | pe_negative[:, 0::2] = torch.sin(-1 * position * div_term) 51 | pe_negative[:, 1::2] = torch.cos(-1 * position * div_term) 52 | 53 | pe_positive = torch.flip(pe_positive, [0]).unsqueeze(0) 54 | pe_negative = pe_negative[1:].unsqueeze(0) 55 | pe = torch.cat([pe_positive, pe_negative], dim=1) 56 | self.pe = pe.to(device=x.device, dtype=x.dtype) 57 | 58 | def forward(self, x: Tensor) -> Tensor: 59 | """ 60 | Args: 61 | x : Input tensor B X T X C 62 | Returns: 63 | torch.Tensor: Encoded tensor B X T X C 64 | """ 65 | self.extend_pe(x) 66 | pos_emb = self.pe[ 67 | :, 68 | self.pe.size(1) // 2 - x.size(1) + 1 : self.pe.size(1) // 2 + x.size(1), 69 | ] 70 | return pos_emb 71 | -------------------------------------------------------------------------------- /conformer/encoder.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, Soohwan Kim. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import torch 16 | import torch.nn as nn 17 | from torch import Tensor 18 | from typing import Tuple 19 | 20 | from .feed_forward import FeedForwardModule 21 | from .attention import MultiHeadedSelfAttentionModule 22 | from .convolution import ( 23 | ConformerConvModule, 24 | Conv2dSubampling, 25 | ) 26 | from .modules import ( 27 | ResidualConnectionModule, 28 | Linear, 29 | ) 30 | 31 | 32 | class ConformerBlock(nn.Module): 33 | """ 34 | Conformer block contains two Feed Forward modules sandwiching the Multi-Headed Self-Attention module 35 | and the Convolution module. This sandwich structure is inspired by Macaron-Net, which proposes replacing 36 | the original feed-forward layer in the Transformer block into two half-step feed-forward layers, 37 | one before the attention layer and one after. 38 | 39 | Args: 40 | encoder_dim (int, optional): Dimension of conformer encoder 41 | num_attention_heads (int, optional): Number of attention heads 42 | feed_forward_expansion_factor (int, optional): Expansion factor of feed forward module 43 | conv_expansion_factor (int, optional): Expansion factor of conformer convolution module 44 | feed_forward_dropout_p (float, optional): Probability of feed forward module dropout 45 | attention_dropout_p (float, optional): Probability of attention module dropout 46 | conv_dropout_p (float, optional): Probability of conformer convolution module dropout 47 | conv_kernel_size (int or tuple, optional): Size of the convolving kernel 48 | half_step_residual (bool): Flag indication whether to use half step residual or not 49 | 50 | Inputs: inputs 51 | - **inputs** (batch, time, dim): Tensor containing input vector 52 | 53 | Returns: outputs 54 | - **outputs** (batch, time, dim): Tensor produces by conformer block. 55 | """ 56 | def __init__( 57 | self, 58 | encoder_dim: int = 512, 59 | num_attention_heads: int = 8, 60 | feed_forward_expansion_factor: int = 4, 61 | conv_expansion_factor: int = 2, 62 | feed_forward_dropout_p: float = 0.1, 63 | attention_dropout_p: float = 0.1, 64 | conv_dropout_p: float = 0.1, 65 | conv_kernel_size: int = 31, 66 | half_step_residual: bool = True, 67 | ): 68 | super(ConformerBlock, self).__init__() 69 | if half_step_residual: 70 | self.feed_forward_residual_factor = 0.5 71 | else: 72 | self.feed_forward_residual_factor = 1 73 | 74 | self.sequential = nn.Sequential( 75 | ResidualConnectionModule( 76 | module=FeedForwardModule( 77 | encoder_dim=encoder_dim, 78 | expansion_factor=feed_forward_expansion_factor, 79 | dropout_p=feed_forward_dropout_p, 80 | ), 81 | module_factor=self.feed_forward_residual_factor, 82 | ), 83 | ResidualConnectionModule( 84 | module=MultiHeadedSelfAttentionModule( 85 | d_model=encoder_dim, 86 | num_heads=num_attention_heads, 87 | dropout_p=attention_dropout_p, 88 | ), 89 | ), 90 | ResidualConnectionModule( 91 | module=ConformerConvModule( 92 | in_channels=encoder_dim, 93 | kernel_size=conv_kernel_size, 94 | expansion_factor=conv_expansion_factor, 95 | dropout_p=conv_dropout_p, 96 | ), 97 | ), 98 | ResidualConnectionModule( 99 | module=FeedForwardModule( 100 | encoder_dim=encoder_dim, 101 | expansion_factor=feed_forward_expansion_factor, 102 | dropout_p=feed_forward_dropout_p, 103 | ), 104 | module_factor=self.feed_forward_residual_factor, 105 | ), 106 | nn.LayerNorm(encoder_dim), 107 | ) 108 | 109 | def forward(self, inputs: Tensor) -> Tensor: 110 | return self.sequential(inputs) 111 | 112 | 113 | class ConformerEncoder(nn.Module): 114 | """ 115 | Conformer encoder first processes the input with a convolution subsampling layer and then 116 | with a number of conformer blocks. 117 | 118 | Args: 119 | input_dim (int, optional): Dimension of input vector 120 | encoder_dim (int, optional): Dimension of conformer encoder 121 | num_layers (int, optional): Number of conformer blocks 122 | num_attention_heads (int, optional): Number of attention heads 123 | feed_forward_expansion_factor (int, optional): Expansion factor of feed forward module 124 | conv_expansion_factor (int, optional): Expansion factor of conformer convolution module 125 | feed_forward_dropout_p (float, optional): Probability of feed forward module dropout 126 | attention_dropout_p (float, optional): Probability of attention module dropout 127 | conv_dropout_p (float, optional): Probability of conformer convolution module dropout 128 | conv_kernel_size (int or tuple, optional): Size of the convolving kernel 129 | half_step_residual (bool): Flag indication whether to use half step residual or not 130 | 131 | Inputs: inputs, input_lengths 132 | - **inputs** (batch, time, dim): Tensor containing input vector 133 | - **input_lengths** (batch): list of sequence input lengths 134 | 135 | Returns: outputs, output_lengths 136 | - **outputs** (batch, out_channels, time): Tensor produces by conformer encoder. 137 | - **output_lengths** (batch): list of sequence output lengths 138 | """ 139 | def __init__( 140 | self, 141 | input_dim: int = 80, 142 | encoder_dim: int = 512, 143 | num_layers: int = 17, 144 | num_attention_heads: int = 8, 145 | feed_forward_expansion_factor: int = 4, 146 | conv_expansion_factor: int = 2, 147 | input_dropout_p: float = 0.1, 148 | feed_forward_dropout_p: float = 0.1, 149 | attention_dropout_p: float = 0.1, 150 | conv_dropout_p: float = 0.1, 151 | conv_kernel_size: int = 31, 152 | half_step_residual: bool = True, 153 | ): 154 | super(ConformerEncoder, self).__init__() 155 | self.conv_subsample = Conv2dSubampling(in_channels=1, out_channels=encoder_dim) 156 | self.input_projection = nn.Sequential( 157 | Linear(encoder_dim * (((input_dim - 1) // 2 - 1) // 2), encoder_dim), 158 | nn.Dropout(p=input_dropout_p), 159 | ) 160 | self.layers = nn.ModuleList([ConformerBlock( 161 | encoder_dim=encoder_dim, 162 | num_attention_heads=num_attention_heads, 163 | feed_forward_expansion_factor=feed_forward_expansion_factor, 164 | conv_expansion_factor=conv_expansion_factor, 165 | feed_forward_dropout_p=feed_forward_dropout_p, 166 | attention_dropout_p=attention_dropout_p, 167 | conv_dropout_p=conv_dropout_p, 168 | conv_kernel_size=conv_kernel_size, 169 | half_step_residual=half_step_residual, 170 | ) for _ in range(num_layers)]) 171 | 172 | def count_parameters(self) -> int: 173 | """ Count parameters of encoder """ 174 | return sum([p.numel() for p in self.parameters()]) 175 | 176 | def update_dropout(self, dropout_p: float) -> None: 177 | """ Update dropout probability of encoder """ 178 | for name, child in self.named_children(): 179 | if isinstance(child, nn.Dropout): 180 | child.p = dropout_p 181 | 182 | def forward(self, inputs: Tensor, input_lengths: Tensor) -> Tuple[Tensor, Tensor]: 183 | """ 184 | Forward propagate a `inputs` for encoder training. 185 | 186 | Args: 187 | inputs (torch.FloatTensor): A input sequence passed to encoder. Typically for inputs this will be a padded 188 | `FloatTensor` of size ``(batch, seq_length, dimension)``. 189 | input_lengths (torch.LongTensor): The length of input tensor. ``(batch)`` 190 | 191 | Returns: 192 | (Tensor, Tensor) 193 | 194 | * outputs (torch.FloatTensor): A output sequence of encoder. `FloatTensor` of size 195 | ``(batch, seq_length, dimension)`` 196 | * output_lengths (torch.LongTensor): The length of output tensor. ``(batch)`` 197 | """ 198 | outputs, output_lengths = self.conv_subsample(inputs, input_lengths) 199 | outputs = self.input_projection(outputs) 200 | 201 | for layer in self.layers: 202 | outputs = layer(outputs) 203 | 204 | return outputs, output_lengths 205 | -------------------------------------------------------------------------------- /conformer/feed_forward.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, Soohwan Kim. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import torch 16 | import torch.nn as nn 17 | from torch import Tensor 18 | 19 | from .activation import Swish 20 | from .modules import Linear 21 | 22 | 23 | class FeedForwardModule(nn.Module): 24 | """ 25 | Conformer Feed Forward Module follow pre-norm residual units and apply layer normalization within the residual unit 26 | and on the input before the first linear layer. This module also apply Swish activation and dropout, which helps 27 | regularizing the network. 28 | 29 | Args: 30 | encoder_dim (int): Dimension of conformer encoder 31 | expansion_factor (int): Expansion factor of feed forward module. 32 | dropout_p (float): Ratio of dropout 33 | 34 | Inputs: inputs 35 | - **inputs** (batch, time, dim): Tensor contains input sequences 36 | 37 | Outputs: outputs 38 | - **outputs** (batch, time, dim): Tensor produces by feed forward module. 39 | """ 40 | def __init__( 41 | self, 42 | encoder_dim: int = 512, 43 | expansion_factor: int = 4, 44 | dropout_p: float = 0.1, 45 | ) -> None: 46 | super(FeedForwardModule, self).__init__() 47 | self.sequential = nn.Sequential( 48 | nn.LayerNorm(encoder_dim), 49 | Linear(encoder_dim, encoder_dim * expansion_factor, bias=True), 50 | Swish(), 51 | nn.Dropout(p=dropout_p), 52 | Linear(encoder_dim * expansion_factor, encoder_dim, bias=True), 53 | nn.Dropout(p=dropout_p), 54 | ) 55 | 56 | def forward(self, inputs: Tensor) -> Tensor: 57 | return self.sequential(inputs) 58 | -------------------------------------------------------------------------------- /conformer/model.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, Soohwan Kim. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import torch 16 | import torch.nn as nn 17 | from torch import Tensor 18 | from typing import Tuple 19 | 20 | from .encoder import ConformerEncoder 21 | from .modules import Linear 22 | 23 | 24 | class Conformer(nn.Module): 25 | """ 26 | Conformer: Convolution-augmented Transformer for Speech Recognition 27 | The paper used a one-lstm Transducer decoder, currently still only implemented 28 | the conformer encoder shown in the paper. 29 | 30 | Args: 31 | num_classes (int): Number of classification classes 32 | input_dim (int, optional): Dimension of input vector 33 | encoder_dim (int, optional): Dimension of conformer encoder 34 | num_encoder_layers (int, optional): Number of conformer blocks 35 | num_attention_heads (int, optional): Number of attention heads 36 | feed_forward_expansion_factor (int, optional): Expansion factor of feed forward module 37 | conv_expansion_factor (int, optional): Expansion factor of conformer convolution module 38 | feed_forward_dropout_p (float, optional): Probability of feed forward module dropout 39 | attention_dropout_p (float, optional): Probability of attention module dropout 40 | conv_dropout_p (float, optional): Probability of conformer convolution module dropout 41 | conv_kernel_size (int or tuple, optional): Size of the convolving kernel 42 | half_step_residual (bool): Flag indication whether to use half step residual or not 43 | 44 | Inputs: inputs, input_lengths 45 | - **inputs** (batch, time, dim): Tensor containing input vector 46 | - **input_lengths** (batch): list of sequence input lengths 47 | 48 | Returns: outputs, output_lengths 49 | - **outputs** (batch, out_channels, time): Tensor produces by conformer. 50 | - **output_lengths** (batch): list of sequence output lengths 51 | """ 52 | def __init__( 53 | self, 54 | num_classes: int, 55 | input_dim: int = 80, 56 | encoder_dim: int = 512, 57 | num_encoder_layers: int = 17, 58 | num_attention_heads: int = 8, 59 | feed_forward_expansion_factor: int = 4, 60 | conv_expansion_factor: int = 2, 61 | input_dropout_p: float = 0.1, 62 | feed_forward_dropout_p: float = 0.1, 63 | attention_dropout_p: float = 0.1, 64 | conv_dropout_p: float = 0.1, 65 | conv_kernel_size: int = 31, 66 | half_step_residual: bool = True, 67 | ) -> None: 68 | super(Conformer, self).__init__() 69 | self.encoder = ConformerEncoder( 70 | input_dim=input_dim, 71 | encoder_dim=encoder_dim, 72 | num_layers=num_encoder_layers, 73 | num_attention_heads=num_attention_heads, 74 | feed_forward_expansion_factor=feed_forward_expansion_factor, 75 | conv_expansion_factor=conv_expansion_factor, 76 | input_dropout_p=input_dropout_p, 77 | feed_forward_dropout_p=feed_forward_dropout_p, 78 | attention_dropout_p=attention_dropout_p, 79 | conv_dropout_p=conv_dropout_p, 80 | conv_kernel_size=conv_kernel_size, 81 | half_step_residual=half_step_residual, 82 | ) 83 | self.fc = Linear(encoder_dim, num_classes, bias=False) 84 | 85 | def count_parameters(self) -> int: 86 | """ Count parameters of encoder """ 87 | return self.encoder.count_parameters() 88 | 89 | def update_dropout(self, dropout_p) -> None: 90 | """ Update dropout probability of model """ 91 | self.encoder.update_dropout(dropout_p) 92 | 93 | def forward(self, inputs: Tensor, input_lengths: Tensor) -> Tuple[Tensor, Tensor]: 94 | """ 95 | Forward propagate a `inputs` and `targets` pair for training. 96 | 97 | Args: 98 | inputs (torch.FloatTensor): A input sequence passed to encoder. Typically for inputs this will be a padded 99 | `FloatTensor` of size ``(batch, seq_length, dimension)``. 100 | input_lengths (torch.LongTensor): The length of input tensor. ``(batch)`` 101 | 102 | Returns: 103 | * predictions (torch.FloatTensor): Result of model predictions. 104 | """ 105 | encoder_outputs, encoder_output_lengths = self.encoder(inputs, input_lengths) 106 | outputs = self.fc(encoder_outputs) 107 | outputs = nn.functional.log_softmax(outputs, dim=-1) 108 | return outputs, encoder_output_lengths 109 | -------------------------------------------------------------------------------- /conformer/modules.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, Soohwan Kim. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import torch 16 | import torch.nn as nn 17 | import torch.nn.init as init 18 | from torch import Tensor 19 | 20 | 21 | class ResidualConnectionModule(nn.Module): 22 | """ 23 | Residual Connection Module. 24 | outputs = (module(inputs) x module_factor + inputs x input_factor) 25 | """ 26 | def __init__(self, module: nn.Module, module_factor: float = 1.0, input_factor: float = 1.0): 27 | super(ResidualConnectionModule, self).__init__() 28 | self.module = module 29 | self.module_factor = module_factor 30 | self.input_factor = input_factor 31 | 32 | def forward(self, inputs: Tensor) -> Tensor: 33 | return (self.module(inputs) * self.module_factor) + (inputs * self.input_factor) 34 | 35 | 36 | class Linear(nn.Module): 37 | """ 38 | Wrapper class of torch.nn.Linear 39 | Weight initialize by xavier initialization and bias initialize to zeros. 40 | """ 41 | def __init__(self, in_features: int, out_features: int, bias: bool = True) -> None: 42 | super(Linear, self).__init__() 43 | self.linear = nn.Linear(in_features, out_features, bias=bias) 44 | init.xavier_uniform_(self.linear.weight) 45 | if bias: 46 | init.zeros_(self.linear.bias) 47 | 48 | def forward(self, x: Tensor) -> Tensor: 49 | return self.linear(x) 50 | 51 | 52 | class View(nn.Module): 53 | """ Wrapper class of torch.view() for Sequential module. """ 54 | def __init__(self, shape: tuple, contiguous: bool = False): 55 | super(View, self).__init__() 56 | self.shape = shape 57 | self.contiguous = contiguous 58 | 59 | def forward(self, x: Tensor) -> Tensor: 60 | if self.contiguous: 61 | x = x.contiguous() 62 | 63 | return x.view(*self.shape) 64 | 65 | 66 | class Transpose(nn.Module): 67 | """ Wrapper class of torch.transpose() for Sequential module. """ 68 | def __init__(self, shape: tuple): 69 | super(Transpose, self).__init__() 70 | self.shape = shape 71 | 72 | def forward(self, x: Tensor) -> Tensor: 73 | return x.transpose(*self.shape) 74 | -------------------------------------------------------------------------------- /docs/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/.DS_Store -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/Model.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Model — conformer latest documentation 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |

50 | 51 | 106 | 107 |
108 | 109 | 110 | 116 | 117 | 118 |
119 | 120 |
121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 |
141 | 142 |
    143 | 144 |
  • »
  • 145 | 146 |
  • Model
  • 147 | 148 | 149 |
  • 150 | 151 | 152 | View page source 153 | 154 | 155 |
  • 156 | 157 |
158 | 159 | 160 |
161 |
162 |
163 |
164 | 165 |
166 |

Model

167 |
168 |

Conformer

169 |
170 |
171 |

Encoder

172 |
173 |
174 |

Decoder

175 |
176 |
177 | 178 | 179 |
180 | 181 |
182 | 206 |
207 |
208 | 209 |
210 | 211 |
212 | 213 | 214 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | -------------------------------------------------------------------------------- /docs/Modules.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Conformer Modules — conformer latest documentation 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |
50 | 51 | 106 | 107 |
108 | 109 | 110 | 116 | 117 | 118 |
119 | 120 |
121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 |
141 | 142 |
    143 | 144 |
  • »
  • 145 | 146 |
  • Conformer Modules
  • 147 | 148 | 149 |
  • 150 | 151 | 152 | View page source 153 | 154 | 155 |
  • 156 | 157 |
158 | 159 | 160 |
161 |
162 |
163 |
164 | 165 |
166 |

Conformer Modules

167 |
168 |

Attention

169 |
170 |
171 |

Convolution

172 |
173 |
174 |

Feed Forward

175 |
176 |
177 | 178 | 179 |
180 | 181 |
182 | 206 |
207 |
208 | 209 |
210 | 211 |
212 | 213 | 214 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | -------------------------------------------------------------------------------- /docs/Submodules.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Submodules — conformer latest documentation 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |
49 | 50 | 105 | 106 |
107 | 108 | 109 | 115 | 116 | 117 |
118 | 119 |
120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 |
140 | 141 |
    142 | 143 |
  • »
  • 144 | 145 |
  • Submodules
  • 146 | 147 | 148 |
  • 149 | 150 | 151 | View page source 152 | 153 | 154 |
  • 155 | 156 |
157 | 158 | 159 |
160 |
161 |
162 |
163 | 164 |
165 |

Submodules

166 |
167 |

Activation

168 |
169 |
170 |

Modules

171 |
172 |
173 |

Embedding

174 |
175 |
176 | 177 | 178 |
179 | 180 |
181 | 204 |
205 |
206 | 207 |
208 | 209 |
210 | 211 | 212 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | -------------------------------------------------------------------------------- /docs/_sources/Model.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | Model 3 | ===================================================== 4 | 5 | Conformer 6 | -------------------------------------------- 7 | 8 | .. automodule:: conformer.model 9 | :members: 10 | 11 | Encoder 12 | -------------------------------------------- 13 | 14 | .. automodule:: conformer.encoder 15 | :members: 16 | 17 | Decoder 18 | -------------------------------------------- 19 | 20 | .. automodule:: conformer.decoder 21 | :members: 22 | -------------------------------------------------------------------------------- /docs/_sources/Modules.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | Conformer Modules 3 | ===================================================== 4 | 5 | Attention 6 | -------------------------------------------- 7 | 8 | .. automodule:: conformer.attention 9 | :members: 10 | 11 | Convolution 12 | -------------------------------------------- 13 | 14 | .. automodule:: conformer.convolution 15 | :members: 16 | 17 | Feed Forward 18 | -------------------------------------------- 19 | 20 | .. automodule:: conformer.feed_forward 21 | :members: -------------------------------------------------------------------------------- /docs/_sources/Submodules.rst.txt: -------------------------------------------------------------------------------- 1 | 2 | Submodules 3 | ===================================================== 4 | 5 | Activation 6 | -------------------------------------------- 7 | 8 | .. automodule:: conformer.activation 9 | :members: 10 | 11 | Modules 12 | -------------------------------------------- 13 | 14 | .. automodule:: conformer.modules 15 | :members: 16 | 17 | Embedding 18 | -------------------------------------------- 19 | 20 | .. automodule:: conformer.embedding 21 | :members: -------------------------------------------------------------------------------- /docs/_sources/index.rst.txt: -------------------------------------------------------------------------------- 1 | .. conformer documentation master file, created by 2 | sphinx-quickstart on Sun Jan 24 01:16:16 2021. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to Conformer's documentation! 7 | ===================================== 8 | 9 | .. toctree:: 10 | :maxdepth: 1 11 | :caption: PACKAGE 12 | 13 | Model 14 | Modules 15 | Submodules 16 | 17 | 18 | 19 | Indices and tables 20 | ================== 21 | 22 | * :ref:`genindex` 23 | * :ref:`modindex` 24 | * :ref:`search` 25 | -------------------------------------------------------------------------------- /docs/_static/basic.css: -------------------------------------------------------------------------------- 1 | /* 2 | * basic.css 3 | * ~~~~~~~~~ 4 | * 5 | * Sphinx stylesheet -- basic theme. 6 | * 7 | * :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | /* -- main layout ----------------------------------------------------------- */ 13 | 14 | div.clearer { 15 | clear: both; 16 | } 17 | 18 | div.section::after { 19 | display: block; 20 | content: ''; 21 | clear: left; 22 | } 23 | 24 | /* -- relbar ---------------------------------------------------------------- */ 25 | 26 | div.related { 27 | width: 100%; 28 | font-size: 90%; 29 | } 30 | 31 | div.related h3 { 32 | display: none; 33 | } 34 | 35 | div.related ul { 36 | margin: 0; 37 | padding: 0 0 0 10px; 38 | list-style: none; 39 | } 40 | 41 | div.related li { 42 | display: inline; 43 | } 44 | 45 | div.related li.right { 46 | float: right; 47 | margin-right: 5px; 48 | } 49 | 50 | /* -- sidebar --------------------------------------------------------------- */ 51 | 52 | div.sphinxsidebarwrapper { 53 | padding: 10px 5px 0 10px; 54 | } 55 | 56 | div.sphinxsidebar { 57 | float: left; 58 | width: 230px; 59 | margin-left: -100%; 60 | font-size: 90%; 61 | word-wrap: break-word; 62 | overflow-wrap : break-word; 63 | } 64 | 65 | div.sphinxsidebar ul { 66 | list-style: none; 67 | } 68 | 69 | div.sphinxsidebar ul ul, 70 | div.sphinxsidebar ul.want-points { 71 | margin-left: 20px; 72 | list-style: square; 73 | } 74 | 75 | div.sphinxsidebar ul ul { 76 | margin-top: 0; 77 | margin-bottom: 0; 78 | } 79 | 80 | div.sphinxsidebar form { 81 | margin-top: 10px; 82 | } 83 | 84 | div.sphinxsidebar input { 85 | border: 1px solid #98dbcc; 86 | font-family: sans-serif; 87 | font-size: 1em; 88 | } 89 | 90 | div.sphinxsidebar #searchbox form.search { 91 | overflow: hidden; 92 | } 93 | 94 | div.sphinxsidebar #searchbox input[type="text"] { 95 | float: left; 96 | width: 80%; 97 | padding: 0.25em; 98 | box-sizing: border-box; 99 | } 100 | 101 | div.sphinxsidebar #searchbox input[type="submit"] { 102 | float: left; 103 | width: 20%; 104 | border-left: none; 105 | padding: 0.25em; 106 | box-sizing: border-box; 107 | } 108 | 109 | 110 | img { 111 | border: 0; 112 | max-width: 100%; 113 | } 114 | 115 | /* -- search page ----------------------------------------------------------- */ 116 | 117 | ul.search { 118 | margin: 10px 0 0 20px; 119 | padding: 0; 120 | } 121 | 122 | ul.search li { 123 | padding: 5px 0 5px 20px; 124 | background-image: url(file.png); 125 | background-repeat: no-repeat; 126 | background-position: 0 7px; 127 | } 128 | 129 | ul.search li a { 130 | font-weight: bold; 131 | } 132 | 133 | ul.search li div.context { 134 | color: #888; 135 | margin: 2px 0 0 30px; 136 | text-align: left; 137 | } 138 | 139 | ul.keywordmatches li.goodmatch a { 140 | font-weight: bold; 141 | } 142 | 143 | /* -- index page ------------------------------------------------------------ */ 144 | 145 | table.contentstable { 146 | width: 90%; 147 | margin-left: auto; 148 | margin-right: auto; 149 | } 150 | 151 | table.contentstable p.biglink { 152 | line-height: 150%; 153 | } 154 | 155 | a.biglink { 156 | font-size: 1.3em; 157 | } 158 | 159 | span.linkdescr { 160 | font-style: italic; 161 | padding-top: 5px; 162 | font-size: 90%; 163 | } 164 | 165 | /* -- general index --------------------------------------------------------- */ 166 | 167 | table.indextable { 168 | width: 100%; 169 | } 170 | 171 | table.indextable td { 172 | text-align: left; 173 | vertical-align: top; 174 | } 175 | 176 | table.indextable ul { 177 | margin-top: 0; 178 | margin-bottom: 0; 179 | list-style-type: none; 180 | } 181 | 182 | table.indextable > tbody > tr > td > ul { 183 | padding-left: 0em; 184 | } 185 | 186 | table.indextable tr.pcap { 187 | height: 10px; 188 | } 189 | 190 | table.indextable tr.cap { 191 | margin-top: 10px; 192 | background-color: #f2f2f2; 193 | } 194 | 195 | img.toggler { 196 | margin-right: 3px; 197 | margin-top: 3px; 198 | cursor: pointer; 199 | } 200 | 201 | div.modindex-jumpbox { 202 | border-top: 1px solid #ddd; 203 | border-bottom: 1px solid #ddd; 204 | margin: 1em 0 1em 0; 205 | padding: 0.4em; 206 | } 207 | 208 | div.genindex-jumpbox { 209 | border-top: 1px solid #ddd; 210 | border-bottom: 1px solid #ddd; 211 | margin: 1em 0 1em 0; 212 | padding: 0.4em; 213 | } 214 | 215 | /* -- domain module index --------------------------------------------------- */ 216 | 217 | table.modindextable td { 218 | padding: 2px; 219 | border-collapse: collapse; 220 | } 221 | 222 | /* -- general body styles --------------------------------------------------- */ 223 | 224 | div.body { 225 | min-width: 450px; 226 | max-width: 800px; 227 | } 228 | 229 | div.body p, div.body dd, div.body li, div.body blockquote { 230 | -moz-hyphens: auto; 231 | -ms-hyphens: auto; 232 | -webkit-hyphens: auto; 233 | hyphens: auto; 234 | } 235 | 236 | a.headerlink { 237 | visibility: hidden; 238 | } 239 | 240 | a.brackets:before, 241 | span.brackets > a:before{ 242 | content: "["; 243 | } 244 | 245 | a.brackets:after, 246 | span.brackets > a:after { 247 | content: "]"; 248 | } 249 | 250 | h1:hover > a.headerlink, 251 | h2:hover > a.headerlink, 252 | h3:hover > a.headerlink, 253 | h4:hover > a.headerlink, 254 | h5:hover > a.headerlink, 255 | h6:hover > a.headerlink, 256 | dt:hover > a.headerlink, 257 | caption:hover > a.headerlink, 258 | p.caption:hover > a.headerlink, 259 | div.code-block-caption:hover > a.headerlink { 260 | visibility: visible; 261 | } 262 | 263 | div.body p.caption { 264 | text-align: inherit; 265 | } 266 | 267 | div.body td { 268 | text-align: left; 269 | } 270 | 271 | .first { 272 | margin-top: 0 !important; 273 | } 274 | 275 | p.rubric { 276 | margin-top: 30px; 277 | font-weight: bold; 278 | } 279 | 280 | img.align-left, .figure.align-left, object.align-left { 281 | clear: left; 282 | float: left; 283 | margin-right: 1em; 284 | } 285 | 286 | img.align-right, .figure.align-right, object.align-right { 287 | clear: right; 288 | float: right; 289 | margin-left: 1em; 290 | } 291 | 292 | img.align-center, .figure.align-center, object.align-center { 293 | display: block; 294 | margin-left: auto; 295 | margin-right: auto; 296 | } 297 | 298 | img.align-default, .figure.align-default { 299 | display: block; 300 | margin-left: auto; 301 | margin-right: auto; 302 | } 303 | 304 | .align-left { 305 | text-align: left; 306 | } 307 | 308 | .align-center { 309 | text-align: center; 310 | } 311 | 312 | .align-default { 313 | text-align: center; 314 | } 315 | 316 | .align-right { 317 | text-align: right; 318 | } 319 | 320 | /* -- sidebars -------------------------------------------------------------- */ 321 | 322 | div.sidebar { 323 | margin: 0 0 0.5em 1em; 324 | border: 1px solid #ddb; 325 | padding: 7px; 326 | background-color: #ffe; 327 | width: 40%; 328 | float: right; 329 | clear: right; 330 | overflow-x: auto; 331 | } 332 | 333 | p.sidebar-title { 334 | font-weight: bold; 335 | } 336 | 337 | div.admonition, div.topic, blockquote { 338 | clear: left; 339 | } 340 | 341 | /* -- topics ---------------------------------------------------------------- */ 342 | 343 | div.topic { 344 | border: 1px solid #ccc; 345 | padding: 7px; 346 | margin: 10px 0 10px 0; 347 | } 348 | 349 | p.topic-title { 350 | font-size: 1.1em; 351 | font-weight: bold; 352 | margin-top: 10px; 353 | } 354 | 355 | /* -- admonitions ----------------------------------------------------------- */ 356 | 357 | div.admonition { 358 | margin-top: 10px; 359 | margin-bottom: 10px; 360 | padding: 7px; 361 | } 362 | 363 | div.admonition dt { 364 | font-weight: bold; 365 | } 366 | 367 | p.admonition-title { 368 | margin: 0px 10px 5px 0px; 369 | font-weight: bold; 370 | } 371 | 372 | div.body p.centered { 373 | text-align: center; 374 | margin-top: 25px; 375 | } 376 | 377 | /* -- content of sidebars/topics/admonitions -------------------------------- */ 378 | 379 | div.sidebar > :last-child, 380 | div.topic > :last-child, 381 | div.admonition > :last-child { 382 | margin-bottom: 0; 383 | } 384 | 385 | div.sidebar::after, 386 | div.topic::after, 387 | div.admonition::after, 388 | blockquote::after { 389 | display: block; 390 | content: ''; 391 | clear: both; 392 | } 393 | 394 | /* -- tables ---------------------------------------------------------------- */ 395 | 396 | table.docutils { 397 | margin-top: 10px; 398 | margin-bottom: 10px; 399 | border: 0; 400 | border-collapse: collapse; 401 | } 402 | 403 | table.align-center { 404 | margin-left: auto; 405 | margin-right: auto; 406 | } 407 | 408 | table.align-default { 409 | margin-left: auto; 410 | margin-right: auto; 411 | } 412 | 413 | table caption span.caption-number { 414 | font-style: italic; 415 | } 416 | 417 | table caption span.caption-text { 418 | } 419 | 420 | table.docutils td, table.docutils th { 421 | padding: 1px 8px 1px 5px; 422 | border-top: 0; 423 | border-left: 0; 424 | border-right: 0; 425 | border-bottom: 1px solid #aaa; 426 | } 427 | 428 | table.footnote td, table.footnote th { 429 | border: 0 !important; 430 | } 431 | 432 | th { 433 | text-align: left; 434 | padding-right: 5px; 435 | } 436 | 437 | table.citation { 438 | border-left: solid 1px gray; 439 | margin-left: 1px; 440 | } 441 | 442 | table.citation td { 443 | border-bottom: none; 444 | } 445 | 446 | th > :first-child, 447 | td > :first-child { 448 | margin-top: 0px; 449 | } 450 | 451 | th > :last-child, 452 | td > :last-child { 453 | margin-bottom: 0px; 454 | } 455 | 456 | /* -- figures --------------------------------------------------------------- */ 457 | 458 | div.figure { 459 | margin: 0.5em; 460 | padding: 0.5em; 461 | } 462 | 463 | div.figure p.caption { 464 | padding: 0.3em; 465 | } 466 | 467 | div.figure p.caption span.caption-number { 468 | font-style: italic; 469 | } 470 | 471 | div.figure p.caption span.caption-text { 472 | } 473 | 474 | /* -- field list styles ----------------------------------------------------- */ 475 | 476 | table.field-list td, table.field-list th { 477 | border: 0 !important; 478 | } 479 | 480 | .field-list ul { 481 | margin: 0; 482 | padding-left: 1em; 483 | } 484 | 485 | .field-list p { 486 | margin: 0; 487 | } 488 | 489 | .field-name { 490 | -moz-hyphens: manual; 491 | -ms-hyphens: manual; 492 | -webkit-hyphens: manual; 493 | hyphens: manual; 494 | } 495 | 496 | /* -- hlist styles ---------------------------------------------------------- */ 497 | 498 | table.hlist { 499 | margin: 1em 0; 500 | } 501 | 502 | table.hlist td { 503 | vertical-align: top; 504 | } 505 | 506 | 507 | /* -- other body styles ----------------------------------------------------- */ 508 | 509 | ol.arabic { 510 | list-style: decimal; 511 | } 512 | 513 | ol.loweralpha { 514 | list-style: lower-alpha; 515 | } 516 | 517 | ol.upperalpha { 518 | list-style: upper-alpha; 519 | } 520 | 521 | ol.lowerroman { 522 | list-style: lower-roman; 523 | } 524 | 525 | ol.upperroman { 526 | list-style: upper-roman; 527 | } 528 | 529 | :not(li) > ol > li:first-child > :first-child, 530 | :not(li) > ul > li:first-child > :first-child { 531 | margin-top: 0px; 532 | } 533 | 534 | :not(li) > ol > li:last-child > :last-child, 535 | :not(li) > ul > li:last-child > :last-child { 536 | margin-bottom: 0px; 537 | } 538 | 539 | ol.simple ol p, 540 | ol.simple ul p, 541 | ul.simple ol p, 542 | ul.simple ul p { 543 | margin-top: 0; 544 | } 545 | 546 | ol.simple > li:not(:first-child) > p, 547 | ul.simple > li:not(:first-child) > p { 548 | margin-top: 0; 549 | } 550 | 551 | ol.simple p, 552 | ul.simple p { 553 | margin-bottom: 0; 554 | } 555 | 556 | dl.footnote > dt, 557 | dl.citation > dt { 558 | float: left; 559 | margin-right: 0.5em; 560 | } 561 | 562 | dl.footnote > dd, 563 | dl.citation > dd { 564 | margin-bottom: 0em; 565 | } 566 | 567 | dl.footnote > dd:after, 568 | dl.citation > dd:after { 569 | content: ""; 570 | clear: both; 571 | } 572 | 573 | dl.field-list { 574 | display: grid; 575 | grid-template-columns: fit-content(30%) auto; 576 | } 577 | 578 | dl.field-list > dt { 579 | font-weight: bold; 580 | word-break: break-word; 581 | padding-left: 0.5em; 582 | padding-right: 5px; 583 | } 584 | 585 | dl.field-list > dt:after { 586 | content: ":"; 587 | } 588 | 589 | dl.field-list > dd { 590 | padding-left: 0.5em; 591 | margin-top: 0em; 592 | margin-left: 0em; 593 | margin-bottom: 0em; 594 | } 595 | 596 | dl { 597 | margin-bottom: 15px; 598 | } 599 | 600 | dd > :first-child { 601 | margin-top: 0px; 602 | } 603 | 604 | dd ul, dd table { 605 | margin-bottom: 10px; 606 | } 607 | 608 | dd { 609 | margin-top: 3px; 610 | margin-bottom: 10px; 611 | margin-left: 30px; 612 | } 613 | 614 | dl > dd:last-child, 615 | dl > dd:last-child > :last-child { 616 | margin-bottom: 0; 617 | } 618 | 619 | dt:target, span.highlighted { 620 | background-color: #fbe54e; 621 | } 622 | 623 | rect.highlighted { 624 | fill: #fbe54e; 625 | } 626 | 627 | dl.glossary dt { 628 | font-weight: bold; 629 | font-size: 1.1em; 630 | } 631 | 632 | .optional { 633 | font-size: 1.3em; 634 | } 635 | 636 | .sig-paren { 637 | font-size: larger; 638 | } 639 | 640 | .versionmodified { 641 | font-style: italic; 642 | } 643 | 644 | .system-message { 645 | background-color: #fda; 646 | padding: 5px; 647 | border: 3px solid red; 648 | } 649 | 650 | .footnote:target { 651 | background-color: #ffa; 652 | } 653 | 654 | .line-block { 655 | display: block; 656 | margin-top: 1em; 657 | margin-bottom: 1em; 658 | } 659 | 660 | .line-block .line-block { 661 | margin-top: 0; 662 | margin-bottom: 0; 663 | margin-left: 1.5em; 664 | } 665 | 666 | .guilabel, .menuselection { 667 | font-family: sans-serif; 668 | } 669 | 670 | .accelerator { 671 | text-decoration: underline; 672 | } 673 | 674 | .classifier { 675 | font-style: oblique; 676 | } 677 | 678 | .classifier:before { 679 | font-style: normal; 680 | margin: 0.5em; 681 | content: ":"; 682 | } 683 | 684 | abbr, acronym { 685 | border-bottom: dotted 1px; 686 | cursor: help; 687 | } 688 | 689 | /* -- code displays --------------------------------------------------------- */ 690 | 691 | pre { 692 | overflow: auto; 693 | overflow-y: hidden; /* fixes display issues on Chrome browsers */ 694 | } 695 | 696 | pre, div[class*="highlight-"] { 697 | clear: both; 698 | } 699 | 700 | span.pre { 701 | -moz-hyphens: none; 702 | -ms-hyphens: none; 703 | -webkit-hyphens: none; 704 | hyphens: none; 705 | } 706 | 707 | div[class*="highlight-"] { 708 | margin: 1em 0; 709 | } 710 | 711 | td.linenos pre { 712 | border: 0; 713 | background-color: transparent; 714 | color: #aaa; 715 | } 716 | 717 | table.highlighttable { 718 | display: block; 719 | } 720 | 721 | table.highlighttable tbody { 722 | display: block; 723 | } 724 | 725 | table.highlighttable tr { 726 | display: flex; 727 | } 728 | 729 | table.highlighttable td { 730 | margin: 0; 731 | padding: 0; 732 | } 733 | 734 | table.highlighttable td.linenos { 735 | padding-right: 0.5em; 736 | } 737 | 738 | table.highlighttable td.code { 739 | flex: 1; 740 | overflow: hidden; 741 | } 742 | 743 | .highlight .hll { 744 | display: block; 745 | } 746 | 747 | div.highlight pre, 748 | table.highlighttable pre { 749 | margin: 0; 750 | } 751 | 752 | div.code-block-caption + div { 753 | margin-top: 0; 754 | } 755 | 756 | div.code-block-caption { 757 | margin-top: 1em; 758 | padding: 2px 5px; 759 | font-size: small; 760 | } 761 | 762 | div.code-block-caption code { 763 | background-color: transparent; 764 | } 765 | 766 | table.highlighttable td.linenos, 767 | div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */ 768 | user-select: none; 769 | } 770 | 771 | div.code-block-caption span.caption-number { 772 | padding: 0.1em 0.3em; 773 | font-style: italic; 774 | } 775 | 776 | div.code-block-caption span.caption-text { 777 | } 778 | 779 | div.literal-block-wrapper { 780 | margin: 1em 0; 781 | } 782 | 783 | code.descname { 784 | background-color: transparent; 785 | font-weight: bold; 786 | font-size: 1.2em; 787 | } 788 | 789 | code.descclassname { 790 | background-color: transparent; 791 | } 792 | 793 | code.xref, a code { 794 | background-color: transparent; 795 | font-weight: bold; 796 | } 797 | 798 | h1 code, h2 code, h3 code, h4 code, h5 code, h6 code { 799 | background-color: transparent; 800 | } 801 | 802 | .viewcode-link { 803 | float: right; 804 | } 805 | 806 | .viewcode-back { 807 | float: right; 808 | font-family: sans-serif; 809 | } 810 | 811 | div.viewcode-block:target { 812 | margin: -1px -10px; 813 | padding: 0 10px; 814 | } 815 | 816 | /* -- math display ---------------------------------------------------------- */ 817 | 818 | img.math { 819 | vertical-align: middle; 820 | } 821 | 822 | div.body div.math p { 823 | text-align: center; 824 | } 825 | 826 | span.eqno { 827 | float: right; 828 | } 829 | 830 | span.eqno a.headerlink { 831 | position: absolute; 832 | z-index: 1; 833 | } 834 | 835 | div.math:hover a.headerlink { 836 | visibility: visible; 837 | } 838 | 839 | /* -- printout stylesheet --------------------------------------------------- */ 840 | 841 | @media print { 842 | div.document, 843 | div.documentwrapper, 844 | div.bodywrapper { 845 | margin: 0 !important; 846 | width: 100%; 847 | } 848 | 849 | div.sphinxsidebar, 850 | div.related, 851 | div.footer, 852 | #top-link { 853 | display: none; 854 | } 855 | } -------------------------------------------------------------------------------- /docs/_static/css/badge_only.css: -------------------------------------------------------------------------------- 1 | .fa:before{-webkit-font-smoothing:antialiased}.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-style:normal;font-weight:400;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#FontAwesome) format("svg")}.fa:before{font-family:FontAwesome;font-style:normal;font-weight:400;line-height:1}.fa:before,a .fa{text-decoration:inherit}.fa:before,a .fa,li .fa{display:inline-block}li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before,.icon-book:before{content:"\f02d"}.fa-caret-down:before,.icon-caret-down:before{content:"\f0d7"}.fa-caret-up:before,.icon-caret-up:before{content:"\f0d8"}.fa-caret-left:before,.icon-caret-left:before{content:"\f0d9"}.fa-caret-right:before,.icon-caret-right:before{content:"\f0da"}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60}.rst-versions .rst-current-version:after{clear:both;content:"";display:block}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}} -------------------------------------------------------------------------------- /docs/_static/css/fonts/Roboto-Slab-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/css/fonts/Roboto-Slab-Bold.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/Roboto-Slab-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/css/fonts/Roboto-Slab-Bold.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/Roboto-Slab-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/css/fonts/Roboto-Slab-Regular.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/Roboto-Slab-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/css/fonts/Roboto-Slab-Regular.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/css/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /docs/_static/css/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/css/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /docs/_static/css/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/css/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/css/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-bold-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/css/fonts/lato-bold-italic.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-bold-italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/css/fonts/lato-bold-italic.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/css/fonts/lato-bold.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/css/fonts/lato-bold.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-normal-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/css/fonts/lato-normal-italic.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-normal-italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/css/fonts/lato-normal-italic.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-normal.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/css/fonts/lato-normal.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-normal.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/css/fonts/lato-normal.woff2 -------------------------------------------------------------------------------- /docs/_static/doctools.js: -------------------------------------------------------------------------------- 1 | /* 2 | * doctools.js 3 | * ~~~~~~~~~~~ 4 | * 5 | * Sphinx JavaScript utilities for all documentation. 6 | * 7 | * :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | /** 13 | * select a different prefix for underscore 14 | */ 15 | $u = _.noConflict(); 16 | 17 | /** 18 | * make the code below compatible with browsers without 19 | * an installed firebug like debugger 20 | if (!window.console || !console.firebug) { 21 | var names = ["log", "debug", "info", "warn", "error", "assert", "dir", 22 | "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", 23 | "profile", "profileEnd"]; 24 | window.console = {}; 25 | for (var i = 0; i < names.length; ++i) 26 | window.console[names[i]] = function() {}; 27 | } 28 | */ 29 | 30 | /** 31 | * small helper function to urldecode strings 32 | */ 33 | jQuery.urldecode = function(x) { 34 | return decodeURIComponent(x).replace(/\+/g, ' '); 35 | }; 36 | 37 | /** 38 | * small helper function to urlencode strings 39 | */ 40 | jQuery.urlencode = encodeURIComponent; 41 | 42 | /** 43 | * This function returns the parsed url parameters of the 44 | * current request. Multiple values per key are supported, 45 | * it will always return arrays of strings for the value parts. 46 | */ 47 | jQuery.getQueryParameters = function(s) { 48 | if (typeof s === 'undefined') 49 | s = document.location.search; 50 | var parts = s.substr(s.indexOf('?') + 1).split('&'); 51 | var result = {}; 52 | for (var i = 0; i < parts.length; i++) { 53 | var tmp = parts[i].split('=', 2); 54 | var key = jQuery.urldecode(tmp[0]); 55 | var value = jQuery.urldecode(tmp[1]); 56 | if (key in result) 57 | result[key].push(value); 58 | else 59 | result[key] = [value]; 60 | } 61 | return result; 62 | }; 63 | 64 | /** 65 | * highlight a given string on a jquery object by wrapping it in 66 | * span elements with the given class name. 67 | */ 68 | jQuery.fn.highlightText = function(text, className) { 69 | function highlight(node, addItems) { 70 | if (node.nodeType === 3) { 71 | var val = node.nodeValue; 72 | var pos = val.toLowerCase().indexOf(text); 73 | if (pos >= 0 && 74 | !jQuery(node.parentNode).hasClass(className) && 75 | !jQuery(node.parentNode).hasClass("nohighlight")) { 76 | var span; 77 | var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg"); 78 | if (isInSVG) { 79 | span = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); 80 | } else { 81 | span = document.createElement("span"); 82 | span.className = className; 83 | } 84 | span.appendChild(document.createTextNode(val.substr(pos, text.length))); 85 | node.parentNode.insertBefore(span, node.parentNode.insertBefore( 86 | document.createTextNode(val.substr(pos + text.length)), 87 | node.nextSibling)); 88 | node.nodeValue = val.substr(0, pos); 89 | if (isInSVG) { 90 | var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect"); 91 | var bbox = node.parentElement.getBBox(); 92 | rect.x.baseVal.value = bbox.x; 93 | rect.y.baseVal.value = bbox.y; 94 | rect.width.baseVal.value = bbox.width; 95 | rect.height.baseVal.value = bbox.height; 96 | rect.setAttribute('class', className); 97 | addItems.push({ 98 | "parent": node.parentNode, 99 | "target": rect}); 100 | } 101 | } 102 | } 103 | else if (!jQuery(node).is("button, select, textarea")) { 104 | jQuery.each(node.childNodes, function() { 105 | highlight(this, addItems); 106 | }); 107 | } 108 | } 109 | var addItems = []; 110 | var result = this.each(function() { 111 | highlight(this, addItems); 112 | }); 113 | for (var i = 0; i < addItems.length; ++i) { 114 | jQuery(addItems[i].parent).before(addItems[i].target); 115 | } 116 | return result; 117 | }; 118 | 119 | /* 120 | * backward compatibility for jQuery.browser 121 | * This will be supported until firefox bug is fixed. 122 | */ 123 | if (!jQuery.browser) { 124 | jQuery.uaMatch = function(ua) { 125 | ua = ua.toLowerCase(); 126 | 127 | var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || 128 | /(webkit)[ \/]([\w.]+)/.exec(ua) || 129 | /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || 130 | /(msie) ([\w.]+)/.exec(ua) || 131 | ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || 132 | []; 133 | 134 | return { 135 | browser: match[ 1 ] || "", 136 | version: match[ 2 ] || "0" 137 | }; 138 | }; 139 | jQuery.browser = {}; 140 | jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true; 141 | } 142 | 143 | /** 144 | * Small JavaScript module for the documentation. 145 | */ 146 | var Documentation = { 147 | 148 | init : function() { 149 | this.fixFirefoxAnchorBug(); 150 | this.highlightSearchWords(); 151 | this.initIndexTable(); 152 | if (DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) { 153 | this.initOnKeyListeners(); 154 | } 155 | }, 156 | 157 | /** 158 | * i18n support 159 | */ 160 | TRANSLATIONS : {}, 161 | PLURAL_EXPR : function(n) { return n === 1 ? 0 : 1; }, 162 | LOCALE : 'unknown', 163 | 164 | // gettext and ngettext don't access this so that the functions 165 | // can safely bound to a different name (_ = Documentation.gettext) 166 | gettext : function(string) { 167 | var translated = Documentation.TRANSLATIONS[string]; 168 | if (typeof translated === 'undefined') 169 | return string; 170 | return (typeof translated === 'string') ? translated : translated[0]; 171 | }, 172 | 173 | ngettext : function(singular, plural, n) { 174 | var translated = Documentation.TRANSLATIONS[singular]; 175 | if (typeof translated === 'undefined') 176 | return (n == 1) ? singular : plural; 177 | return translated[Documentation.PLURALEXPR(n)]; 178 | }, 179 | 180 | addTranslations : function(catalog) { 181 | for (var key in catalog.messages) 182 | this.TRANSLATIONS[key] = catalog.messages[key]; 183 | this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')'); 184 | this.LOCALE = catalog.locale; 185 | }, 186 | 187 | /** 188 | * add context elements like header anchor links 189 | */ 190 | addContextElements : function() { 191 | $('div[id] > :header:first').each(function() { 192 | $('\u00B6'). 193 | attr('href', '#' + this.id). 194 | attr('title', _('Permalink to this headline')). 195 | appendTo(this); 196 | }); 197 | $('dt[id]').each(function() { 198 | $('\u00B6'). 199 | attr('href', '#' + this.id). 200 | attr('title', _('Permalink to this definition')). 201 | appendTo(this); 202 | }); 203 | }, 204 | 205 | /** 206 | * workaround a firefox stupidity 207 | * see: https://bugzilla.mozilla.org/show_bug.cgi?id=645075 208 | */ 209 | fixFirefoxAnchorBug : function() { 210 | if (document.location.hash && $.browser.mozilla) 211 | window.setTimeout(function() { 212 | document.location.href += ''; 213 | }, 10); 214 | }, 215 | 216 | /** 217 | * highlight the search words provided in the url in the text 218 | */ 219 | highlightSearchWords : function() { 220 | var params = $.getQueryParameters(); 221 | var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; 222 | if (terms.length) { 223 | var body = $('div.body'); 224 | if (!body.length) { 225 | body = $('body'); 226 | } 227 | window.setTimeout(function() { 228 | $.each(terms, function() { 229 | body.highlightText(this.toLowerCase(), 'highlighted'); 230 | }); 231 | }, 10); 232 | $('') 234 | .appendTo($('#searchbox')); 235 | } 236 | }, 237 | 238 | /** 239 | * init the domain index toggle buttons 240 | */ 241 | initIndexTable : function() { 242 | var togglers = $('img.toggler').click(function() { 243 | var src = $(this).attr('src'); 244 | var idnum = $(this).attr('id').substr(7); 245 | $('tr.cg-' + idnum).toggle(); 246 | if (src.substr(-9) === 'minus.png') 247 | $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); 248 | else 249 | $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); 250 | }).css('display', ''); 251 | if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { 252 | togglers.click(); 253 | } 254 | }, 255 | 256 | /** 257 | * helper function to hide the search marks again 258 | */ 259 | hideSearchWords : function() { 260 | $('#searchbox .highlight-link').fadeOut(300); 261 | $('span.highlighted').removeClass('highlighted'); 262 | }, 263 | 264 | /** 265 | * make the url absolute 266 | */ 267 | makeURL : function(relativeURL) { 268 | return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL; 269 | }, 270 | 271 | /** 272 | * get the current relative url 273 | */ 274 | getCurrentURL : function() { 275 | var path = document.location.pathname; 276 | var parts = path.split(/\//); 277 | $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { 278 | if (this === '..') 279 | parts.pop(); 280 | }); 281 | var url = parts.join('/'); 282 | return path.substring(url.lastIndexOf('/') + 1, path.length - 1); 283 | }, 284 | 285 | initOnKeyListeners: function() { 286 | $(document).keydown(function(event) { 287 | var activeElementType = document.activeElement.tagName; 288 | // don't navigate when in search box or textarea 289 | if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT' 290 | && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) { 291 | switch (event.keyCode) { 292 | case 37: // left 293 | var prevHref = $('link[rel="prev"]').prop('href'); 294 | if (prevHref) { 295 | window.location.href = prevHref; 296 | return false; 297 | } 298 | case 39: // right 299 | var nextHref = $('link[rel="next"]').prop('href'); 300 | if (nextHref) { 301 | window.location.href = nextHref; 302 | return false; 303 | } 304 | } 305 | } 306 | }); 307 | } 308 | }; 309 | 310 | // quick alias for translations 311 | _ = Documentation.gettext; 312 | 313 | $(document).ready(function() { 314 | Documentation.init(); 315 | }); 316 | -------------------------------------------------------------------------------- /docs/_static/documentation_options.js: -------------------------------------------------------------------------------- 1 | var DOCUMENTATION_OPTIONS = { 2 | URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), 3 | VERSION: 'latest', 4 | LANGUAGE: 'None', 5 | COLLAPSE_INDEX: false, 6 | BUILDER: 'html', 7 | FILE_SUFFIX: '.html', 8 | LINK_SUFFIX: '.html', 9 | HAS_SOURCE: true, 10 | SOURCELINK_SUFFIX: '.txt', 11 | NAVIGATION_WITH_KEYS: false 12 | }; -------------------------------------------------------------------------------- /docs/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/file.png -------------------------------------------------------------------------------- /docs/_static/js/badge_only.js: -------------------------------------------------------------------------------- 1 | !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}({4:function(e,t,r){}}); -------------------------------------------------------------------------------- /docs/_static/js/html5shiv-printshiv.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve HTML5 Shiv 3.7.3-pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=y.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=y.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),y.elements=c+" "+a,j(b)}function f(a){var b=x[a[v]];return b||(b={},w++,a[v]=w,x[w]=b),b}function g(a,c,d){if(c||(c=b),q)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():u.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||t.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),q)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return y.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(y,b.frag)}function j(a){a||(a=b);var d=f(a);return!y.shivCSS||p||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),q||i(a,d),a}function k(a){for(var b,c=a.getElementsByTagName("*"),e=c.length,f=RegExp("^(?:"+d().join("|")+")$","i"),g=[];e--;)b=c[e],f.test(b.nodeName)&&g.push(b.applyElement(l(b)));return g}function l(a){for(var b,c=a.attributes,d=c.length,e=a.ownerDocument.createElement(A+":"+a.nodeName);d--;)b=c[d],b.specified&&e.setAttribute(b.nodeName,b.nodeValue);return e.style.cssText=a.style.cssText,e}function m(a){for(var b,c=a.split("{"),e=c.length,f=RegExp("(^|[\\s,>+~])("+d().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),g="$1"+A+"\\:$2";e--;)b=c[e]=c[e].split("}"),b[b.length-1]=b[b.length-1].replace(f,g),c[e]=b.join("}");return c.join("{")}function n(a){for(var b=a.length;b--;)a[b].removeNode()}function o(a){function b(){clearTimeout(g._removeSheetTimer),d&&d.removeNode(!0),d=null}var d,e,g=f(a),h=a.namespaces,i=a.parentWindow;return!B||a.printShived?a:("undefined"==typeof h[A]&&h.add(A),i.attachEvent("onbeforeprint",function(){b();for(var f,g,h,i=a.styleSheets,j=[],l=i.length,n=Array(l);l--;)n[l]=i[l];for(;h=n.pop();)if(!h.disabled&&z.test(h.media)){try{f=h.imports,g=f.length}catch(o){g=0}for(l=0;g>l;l++)n.push(f[l]);try{j.push(h.cssText)}catch(o){}}j=m(j.reverse().join("")),e=k(a),d=c(a,j)}),i.attachEvent("onafterprint",function(){n(e),clearTimeout(g._removeSheetTimer),g._removeSheetTimer=setTimeout(b,500)}),a.printShived=!0,a)}var p,q,r="3.7.3",s=a.html5||{},t=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,u=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,v="_html5shiv",w=0,x={};!function(){try{var a=b.createElement("a");a.innerHTML="",p="hidden"in a,q=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){p=!0,q=!0}}();var y={elements:s.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:r,shivCSS:s.shivCSS!==!1,supportsUnknownElements:q,shivMethods:s.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=y,j(b);var z=/^$|\b(?:all|print)\b/,A="html5shiv",B=!q&&function(){var c=b.documentElement;return!("undefined"==typeof b.namespaces||"undefined"==typeof b.parentWindow||"undefined"==typeof c.applyElement||"undefined"==typeof c.removeNode||"undefined"==typeof a.attachEvent)}();y.type+=" print",y.shivPrint=o,o(b),"object"==typeof module&&module.exports&&(module.exports=y)}("undefined"!=typeof window?window:this,document); -------------------------------------------------------------------------------- /docs/_static/js/html5shiv.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3-pre",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document); -------------------------------------------------------------------------------- /docs/_static/js/theme.js: -------------------------------------------------------------------------------- 1 | !function(n){var e={};function t(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return n[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=n,t.c=e,t.d=function(n,e,i){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:i})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var i=Object.create(null);if(t.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)t.d(i,o,function(e){return n[e]}.bind(null,o));return i},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){t(1),n.exports=t(3)},function(n,e,t){(function(){var e="undefined"!=typeof window?window.jQuery:t(2);n.exports.ThemeNav={navBar:null,win:null,winScroll:!1,winResize:!1,linkScroll:!1,winPosition:0,winHeight:null,docHeight:null,isRunning:!1,enable:function(n){var t=this;void 0===n&&(n=!0),t.isRunning||(t.isRunning=!0,e((function(e){t.init(e),t.reset(),t.win.on("hashchange",t.reset),n&&t.win.on("scroll",(function(){t.linkScroll||t.winScroll||(t.winScroll=!0,requestAnimationFrame((function(){t.onScroll()})))})),t.win.on("resize",(function(){t.winResize||(t.winResize=!0,requestAnimationFrame((function(){t.onResize()})))})),t.onResize()})))},enableSticky:function(){this.enable(!0)},init:function(n){n(document);var e=this;this.navBar=n("div.wy-side-scroll:first"),this.win=n(window),n(document).on("click","[data-toggle='wy-nav-top']",(function(){n("[data-toggle='wy-nav-shift']").toggleClass("shift"),n("[data-toggle='rst-versions']").toggleClass("shift")})).on("click",".wy-menu-vertical .current ul li a",(function(){var t=n(this);n("[data-toggle='wy-nav-shift']").removeClass("shift"),n("[data-toggle='rst-versions']").toggleClass("shift"),e.toggleCurrent(t),e.hashChange()})).on("click","[data-toggle='rst-current-version']",(function(){n("[data-toggle='rst-versions']").toggleClass("shift-up")})),n("table.docutils:not(.field-list,.footnote,.citation)").wrap("
"),n("table.docutils.footnote").wrap("
"),n("table.docutils.citation").wrap("
"),n(".wy-menu-vertical ul").not(".simple").siblings("a").each((function(){var t=n(this);expand=n(''),expand.on("click",(function(n){return e.toggleCurrent(t),n.stopPropagation(),!1})),t.prepend(expand)}))},reset:function(){var n=encodeURI(window.location.hash)||"#";try{var e=$(".wy-menu-vertical"),t=e.find('[href="'+n+'"]');if(0===t.length){var i=$('.document [id="'+n.substring(1)+'"]').closest("div.section");0===(t=e.find('[href="#'+i.attr("id")+'"]')).length&&(t=e.find('[href="#"]'))}t.length>0&&($(".wy-menu-vertical .current").removeClass("current"),t.addClass("current"),t.closest("li.toctree-l1").addClass("current"),t.closest("li.toctree-l1").parent().addClass("current"),t.closest("li.toctree-l1").addClass("current"),t.closest("li.toctree-l2").addClass("current"),t.closest("li.toctree-l3").addClass("current"),t.closest("li.toctree-l4").addClass("current"),t.closest("li.toctree-l5").addClass("current"),t[0].scrollIntoView())}catch(n){console.log("Error expanding nav for anchor",n)}},onScroll:function(){this.winScroll=!1;var n=this.win.scrollTop(),e=n+this.winHeight,t=this.navBar.scrollTop()+(n-this.winPosition);n<0||e>this.docHeight||(this.navBar.scrollTop(t),this.winPosition=n)},onResize:function(){this.winResize=!1,this.winHeight=this.win.height(),this.docHeight=$(document).height()},hashChange:function(){this.linkScroll=!0,this.win.one("hashchange",(function(){this.linkScroll=!1}))},toggleCurrent:function(n){var e=n.closest("li");e.siblings("li.current").removeClass("current"),e.siblings().find("li.current").removeClass("current"),e.find("> ul li.current").removeClass("current"),e.toggleClass("current")}},"undefined"!=typeof window&&(window.SphinxRtdTheme={Navigation:n.exports.ThemeNav,StickyNav:n.exports.ThemeNav}),function(){for(var n=0,e=["ms","moz","webkit","o"],t=0;t0 62 | var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1 63 | var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1 64 | var s_v = "^(" + C + ")?" + v; // vowel in stem 65 | 66 | this.stemWord = function (w) { 67 | var stem; 68 | var suffix; 69 | var firstch; 70 | var origword = w; 71 | 72 | if (w.length < 3) 73 | return w; 74 | 75 | var re; 76 | var re2; 77 | var re3; 78 | var re4; 79 | 80 | firstch = w.substr(0,1); 81 | if (firstch == "y") 82 | w = firstch.toUpperCase() + w.substr(1); 83 | 84 | // Step 1a 85 | re = /^(.+?)(ss|i)es$/; 86 | re2 = /^(.+?)([^s])s$/; 87 | 88 | if (re.test(w)) 89 | w = w.replace(re,"$1$2"); 90 | else if (re2.test(w)) 91 | w = w.replace(re2,"$1$2"); 92 | 93 | // Step 1b 94 | re = /^(.+?)eed$/; 95 | re2 = /^(.+?)(ed|ing)$/; 96 | if (re.test(w)) { 97 | var fp = re.exec(w); 98 | re = new RegExp(mgr0); 99 | if (re.test(fp[1])) { 100 | re = /.$/; 101 | w = w.replace(re,""); 102 | } 103 | } 104 | else if (re2.test(w)) { 105 | var fp = re2.exec(w); 106 | stem = fp[1]; 107 | re2 = new RegExp(s_v); 108 | if (re2.test(stem)) { 109 | w = stem; 110 | re2 = /(at|bl|iz)$/; 111 | re3 = new RegExp("([^aeiouylsz])\\1$"); 112 | re4 = new RegExp("^" + C + v + "[^aeiouwxy]$"); 113 | if (re2.test(w)) 114 | w = w + "e"; 115 | else if (re3.test(w)) { 116 | re = /.$/; 117 | w = w.replace(re,""); 118 | } 119 | else if (re4.test(w)) 120 | w = w + "e"; 121 | } 122 | } 123 | 124 | // Step 1c 125 | re = /^(.+?)y$/; 126 | if (re.test(w)) { 127 | var fp = re.exec(w); 128 | stem = fp[1]; 129 | re = new RegExp(s_v); 130 | if (re.test(stem)) 131 | w = stem + "i"; 132 | } 133 | 134 | // Step 2 135 | re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; 136 | if (re.test(w)) { 137 | var fp = re.exec(w); 138 | stem = fp[1]; 139 | suffix = fp[2]; 140 | re = new RegExp(mgr0); 141 | if (re.test(stem)) 142 | w = stem + step2list[suffix]; 143 | } 144 | 145 | // Step 3 146 | re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; 147 | if (re.test(w)) { 148 | var fp = re.exec(w); 149 | stem = fp[1]; 150 | suffix = fp[2]; 151 | re = new RegExp(mgr0); 152 | if (re.test(stem)) 153 | w = stem + step3list[suffix]; 154 | } 155 | 156 | // Step 4 157 | re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; 158 | re2 = /^(.+?)(s|t)(ion)$/; 159 | if (re.test(w)) { 160 | var fp = re.exec(w); 161 | stem = fp[1]; 162 | re = new RegExp(mgr1); 163 | if (re.test(stem)) 164 | w = stem; 165 | } 166 | else if (re2.test(w)) { 167 | var fp = re2.exec(w); 168 | stem = fp[1] + fp[2]; 169 | re2 = new RegExp(mgr1); 170 | if (re2.test(stem)) 171 | w = stem; 172 | } 173 | 174 | // Step 5 175 | re = /^(.+?)e$/; 176 | if (re.test(w)) { 177 | var fp = re.exec(w); 178 | stem = fp[1]; 179 | re = new RegExp(mgr1); 180 | re2 = new RegExp(meq1); 181 | re3 = new RegExp("^" + C + v + "[^aeiouwxy]$"); 182 | if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) 183 | w = stem; 184 | } 185 | re = /ll$/; 186 | re2 = new RegExp(mgr1); 187 | if (re.test(w) && re2.test(w)) { 188 | re = /.$/; 189 | w = w.replace(re,""); 190 | } 191 | 192 | // and turn initial Y back to y 193 | if (firstch == "y") 194 | w = firstch.toLowerCase() + w.substr(1); 195 | return w; 196 | } 197 | } 198 | 199 | 200 | 201 | 202 | 203 | var splitChars = (function() { 204 | var result = {}; 205 | var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648, 206 | 1748, 1809, 2416, 2473, 2481, 2526, 2601, 2609, 2612, 2615, 2653, 2702, 207 | 2706, 2729, 2737, 2740, 2857, 2865, 2868, 2910, 2928, 2948, 2961, 2971, 208 | 2973, 3085, 3089, 3113, 3124, 3213, 3217, 3241, 3252, 3295, 3341, 3345, 209 | 3369, 3506, 3516, 3633, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 3761, 210 | 3781, 3912, 4239, 4347, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 4823, 211 | 4881, 5760, 5901, 5997, 6313, 7405, 8024, 8026, 8028, 8030, 8117, 8125, 212 | 8133, 8181, 8468, 8485, 8487, 8489, 8494, 8527, 11311, 11359, 11687, 11695, 213 | 11703, 11711, 11719, 11727, 11735, 12448, 12539, 43010, 43014, 43019, 43587, 214 | 43696, 43713, 64286, 64297, 64311, 64317, 64319, 64322, 64325, 65141]; 215 | var i, j, start, end; 216 | for (i = 0; i < singles.length; i++) { 217 | result[singles[i]] = true; 218 | } 219 | var ranges = [[0, 47], [58, 64], [91, 94], [123, 169], [171, 177], [182, 184], [706, 709], 220 | [722, 735], [741, 747], [751, 879], [888, 889], [894, 901], [1154, 1161], 221 | [1318, 1328], [1367, 1368], [1370, 1376], [1416, 1487], [1515, 1519], [1523, 1568], 222 | [1611, 1631], [1642, 1645], [1750, 1764], [1767, 1773], [1789, 1790], [1792, 1807], 223 | [1840, 1868], [1958, 1968], [1970, 1983], [2027, 2035], [2038, 2041], [2043, 2047], 224 | [2070, 2073], [2075, 2083], [2085, 2087], [2089, 2307], [2362, 2364], [2366, 2383], 225 | [2385, 2391], [2402, 2405], [2419, 2424], [2432, 2436], [2445, 2446], [2449, 2450], 226 | [2483, 2485], [2490, 2492], [2494, 2509], [2511, 2523], [2530, 2533], [2546, 2547], 227 | [2554, 2564], [2571, 2574], [2577, 2578], [2618, 2648], [2655, 2661], [2672, 2673], 228 | [2677, 2692], [2746, 2748], [2750, 2767], [2769, 2783], [2786, 2789], [2800, 2820], 229 | [2829, 2830], [2833, 2834], [2874, 2876], [2878, 2907], [2914, 2917], [2930, 2946], 230 | [2955, 2957], [2966, 2968], [2976, 2978], [2981, 2983], [2987, 2989], [3002, 3023], 231 | [3025, 3045], [3059, 3076], [3130, 3132], [3134, 3159], [3162, 3167], [3170, 3173], 232 | [3184, 3191], [3199, 3204], [3258, 3260], [3262, 3293], [3298, 3301], [3312, 3332], 233 | [3386, 3388], [3390, 3423], [3426, 3429], [3446, 3449], [3456, 3460], [3479, 3481], 234 | [3518, 3519], [3527, 3584], [3636, 3647], [3655, 3663], [3674, 3712], [3717, 3718], 235 | [3723, 3724], [3726, 3731], [3752, 3753], [3764, 3772], [3774, 3775], [3783, 3791], 236 | [3802, 3803], [3806, 3839], [3841, 3871], [3892, 3903], [3949, 3975], [3980, 4095], 237 | [4139, 4158], [4170, 4175], [4182, 4185], [4190, 4192], [4194, 4196], [4199, 4205], 238 | [4209, 4212], [4226, 4237], [4250, 4255], [4294, 4303], [4349, 4351], [4686, 4687], 239 | [4702, 4703], [4750, 4751], [4790, 4791], [4806, 4807], [4886, 4887], [4955, 4968], 240 | [4989, 4991], [5008, 5023], [5109, 5120], [5741, 5742], [5787, 5791], [5867, 5869], 241 | [5873, 5887], [5906, 5919], [5938, 5951], [5970, 5983], [6001, 6015], [6068, 6102], 242 | [6104, 6107], [6109, 6111], [6122, 6127], [6138, 6159], [6170, 6175], [6264, 6271], 243 | [6315, 6319], [6390, 6399], [6429, 6469], [6510, 6511], [6517, 6527], [6572, 6592], 244 | [6600, 6607], [6619, 6655], [6679, 6687], [6741, 6783], [6794, 6799], [6810, 6822], 245 | [6824, 6916], [6964, 6980], [6988, 6991], [7002, 7042], [7073, 7085], [7098, 7167], 246 | [7204, 7231], [7242, 7244], [7294, 7400], [7410, 7423], [7616, 7679], [7958, 7959], 247 | [7966, 7967], [8006, 8007], [8014, 8015], [8062, 8063], [8127, 8129], [8141, 8143], 248 | [8148, 8149], [8156, 8159], [8173, 8177], [8189, 8303], [8306, 8307], [8314, 8318], 249 | [8330, 8335], [8341, 8449], [8451, 8454], [8456, 8457], [8470, 8472], [8478, 8483], 250 | [8506, 8507], [8512, 8516], [8522, 8525], [8586, 9311], [9372, 9449], [9472, 10101], 251 | [10132, 11263], [11493, 11498], [11503, 11516], [11518, 11519], [11558, 11567], 252 | [11622, 11630], [11632, 11647], [11671, 11679], [11743, 11822], [11824, 12292], 253 | [12296, 12320], [12330, 12336], [12342, 12343], [12349, 12352], [12439, 12444], 254 | [12544, 12548], [12590, 12592], [12687, 12689], [12694, 12703], [12728, 12783], 255 | [12800, 12831], [12842, 12880], [12896, 12927], [12938, 12976], [12992, 13311], 256 | [19894, 19967], [40908, 40959], [42125, 42191], [42238, 42239], [42509, 42511], 257 | [42540, 42559], [42592, 42593], [42607, 42622], [42648, 42655], [42736, 42774], 258 | [42784, 42785], [42889, 42890], [42893, 43002], [43043, 43055], [43062, 43071], 259 | [43124, 43137], [43188, 43215], [43226, 43249], [43256, 43258], [43260, 43263], 260 | [43302, 43311], [43335, 43359], [43389, 43395], [43443, 43470], [43482, 43519], 261 | [43561, 43583], [43596, 43599], [43610, 43615], [43639, 43641], [43643, 43647], 262 | [43698, 43700], [43703, 43704], [43710, 43711], [43715, 43738], [43742, 43967], 263 | [44003, 44015], [44026, 44031], [55204, 55215], [55239, 55242], [55292, 55295], 264 | [57344, 63743], [64046, 64047], [64110, 64111], [64218, 64255], [64263, 64274], 265 | [64280, 64284], [64434, 64466], [64830, 64847], [64912, 64913], [64968, 65007], 266 | [65020, 65135], [65277, 65295], [65306, 65312], [65339, 65344], [65371, 65381], 267 | [65471, 65473], [65480, 65481], [65488, 65489], [65496, 65497]]; 268 | for (i = 0; i < ranges.length; i++) { 269 | start = ranges[i][0]; 270 | end = ranges[i][1]; 271 | for (j = start; j <= end; j++) { 272 | result[j] = true; 273 | } 274 | } 275 | return result; 276 | })(); 277 | 278 | function splitQuery(query) { 279 | var result = []; 280 | var start = -1; 281 | for (var i = 0; i < query.length; i++) { 282 | if (splitChars[query.charCodeAt(i)]) { 283 | if (start !== -1) { 284 | result.push(query.slice(start, i)); 285 | start = -1; 286 | } 287 | } else if (start === -1) { 288 | start = i; 289 | } 290 | } 291 | if (start !== -1) { 292 | result.push(query.slice(start)); 293 | } 294 | return result; 295 | } 296 | 297 | 298 | -------------------------------------------------------------------------------- /docs/_static/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/minus.png -------------------------------------------------------------------------------- /docs/_static/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sooftware/conformer/b4e7d44944214db6e5912f92ff43d5ea1919eaa2/docs/_static/plus.png -------------------------------------------------------------------------------- /docs/_static/pygments.css: -------------------------------------------------------------------------------- 1 | pre { line-height: 125%; margin: 0; } 2 | td.linenos pre { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; } 3 | span.linenos { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; } 4 | td.linenos pre.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } 5 | span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } 6 | .highlight .hll { background-color: #ffffcc } 7 | .highlight { background: #eeffcc; } 8 | .highlight .c { color: #408090; font-style: italic } /* Comment */ 9 | .highlight .err { border: 1px solid #FF0000 } /* Error */ 10 | .highlight .k { color: #007020; font-weight: bold } /* Keyword */ 11 | .highlight .o { color: #666666 } /* Operator */ 12 | .highlight .ch { color: #408090; font-style: italic } /* Comment.Hashbang */ 13 | .highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */ 14 | .highlight .cp { color: #007020 } /* Comment.Preproc */ 15 | .highlight .cpf { color: #408090; font-style: italic } /* Comment.PreprocFile */ 16 | .highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */ 17 | .highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */ 18 | .highlight .gd { color: #A00000 } /* Generic.Deleted */ 19 | .highlight .ge { font-style: italic } /* Generic.Emph */ 20 | .highlight .gr { color: #FF0000 } /* Generic.Error */ 21 | .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ 22 | .highlight .gi { color: #00A000 } /* Generic.Inserted */ 23 | .highlight .go { color: #333333 } /* Generic.Output */ 24 | .highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ 25 | .highlight .gs { font-weight: bold } /* Generic.Strong */ 26 | .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ 27 | .highlight .gt { color: #0044DD } /* Generic.Traceback */ 28 | .highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */ 29 | .highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */ 30 | .highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */ 31 | .highlight .kp { color: #007020 } /* Keyword.Pseudo */ 32 | .highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */ 33 | .highlight .kt { color: #902000 } /* Keyword.Type */ 34 | .highlight .m { color: #208050 } /* Literal.Number */ 35 | .highlight .s { color: #4070a0 } /* Literal.String */ 36 | .highlight .na { color: #4070a0 } /* Name.Attribute */ 37 | .highlight .nb { color: #007020 } /* Name.Builtin */ 38 | .highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */ 39 | .highlight .no { color: #60add5 } /* Name.Constant */ 40 | .highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */ 41 | .highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */ 42 | .highlight .ne { color: #007020 } /* Name.Exception */ 43 | .highlight .nf { color: #06287e } /* Name.Function */ 44 | .highlight .nl { color: #002070; font-weight: bold } /* Name.Label */ 45 | .highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ 46 | .highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */ 47 | .highlight .nv { color: #bb60d5 } /* Name.Variable */ 48 | .highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */ 49 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */ 50 | .highlight .mb { color: #208050 } /* Literal.Number.Bin */ 51 | .highlight .mf { color: #208050 } /* Literal.Number.Float */ 52 | .highlight .mh { color: #208050 } /* Literal.Number.Hex */ 53 | .highlight .mi { color: #208050 } /* Literal.Number.Integer */ 54 | .highlight .mo { color: #208050 } /* Literal.Number.Oct */ 55 | .highlight .sa { color: #4070a0 } /* Literal.String.Affix */ 56 | .highlight .sb { color: #4070a0 } /* Literal.String.Backtick */ 57 | .highlight .sc { color: #4070a0 } /* Literal.String.Char */ 58 | .highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */ 59 | .highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ 60 | .highlight .s2 { color: #4070a0 } /* Literal.String.Double */ 61 | .highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */ 62 | .highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */ 63 | .highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */ 64 | .highlight .sx { color: #c65d09 } /* Literal.String.Other */ 65 | .highlight .sr { color: #235388 } /* Literal.String.Regex */ 66 | .highlight .s1 { color: #4070a0 } /* Literal.String.Single */ 67 | .highlight .ss { color: #517918 } /* Literal.String.Symbol */ 68 | .highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */ 69 | .highlight .fm { color: #06287e } /* Name.Function.Magic */ 70 | .highlight .vc { color: #bb60d5 } /* Name.Variable.Class */ 71 | .highlight .vg { color: #bb60d5 } /* Name.Variable.Global */ 72 | .highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */ 73 | .highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */ 74 | .highlight .il { color: #208050 } /* Literal.Number.Integer.Long */ -------------------------------------------------------------------------------- /docs/_static/searchtools.js: -------------------------------------------------------------------------------- 1 | /* 2 | * searchtools.js 3 | * ~~~~~~~~~~~~~~~~ 4 | * 5 | * Sphinx JavaScript utilities for the full-text search. 6 | * 7 | * :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | if (!Scorer) { 13 | /** 14 | * Simple result scoring code. 15 | */ 16 | var Scorer = { 17 | // Implement the following function to further tweak the score for each result 18 | // The function takes a result array [filename, title, anchor, descr, score] 19 | // and returns the new score. 20 | /* 21 | score: function(result) { 22 | return result[4]; 23 | }, 24 | */ 25 | 26 | // query matches the full name of an object 27 | objNameMatch: 11, 28 | // or matches in the last dotted part of the object name 29 | objPartialMatch: 6, 30 | // Additive scores depending on the priority of the object 31 | objPrio: {0: 15, // used to be importantResults 32 | 1: 5, // used to be objectResults 33 | 2: -5}, // used to be unimportantResults 34 | // Used when the priority is not in the mapping. 35 | objPrioDefault: 0, 36 | 37 | // query found in title 38 | title: 15, 39 | partialTitle: 7, 40 | // query found in terms 41 | term: 5, 42 | partialTerm: 2 43 | }; 44 | } 45 | 46 | if (!splitQuery) { 47 | function splitQuery(query) { 48 | return query.split(/\s+/); 49 | } 50 | } 51 | 52 | /** 53 | * Search Module 54 | */ 55 | var Search = { 56 | 57 | _index : null, 58 | _queued_query : null, 59 | _pulse_status : -1, 60 | 61 | htmlToText : function(htmlString) { 62 | var htmlElement = document.createElement('span'); 63 | htmlElement.innerHTML = htmlString; 64 | $(htmlElement).find('.headerlink').remove(); 65 | docContent = $(htmlElement).find('[role=main]')[0]; 66 | if(docContent === undefined) { 67 | console.warn("Content block not found. Sphinx search tries to obtain it " + 68 | "via '[role=main]'. Could you check your theme or template."); 69 | return ""; 70 | } 71 | return docContent.textContent || docContent.innerText; 72 | }, 73 | 74 | init : function() { 75 | var params = $.getQueryParameters(); 76 | if (params.q) { 77 | var query = params.q[0]; 78 | $('input[name="q"]')[0].value = query; 79 | this.performSearch(query); 80 | } 81 | }, 82 | 83 | loadIndex : function(url) { 84 | $.ajax({type: "GET", url: url, data: null, 85 | dataType: "script", cache: true, 86 | complete: function(jqxhr, textstatus) { 87 | if (textstatus != "success") { 88 | document.getElementById("searchindexloader").src = url; 89 | } 90 | }}); 91 | }, 92 | 93 | setIndex : function(index) { 94 | var q; 95 | this._index = index; 96 | if ((q = this._queued_query) !== null) { 97 | this._queued_query = null; 98 | Search.query(q); 99 | } 100 | }, 101 | 102 | hasIndex : function() { 103 | return this._index !== null; 104 | }, 105 | 106 | deferQuery : function(query) { 107 | this._queued_query = query; 108 | }, 109 | 110 | stopPulse : function() { 111 | this._pulse_status = 0; 112 | }, 113 | 114 | startPulse : function() { 115 | if (this._pulse_status >= 0) 116 | return; 117 | function pulse() { 118 | var i; 119 | Search._pulse_status = (Search._pulse_status + 1) % 4; 120 | var dotString = ''; 121 | for (i = 0; i < Search._pulse_status; i++) 122 | dotString += '.'; 123 | Search.dots.text(dotString); 124 | if (Search._pulse_status > -1) 125 | window.setTimeout(pulse, 500); 126 | } 127 | pulse(); 128 | }, 129 | 130 | /** 131 | * perform a search for something (or wait until index is loaded) 132 | */ 133 | performSearch : function(query) { 134 | // create the required interface elements 135 | this.out = $('#search-results'); 136 | this.title = $('

' + _('Searching') + '

').appendTo(this.out); 137 | this.dots = $('').appendTo(this.title); 138 | this.status = $('

 

').appendTo(this.out); 139 | this.output = $('