├── .gitignore ├── .nojekyll ├── 404.html ├── CNAME ├── Dockerfile ├── LICENSE ├── README.md ├── SUMMARY.md ├── Styles └── ebook.css ├── asset ├── docsify-apachecn-footer.js ├── docsify-baidu-push.js ├── docsify-baidu-stat.js ├── docsify-clicker.js ├── docsify-cnzz.js ├── docsify-copy-code.min.js ├── docsify.min.js ├── prism-darcula.css ├── prism-python.min.js ├── search.min.js ├── style.css └── vue.css ├── docs ├── 0.md ├── 1.md ├── 10.md ├── 11.md ├── 12.md ├── 14.md ├── 2.md ├── 3.md ├── 4.md ├── 5.md ├── 6.md ├── 7.md ├── 8.md ├── 9.md └── Images │ ├── 05c7618d4554f83cfa6105c528703794.jpg │ ├── 07e7d99633e4a107388f7202380cce55.jpg │ ├── 0ddbd56a410c886c77d1c72a84e27883.jpg │ ├── 0de8ea07b37cc379da8aeb4a0c9fd5bf.jpg │ ├── 0e6e187e03f69a6548e7daa4f95e1548.jpg │ ├── 0e768e8c4378c2b0b3290aab46dc770e.jpg │ ├── 0f4441cdaf35bfa4d58fc64142cf4736.jpg │ ├── 102675fd70e434164536c75bf7f8f043.jpg │ ├── 1094084b61ac3f0e4416e92869c52ccd.jpg │ ├── 10a8a58e33a0a6b7fb71389ea2114566.jpg │ ├── 10a910dd6de117ab7a0ab352519f7297.jpg │ ├── 12573c3a9015654728fe798e170a3c50.jpg │ ├── 13361de430cd983e689417c547330bbc.jpg │ ├── 13f25b9eba42f74ad969a74cee78551e.jpg │ ├── 14a0a2692f06286091f0cca17de5c0f3.jpg │ ├── 14a15b73cb826ac3464754d6db3e9e54.jpg │ ├── 160f0b5ad0e4b8745b925d63377a69ba.jpg │ ├── 17af2b7a4de652abd5c2c71a94cc1c7b.jpg │ ├── 1ab45939cc9babb242ac45ed03a94f7a.jpg │ ├── 1b33abb14fc8fe7c704d005736ddb323.jpg │ ├── 1c54b3124863d24d17b2edec4f1d47e5.jpg │ ├── 1cf5b2605018e587fa94db2ac671e930.jpg │ ├── 21f757d2c1451cb55bc923dcb4d8d1ab.jpg │ ├── 24589c2eb435b25724aed562d1d47617.jpg │ ├── 273b9ed1ea067e4503c00dbd193216e8.jpg │ ├── 27ffeabf8327e1810d6ac35642a72700.jpg │ ├── 2ce816f11fd01927802253d100780b0a.jpg │ ├── 2cfe7a0ac0b6007d979cf3aecda8a9f5.jpg │ ├── 334be383b5db7ffe3599cc03bc74bf9e.jpg │ ├── 346344c2e5a627acfdddf948fb69cb1d.jpg │ ├── 37edef9faf625ac06477a0ab0118afca.jpg │ ├── 3a93e0258a010fdda935b4ee067411a5.jpg │ ├── 3edaf7564caaab7c8ddc83db1d5408a3.jpg │ ├── 4150e51ab7e511f8d4f72293054ceb22.jpg │ ├── 431fed60785d71efd9010589288ca55d.jpg │ ├── 43a0f901bdd8f343b2885d2b2e95b996.jpg │ ├── 484180fc6abc244116b30e57cb6c0cf5.jpg │ ├── 496754d8cdb6262f8f72e1f066bab359.jpg │ ├── 499f8953a7d39c034e6840bdacd99d08.jpg │ ├── 4a87f1dccc0e18aab5ec599d8d8358d6.jpg │ ├── 4acbae4abe459cf45122fe134ff7672d.jpg │ ├── 4b32a28b1aab7148420347abc990ee67.jpg │ ├── 4b5cae275c53c53ccc8f2f779acada3e.jpg │ ├── 4cdc400cf76b0354304e01aeb894877b.jpg │ ├── 4cec5bd698a48f7e083696dd51ae9e7a.jpg │ ├── 513df73dfd52feca2c96a86dcc261c8b.jpg │ ├── 532d5f3185ea7edaec68683d89a74182.jpg │ ├── 542fee25c56235c899312bed3d5ee9ba.jpg │ ├── 55f4da85888c6e9974fea5360283035a.jpg │ ├── 56cee123595482cf3edaef089cb9a6a7.jpg │ ├── 5741a8d50a63172cbd2c825cda1b61d5.jpg │ ├── 58a1097522dc6fbe24eddd96cfd6cbc9.jpg │ ├── 5ac0acc015eeb4b0a40c6c23b7f95395.jpg │ ├── 5c0c6dc75f29f253edaecb566d608aa3.jpg │ ├── 5c3caa46daa29a053a04713bab6e4f03.jpg │ ├── 5e197b7d253f66454a97af2a93c30a8e.jpg │ ├── 5eeb4cf55b6d18d4bcb098fc72ddc6d7.jpg │ ├── 6372ba4f28e69f0b220c75a9b2f4decf.jpg │ ├── 63a8e4c47e813ba9630363f9b203a19a.jpg │ ├── 64864d38550248d5bd9b82eeb6f0583b.jpg │ ├── 66d94cb86ab90a95cfe745d9613c37b1.jpg │ ├── 67abca0731a79d664847dee1390f2e13.jpg │ ├── 6ac827d2d00b6ebf8bbc704f430af896.jpg │ ├── 6ddd472200240ea6c0cab35349a8403e.jpg │ ├── 6efeadf518b11a6441906b93844c2b19.jpg │ ├── 723ad3b660335fc3b79e7bd2c947b195.jpg │ ├── 74248e04835acdba414fd407bb4f3241.jpg │ ├── 77460905bcad52d84e324fc4821ed903.jpg │ ├── 78213332718eae7fffd6314dae12484e.jpg │ ├── 78bc6ca8410394dcf6910484bc97e2b6.jpg │ ├── 7a979f968bd33428b02cde62eaf2b615.jpg │ ├── 7aee076ae156921aba96ac5d4f9ed419.jpg │ ├── 7bbd845f6f0cf6246561d2859cbcecbf.jpg │ ├── 7c20d0adbadb35031a28bfcd6dff9900.jpg │ ├── 7e6ea96aad77f3e523494b3972b5a989.jpg │ ├── 7f27bfe5324e4d9573ddd210531a8126.jpg │ ├── 7f97e7ac70a7c865fb1020795f6e7236.jpg │ ├── 81e6b07f4541d7d5a7900508d11172bd.jpg │ ├── 82ddd91230422f3ba446f46ca73ff663.jpg │ ├── 84419adac7940aeb3026bc0a8b3e5fb4.jpg │ ├── 854532b0c5c8869f9012833955e75b20.jpg │ ├── 86cecc4bd139ddaf1a5daf9991f39945.jpg │ ├── 89747cee31bc672bfbbb6891a9099a25.jpg │ ├── 8b4bb6b0ec5bb337fdb00c31efcc1645.jpg │ ├── 8bfa073b3f3753285055c1e3ef689826.jpg │ ├── 8c5ec1a0132f7c85fd96eda9d9929d15.jpg │ ├── 8cb61a943f3d34f94596e77065410cd3.jpg │ ├── 910abba27da60798441e98902cce64ca.jpg │ ├── 92cc2e7821d464cfbaaf651a360cd413.jpg │ ├── 934b688727805b37f2404f7497c52027.jpg │ ├── 953f4a408c97594449de5ca84c294719.jpg │ ├── 96fd8d34602a08c09a19f5b2c5c19380.jpg │ ├── 99dbcae75bd96499dce3b3671032a106.jpg │ ├── 9ea1d0111a40bd865c651712f276bc31.jpg │ ├── a538227535079e1fa1e906af90af28eb.jpg │ ├── aa68e0e8f4d58caa31e5542dabe4ddc2.jpg │ ├── ab3d4c917ad3461f18759719a288afa5.jpg │ ├── b1aad2b60635723f14976fb5cb9ca372.jpg │ ├── b2af1426c6cd2403c8b938eb557a99d1.jpg │ ├── b502c97e1f935240559d38b397805b32.jpg │ ├── bc7e6aa002dd5ced295ba1de2ebbbf61.jpg │ ├── bcf758e8278f3295df58c6eace05152c.jpg │ ├── be33958d0b44c88caac0dcf4d4ec84c6.jpg │ ├── bf2a88150e1927f2e52d745ab6cae7ce.jpg │ ├── bfd8f5fc51eb8848dfb986c7937ded23.jpg │ ├── c28c02e5c661caa578acaea0fa9e9dd2.jpg │ ├── c370689374c63baf915c9e44c4b270d4.jpg │ ├── ca21bcde8ab16a341929b7fb9ccb0a0e.jpg │ ├── ced4e829d6a662a2be20187f9d7b71b5.jpg │ ├── cf5ffc116dbddb4a34c65925b0d558cb.jpg │ ├── d167c4075a237573a350e298a184d4fb.jpg │ ├── d2c5cc51cd61a6915f24d0c52eaab9c5.jpg │ ├── d315c52900de61a078cd8391c1a1c604.jpg │ ├── d3541d4caaf5c92d8ab496ccd7ee9a2d.jpg │ ├── d41ca3c99b067df414f6ed0847a641ca.jpg │ ├── d46d7efa5d57b31c68c4ddddd464d6c0.jpg │ ├── d87676460c87d0516fb382b929c07302.jpg │ ├── da1752497a2a17be12b2acb282918a7a.jpg │ ├── da516572f97daebe1be746abd7bd2268.jpg │ ├── daf7c1761ffc1edbb39e6ca11863854f.jpg │ ├── de0715649664a49a5ab2e2b61ae2675a.jpg │ ├── df98e5a4903ccc7253cc7cc6ebda4fea.jpg │ ├── e04c36ac970436161b45be660ea3a7d2.jpg │ ├── e104303155c3fbb0742ea67a0560ab7f.jpg │ ├── e112e308d5c3454875146f40e4b48f3f.jpg │ ├── e24d03f1dec3f8a75e8042579446a47e.jpg │ ├── e33fb540f11c5ea9a07441be8a407d43.jpg │ ├── e372da3dc801bc1211a47d2e82840b64.jpg │ ├── e591e60c490795add5183c998132ebc0.jpg │ ├── e5fb07e997b9718f18dbf677e3d6634d.jpg │ ├── e685801a8cec4515b47e1bda95deb59d.jpg │ ├── e941b64ed778967dd0170d25492e42df.jpg │ ├── e9d9a0887996a6bac6c52bb0bfaf9fdf.jpg │ ├── ea84debad296c6385399fb2252fc93f1.jpg │ ├── eb630c6034e9ed7274ef2e04b9694347.jpg │ ├── edd1b5af9dcd26541183ce4d6a634e54.jpg │ ├── eeff7ed83be48bf40aeeb3bf9db5550e.jpg │ ├── ef661b5a01845fe5440027afca461925.jpg │ ├── f093aaace735b4961dbf9fa7d5c8ca37.jpg │ ├── f202bb6a4c773430e3d1340de573d0e5.jpg │ ├── f3ad266a67457b4615141d6ba83e724e.jpg │ ├── f4891d12ae20c39b685951ad3cddf1aa.jpg │ ├── f9e1ba3246770e3ecb24f813f33f2075.jpg │ ├── fb1a02fe3607a0deb452086296fd6f69.jpg │ ├── ff868af58b8c1843c38287717b137f7c.jpg │ ├── ffa808c97c7034af1bc2806ed7224203.jpg │ └── fff90c564d2625f739b442b23301906e.jpg ├── index.html └── update.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | .vscode 6 | sftp.json 7 | data 8 | 9 | # C extensions 10 | *.so 11 | 12 | # Distribution / packaging 13 | .Python 14 | build/ 15 | develop-eggs/ 16 | dist/ 17 | downloads/ 18 | eggs/ 19 | .eggs/ 20 | lib/ 21 | lib64/ 22 | parts/ 23 | sdist/ 24 | var/ 25 | wheels/ 26 | *.egg-info/ 27 | .installed.cfg 28 | *.egg 29 | MANIFEST 30 | 31 | # PyInstaller 32 | # Usually these files are written by a python script from a template 33 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 34 | *.manifest 35 | *.spec 36 | 37 | # Installer logs 38 | pip-log.txt 39 | pip-delete-this-directory.txt 40 | 41 | # Unit test / coverage reports 42 | htmlcov/ 43 | .tox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | 53 | # Translations 54 | *.mo 55 | *.pot 56 | 57 | # Django stuff: 58 | *.log 59 | local_settings.py 60 | db.sqlite3 61 | 62 | # Flask stuff: 63 | instance/ 64 | .webassets-cache 65 | 66 | # Scrapy stuff: 67 | .scrapy 68 | 69 | # Sphinx documentation 70 | _book/ 71 | docs/_build/ 72 | 73 | # PyBuilder 74 | target/ 75 | 76 | # Jupyter Notebook 77 | .ipynb_checkpoints 78 | 79 | # pyenv 80 | .python-version 81 | 82 | # celery beat schedule file 83 | celerybeat-schedule 84 | 85 | # SageMath parsed files 86 | *.sage.py 87 | 88 | # Environments 89 | .env 90 | .venv 91 | env/ 92 | venv/ 93 | ENV/ 94 | env.bak/ 95 | venv.bak/ 96 | 97 | # Spyder project settings 98 | .spyderproject 99 | .spyproject 100 | 101 | # Rope project settings 102 | .ropeproject 103 | 104 | # mkdocs documentation 105 | /site 106 | 107 | # mypy 108 | .mypy_cache/ 109 | node_modules 110 | -------------------------------------------------------------------------------- /.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/.nojekyll -------------------------------------------------------------------------------- /404.html: -------------------------------------------------------------------------------- 1 | --- 2 | permalink: /404.html 3 | --- 4 | 5 | -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | nltk.apachecn.org -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM httpd:2.4 2 | COPY ./ /usr/local/apache2/htdocs/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License (CC BY-NC-SA 4.0) 2 | 3 | Copyright © 2020 ApacheCN(apachecn@163.com) 4 | 5 | By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. 6 | 7 | Section 1 – Definitions. 8 | 9 | a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. 10 | b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. 11 | c. BY-NC-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License. 12 | d. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. 13 | e. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. 14 | f. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. 15 | g. License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution, NonCommercial, and ShareAlike. 16 | h. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. 17 | i. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. 18 | j. Licensor means the individual(s) or entity(ies) granting rights under this Public License. 19 | k. NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange. 20 | l. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. 21 | m. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. 22 | n. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. 23 | 24 | Section 2 – Scope. 25 | 26 | a. License grant. 27 | 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: 28 | A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and 29 | B. produce, reproduce, and Share Adapted Material for NonCommercial purposes only. 30 | 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 31 | 3. Term. The term of this Public License is specified in Section 6(a). 32 | 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. 33 | 5. Downstream recipients. 34 | A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. 35 | B. Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply. 36 | C. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 37 | 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). 38 | b. Other rights. 39 | 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 40 | 2. Patent and trademark rights are not licensed under this Public License. 41 | 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes. 42 | 43 | Section 3 – License Conditions. 44 | 45 | Your exercise of the Licensed Rights is expressly made subject to the following conditions. 46 | 47 | a. Attribution. 48 | 1. If You Share the Licensed Material (including in modified form), You must: 49 | A. retain the following if it is supplied by the Licensor with the Licensed Material: 50 | i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); 51 | ii. a copyright notice; 52 | iii. a notice that refers to this Public License; 53 | iv. a notice that refers to the disclaimer of warranties; 54 | v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; 55 | B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and 56 | C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 57 | 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 58 | 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. 59 | b. ShareAlike. 60 | In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply. 61 | 1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-NC-SA Compatible License. 62 | 2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material. 63 | 3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply. 64 | 65 | Section 4 – Sui Generis Database Rights. 66 | 67 | Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: 68 | 69 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only; 70 | b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and 71 | c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. 72 | 73 | For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. 74 | 75 | Section 5 – Disclaimer of Warranties and Limitation of Liability. 76 | 77 | a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. 78 | b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. 79 | c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. 80 | 81 | Section 6 – Term and Termination. 82 | 83 | a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. 84 | b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 85 | 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 86 | 2. upon express reinstatement by the Licensor. 87 | For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. 88 | c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. 89 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. 90 | 91 | Section 7 – Other Terms and Conditions. 92 | 93 | a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. 94 | b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. 95 | 96 | Section 8 – Interpretation. 97 | 98 | a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. 99 | b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. 100 | c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. 101 | d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python 自然语言处理 第二版 2 | 3 | ## – 使用自然语言工具包分析文本 4 | 5 | > 作者:**Steven Bird, Ewan Klein 和 Edward Loper** 6 | > 7 | > 译者:[Python 文档协作翻译小组](http://usyiyi.cn/translate/nltk_python/index.html) 8 | > 9 | > 最后更新:2017.3.4 10 | > 11 | > [Django 文档协作翻译小组](http://python.usyiyi.cn/django/index.html)人手紧缺,有兴趣的朋友可以加入我们,完全公益性质。交流群:467338606。 12 | 13 | + [在线阅读](https://nltk.apachecn.org) 14 | + [在线阅读(Gitee)](https://apachecn.gitee.io/nlp-py-2e-zh/) 15 | 16 | 本版本的 NLTK 已经针对 Python 3 和 NLTK 3 更新。本书的第一版由 O'Reilly 出版,可以在 [http://nltk.org/book_1ed/](http://nltk.org/book_1ed/) 访问到。(本书目前没有计划出第二版) 17 | 18 | 本版本的初译基于[原书第一版的翻译](http://www.52nlp.cn/resources),参见第一版[译者的话](./15.html)。 19 | 20 | 本书的发行遵守 [Creative Commons Attribution Noncommercial No-Derivative-Works 3.0 US License](http://creativecommons.org/licenses/by-nc-nd/3.0/us/) 条款。 21 | 22 | 如果对材料有任何疑问请提交至 [nltk-users](http://groups.google.com/group/nltk-users) 邮件列表。请在 [issue tracker](https://github.com/nltk/nltk_book/issues) 上报告错误。 23 | 24 | ## 下载 25 | 26 | ### Docker 27 | 28 | ``` 29 | docker pull apachecn0/nlp-py-2e-zh 30 | docker run -tid -p :80 apachecn0/nlp-py-2e-zh 31 | # 访问 http://localhost:{port} 查看文档 32 | ``` 33 | 34 | ### PYPI 35 | 36 | ``` 37 | pip install nlp-py-2e-zh 38 | nlp-py-2e-zh 39 | # 访问 http://localhost:{port} 查看文档 40 | ``` 41 | 42 | ### NPM 43 | 44 | ``` 45 | npm install -g nlp-py-2e-zh 46 | nlp-py-2e-zh 47 | # 访问 http://localhost:{port} 查看文档 48 | ``` 49 | -------------------------------------------------------------------------------- /SUMMARY.md: -------------------------------------------------------------------------------- 1 | + [Python 自然语言处理 第二版](README.md) 2 | + [前言](docs/0.md) 3 | + [1 语言处理与 Python](docs/1.md) 4 | + [2 获得文本语料和词汇资源](docs/2.md) 5 | + [3 处理原始文本](docs/3.md) 6 | + [4 编写结构化程序](docs/4.md) 7 | + [5 分类和标注词汇](docs/5.md) 8 | + [6 学习分类文本](docs/6.md) 9 | + [7 从文本提取信息](docs/7.md) 10 | + [8 分析句子结构](docs/8.md) 11 | + [9 构建基于特征的语法](docs/9.md) 12 | + [10 分析句子的意思](docs/10.md) 13 | + [11 语言学数据管理](docs/11.md) 14 | + [后记:语言的挑战](docs/12.md) 15 | + [索引](docs/14.md) 16 | -------------------------------------------------------------------------------- /Styles/ebook.css: -------------------------------------------------------------------------------- 1 | /* GitHub stylesheet for MarkdownPad (http://markdownpad.com) */ 2 | /* Author: Nicolas Hery - http://nicolashery.com */ 3 | /* Version: b13fe65ca28d2e568c6ed5d7f06581183df8f2ff */ 4 | /* Source: https://github.com/nicolahery/markdownpad-github */ 5 | 6 | /* RESET 7 | =============================================================================*/ 8 | 9 | html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { 10 | margin: 0; 11 | padding: 0; 12 | border: 0; 13 | } 14 | 15 | /* BODY 16 | =============================================================================*/ 17 | 18 | body { 19 | font-family: Helvetica, arial, freesans, clean, sans-serif; 20 | font-size: 14px; 21 | line-height: 1.6; 22 | color: #333; 23 | background-color: #fff; 24 | padding: 20px; 25 | max-width: 960px; 26 | margin: 0 auto; 27 | } 28 | 29 | body>*:first-child { 30 | margin-top: 0 !important; 31 | } 32 | 33 | body>*:last-child { 34 | margin-bottom: 0 !important; 35 | } 36 | 37 | /* BLOCKS 38 | =============================================================================*/ 39 | 40 | p, blockquote, ul, ol, dl, table, pre { 41 | margin: 15px 0; 42 | } 43 | 44 | /* HEADERS 45 | =============================================================================*/ 46 | 47 | h1, h2, h3, h4, h5, h6 { 48 | margin: 20px 0 10px; 49 | padding: 0; 50 | font-weight: bold; 51 | -webkit-font-smoothing: antialiased; 52 | } 53 | 54 | h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code, h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code { 55 | font-size: inherit; 56 | } 57 | 58 | h1 { 59 | font-size: 24px; 60 | border-bottom: 1px solid #ccc; 61 | color: #000; 62 | } 63 | 64 | h2 { 65 | font-size: 18px; 66 | color: #000; 67 | } 68 | 69 | h3 { 70 | font-size: 14px; 71 | } 72 | 73 | h4 { 74 | font-size: 14px; 75 | } 76 | 77 | h5 { 78 | font-size: 14px; 79 | } 80 | 81 | h6 { 82 | color: #777; 83 | font-size: 14px; 84 | } 85 | 86 | body>h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h4:first-child, body>h5:first-child, body>h6:first-child { 87 | margin-top: 0; 88 | padding-top: 0; 89 | } 90 | 91 | a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 { 92 | margin-top: 0; 93 | padding-top: 0; 94 | } 95 | 96 | h1+p, h2+p, h3+p, h4+p, h5+p, h6+p { 97 | margin-top: 10px; 98 | } 99 | 100 | /* LINKS 101 | =============================================================================*/ 102 | 103 | a { 104 | color: #4183C4; 105 | text-decoration: none; 106 | } 107 | 108 | a:hover { 109 | text-decoration: underline; 110 | } 111 | 112 | /* LISTS 113 | =============================================================================*/ 114 | 115 | ul, ol { 116 | padding-left: 30px; 117 | } 118 | 119 | ul li > :first-child, 120 | ol li > :first-child, 121 | ul li ul:first-of-type, 122 | ol li ol:first-of-type, 123 | ul li ol:first-of-type, 124 | ol li ul:first-of-type { 125 | margin-top: 0px; 126 | } 127 | 128 | ul ul, ul ol, ol ol, ol ul { 129 | margin-bottom: 0; 130 | } 131 | 132 | dl { 133 | padding: 0; 134 | } 135 | 136 | dl dt { 137 | font-size: 14px; 138 | font-weight: bold; 139 | font-style: italic; 140 | padding: 0; 141 | margin: 15px 0 5px; 142 | } 143 | 144 | dl dt:first-child { 145 | padding: 0; 146 | } 147 | 148 | dl dt>:first-child { 149 | margin-top: 0px; 150 | } 151 | 152 | dl dt>:last-child { 153 | margin-bottom: 0px; 154 | } 155 | 156 | dl dd { 157 | margin: 0 0 15px; 158 | padding: 0 15px; 159 | } 160 | 161 | dl dd>:first-child { 162 | margin-top: 0px; 163 | } 164 | 165 | dl dd>:last-child { 166 | margin-bottom: 0px; 167 | } 168 | 169 | /* CODE 170 | =============================================================================*/ 171 | 172 | pre, code, tt { 173 | font-size: 12px; 174 | font-family: Consolas, "Liberation Mono", Courier, monospace; 175 | } 176 | 177 | code, tt { 178 | margin: 0 0px; 179 | padding: 0px 0px; 180 | white-space: nowrap; 181 | border: 1px solid #eaeaea; 182 | background-color: #f8f8f8; 183 | border-radius: 3px; 184 | } 185 | 186 | pre>code { 187 | margin: 0; 188 | padding: 0; 189 | white-space: pre; 190 | border: none; 191 | background: transparent; 192 | } 193 | 194 | pre { 195 | background-color: #f8f8f8; 196 | border: 1px solid #ccc; 197 | font-size: 13px; 198 | line-height: 19px; 199 | overflow: auto; 200 | padding: 6px 10px; 201 | border-radius: 3px; 202 | } 203 | 204 | pre code, pre tt { 205 | background-color: transparent; 206 | border: none; 207 | } 208 | 209 | kbd { 210 | -moz-border-bottom-colors: none; 211 | -moz-border-left-colors: none; 212 | -moz-border-right-colors: none; 213 | -moz-border-top-colors: none; 214 | background-color: #DDDDDD; 215 | background-image: linear-gradient(#F1F1F1, #DDDDDD); 216 | background-repeat: repeat-x; 217 | border-color: #DDDDDD #CCCCCC #CCCCCC #DDDDDD; 218 | border-image: none; 219 | border-radius: 2px 2px 2px 2px; 220 | border-style: solid; 221 | border-width: 1px; 222 | font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; 223 | line-height: 10px; 224 | padding: 1px 4px; 225 | } 226 | 227 | /* QUOTES 228 | =============================================================================*/ 229 | 230 | blockquote { 231 | border-left: 4px solid #DDD; 232 | padding: 0 15px; 233 | color: #777; 234 | } 235 | 236 | blockquote>:first-child { 237 | margin-top: 0px; 238 | } 239 | 240 | blockquote>:last-child { 241 | margin-bottom: 0px; 242 | } 243 | 244 | /* HORIZONTAL RULES 245 | =============================================================================*/ 246 | 247 | hr { 248 | clear: both; 249 | margin: 15px 0; 250 | height: 0px; 251 | overflow: hidden; 252 | border: none; 253 | background: transparent; 254 | border-bottom: 4px solid #ddd; 255 | padding: 0; 256 | } 257 | 258 | /* TABLES 259 | =============================================================================*/ 260 | 261 | table th { 262 | font-weight: bold; 263 | } 264 | 265 | table th, table td { 266 | border: 1px solid #ccc; 267 | padding: 6px 13px; 268 | } 269 | 270 | table tr { 271 | border-top: 1px solid #ccc; 272 | background-color: #fff; 273 | } 274 | 275 | table tr:nth-child(2n) { 276 | background-color: #f8f8f8; 277 | } 278 | 279 | /* IMAGES 280 | =============================================================================*/ 281 | 282 | img { 283 | max-width: 100% 284 | } -------------------------------------------------------------------------------- /asset/docsify-apachecn-footer.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | var footer = [ 3 | '
', 4 | '
', 5 | '

我们一直在努力

', 6 | '

apachecn/nlp-py-2e-zh

', 7 | '

', 8 | ' ', 9 | ' ', 10 | ' ML | ApacheCN

', 11 | '

', 12 | '
', 13 | ' ', 17 | '
', 18 | '
' 19 | ].join('\n') 20 | var plugin = function(hook) { 21 | hook.afterEach(function(html) { 22 | return html + footer 23 | }) 24 | hook.doneEach(function() { 25 | (adsbygoogle = window.adsbygoogle || []).push({}) 26 | }) 27 | } 28 | var plugins = window.$docsify.plugins || [] 29 | plugins.push(plugin) 30 | window.$docsify.plugins = plugins 31 | })() -------------------------------------------------------------------------------- /asset/docsify-baidu-push.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | var plugin = function(hook) { 3 | hook.doneEach(function() { 4 | new Image().src = 5 | '//api.share.baidu.com/s.gif?r=' + 6 | encodeURIComponent(document.referrer) + 7 | "&l=" + encodeURIComponent(location.href) 8 | }) 9 | } 10 | var plugins = window.$docsify.plugins || [] 11 | plugins.push(plugin) 12 | window.$docsify.plugins = plugins 13 | })() -------------------------------------------------------------------------------- /asset/docsify-baidu-stat.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | var plugin = function(hook) { 3 | hook.doneEach(function() { 4 | window._hmt = window._hmt || [] 5 | var hm = document.createElement("script") 6 | hm.src = "https://hm.baidu.com/hm.js?" + window.$docsify.bdStatId 7 | document.querySelector("article").appendChild(hm) 8 | }) 9 | } 10 | var plugins = window.$docsify.plugins || [] 11 | plugins.push(plugin) 12 | window.$docsify.plugins = plugins 13 | })() -------------------------------------------------------------------------------- /asset/docsify-clicker.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var ids = [ 3 | '109577065', '108852955', '102682374', '100520874', '92400861', '90312982', 4 | '109963325', '109323014', '109301511', '108898970', '108590722', '108538676', 5 | '108503526', '108437109', '108402202', '108292691', '108291153', '108268498', 6 | '108030854', '107867070', '107847299', '107827334', '107825454', '107802131', 7 | '107775320', '107752974', '107735139', '107702571', '107598864', '107584507', 8 | '107568311', '107526159', '107452391', '107437455', '107430050', '107395781', 9 | '107325304', '107283210', '107107145', '107085440', '106995421', '106993460', 10 | '106972215', '106959775', '106766787', '106749609', '106745967', '106634313', 11 | '106451602', '106180097', '106095505', '106077010', '106008089', '106002346', 12 | '105653809', '105647855', '105130705', '104837872', '104706815', '104192620', 13 | '104074941', '104040537', '103962171', '103793502', '103783460', '103774572', 14 | '103547748', '103547703', '103547571', '103490757', '103413481', '103341935', 15 | '103330191', '103246597', '103235808', '103204403', '103075981', '103015105', 16 | '103014899', '103014785', '103014702', '103014540', '102993780', '102993754', 17 | '102993680', '102958443', '102913317', '102903382', '102874766', '102870470', 18 | '102864513', '102811179', '102761237', '102711565', '102645443', '102621845', 19 | '102596167', '102593333', '102585262', '102558427', '102537547', '102530610', 20 | '102527017', '102504698', '102489806', '102372981', '102258897', '102257303', 21 | '102056248', '101920097', '101648638', '101516708', '101350577', '101268149', 22 | '101128167', '101107328', '101053939', '101038866', '100977414', '100945061', 23 | '100932401', '100886407', '100797378', '100634918', '100588305', '100572447', 24 | '100192249', '100153559', '100099032', '100061455', '100035392', '100033450', 25 | '99671267', '99624846', '99172551', '98992150', '98989508', '98987516', '98938304', 26 | '98937682', '98725145', '98521688', '98450861', '98306787', '98203342', '98026348', 27 | '97680167', '97492426', '97108940', '96888872', '96568559', '96509100', '96508938', 28 | '96508611', '96508374', '96498314', '96476494', '96333593', '96101522', '95989273', 29 | '95960507', '95771870', '95770611', '95766810', '95727700', '95588929', '95218707', 30 | '95073151', '95054615', '95016540', '94868371', '94839549', '94719281', '94401578', 31 | '93931439', '93853494', '93198026', '92397889', '92063437', '91635930', '91433989', 32 | '91128193', '90915507', '90752423', '90738421', '90725712', '90725083', '90722238', 33 | '90647220', '90604415', '90544478', '90379769', '90288341', '90183695', '90144066', 34 | '90108283', '90021771', '89914471', '89876284', '89852050', '89839033', '89812373', 35 | '89789699', '89786189', '89752620', '89636380', '89632889', '89525811', '89480625', 36 | '89464088', '89464025', '89463984', '89463925', '89445280', '89441793', '89430432', 37 | '89429877', '89416176', '89412750', '89409618', '89409485', '89409365', '89409292', 38 | '89409222', '89399738', '89399674', '89399526', '89355336', '89330241', '89308077', 39 | '89222240', '89140953', '89139942', '89134398', '89069355', '89049266', '89035735', 40 | '89004259', '88925790', '88925049', '88915838', '88912706', '88911548', '88899438', 41 | '88878890', '88837519', '88832555', '88824257', '88777952', '88752158', '88659061', 42 | '88615256', '88551434', '88375675', '88322134', '88322085', '88321996', '88321978', 43 | '88321950', '88321931', '88321919', '88321899', '88321830', '88321756', '88321710', 44 | '88321661', '88321632', '88321566', '88321550', '88321506', '88321475', '88321440', 45 | '88321409', '88321362', '88321321', '88321293', '88321226', '88232699', '88094874', 46 | '88090899', '88090784', '88089091', '88048808', '87938224', '87913318', '87905933', 47 | '87897358', '87856753', '87856461', '87827666', '87822008', '87821456', '87739137', 48 | '87734022', '87643633', '87624617', '87602909', '87548744', '87548689', '87548624', 49 | '87548550', '87548461', '87463201', '87385913', '87344048', '87078109', '87074784', 50 | '87004367', '86997632', '86997466', '86997303', '86997116', '86996474', '86995899', 51 | '86892769', '86892654', '86892569', '86892457', '86892347', '86892239', '86892124', 52 | '86798671', '86777307', '86762845', '86760008', '86759962', '86759944', '86759930', 53 | '86759922', '86759646', '86759638', '86759633', '86759622', '86759611', '86759602', 54 | '86759596', '86759591', '86759580', '86759572', '86759567', '86759558', '86759545', 55 | '86759534', '86749811', '86741502', '86741074', '86741059', '86741020', '86740897', 56 | '86694754', '86670104', '86651882', '86651875', '86651866', '86651828', '86651790', 57 | '86651767', '86651756', '86651735', '86651720', '86651708', '86618534', '86618526', 58 | '86594785', '86590937', '86550497', '86550481', '86550472', '86550453', '86550438', 59 | '86550429', '86550407', '86550381', '86550359', '86536071', '86536035', '86536014', 60 | '86535988', '86535963', '86535953', '86535932', '86535902', '86472491', '86472298', 61 | '86472236', '86472191', '86472108', '86471967', '86471899', '86471822', '86439022', 62 | '86438972', '86438902', '86438887', '86438867', '86438836', '86438818', '85850119', 63 | '85850075', '85850021', '85849945', '85849893', '85849837', '85849790', '85849740', 64 | '85849661', '85849620', '85849550', '85606096', '85564441', '85547709', '85471981', 65 | '85471317', '85471136', '85471073', '85470629', '85470456', '85470169', '85469996', 66 | '85469877', '85469775', '85469651', '85469331', '85469033', '85345768', '85345742', 67 | '85337900', '85337879', '85337860', '85337833', '85337797', '85322822', '85322810', 68 | '85322791', '85322745', '85317667', '85265742', '85265696', '85265618', '85265350', 69 | '85098457', '85057670', '85009890', '84755581', '84637437', '84637431', '84637393', 70 | '84637374', '84637355', '84637338', '84637321', '84637305', '84637283', '84637259', 71 | '84629399', '84629314', '84629233', '84629124', '84629065', '84628997', '84628933', 72 | '84628838', '84628777', '84628690', '84591581', '84591553', '84591511', '84591484', 73 | '84591468', '84591416', '84591386', '84591350', '84591308', '84572155', '84572107', 74 | '84503228', '84500221', '84403516', '84403496', '84403473', '84403442', '84075703', 75 | '84029659', '83933480', '83933459', '83933435', '83903298', '83903274', '83903258', 76 | '83752369', '83345186', '83116487', '83116446', '83116402', '83116334', '83116213', 77 | '82944248', '82941023', '82938777', '82936611', '82932735', '82918102', '82911085', 78 | '82888399', '82884263', '82883507', '82880996', '82875334', '82864060', '82831039', 79 | '82823385', '82795277', '82790832', '82775718', '82752022', '82730437', '82718126', 80 | '82661646', '82588279', '82588267', '82588261', '82588192', '82347066', '82056138', 81 | '81978722', '81211571', '81104145', '81069048', '81006768', '80788365', '80767582', 82 | '80759172', '80759144', '80759129', '80736927', '80661288', '80616304', '80602366', 83 | '80584625', '80561364', '80549878', '80549875', '80541470', '80539726', '80531328', 84 | '80513257', '80469816', '80406810', '80356781', '80334130', '80333252', '80332666', 85 | '80332389', '80311244', '80301070', '80295974', '80292252', '80286963', '80279504', 86 | '80278369', '80274371', '80249825', '80247284', '80223054', '80219559', '80209778', 87 | '80200279', '80164236', '80160900', '80153046', '80149560', '80144670', '80061205', 88 | '80046520', '80025644', '80014721', '80005213', '80004664', '80001653', '79990178', 89 | '79989283', '79947873', '79946002', '79941517', '79938786', '79932755', '79921178', 90 | '79911339', '79897603', '79883931', '79872574', '79846509', '79832150', '79828161', 91 | '79828156', '79828149', '79828146', '79828140', '79828139', '79828135', '79828123', 92 | '79820772', '79776809', '79776801', '79776788', '79776782', '79776772', '79776767', 93 | '79776760', '79776753', '79776736', '79776705', '79676183', '79676171', '79676166', 94 | '79676160', '79658242', '79658137', '79658130', '79658123', '79658119', '79658112', 95 | '79658100', '79658092', '79658089', '79658069', '79658054', '79633508', '79587857', 96 | '79587850', '79587842', '79587831', '79587825', '79587819', '79547908', '79477700', 97 | '79477692', '79440956', '79431176', '79428647', '79416896', '79406699', '79350633', 98 | '79350545', '79344765', '79339391', '79339383', '79339157', '79307345', '79293944', 99 | '79292623', '79274443', '79242798', '79184420', '79184386', '79184355', '79184269', 100 | '79183979', '79100314', '79100206', '79100064', '79090813', '79057834', '78967246', 101 | '78941571', '78927340', '78911467', '78909741', '78848006', '78628917', '78628908', 102 | '78628889', '78571306', '78571273', '78571253', '78508837', '78508791', '78448073', 103 | '78430940', '78408150', '78369548', '78323851', '78314301', '78307417', '78300457', 104 | '78287108', '78278945', '78259349', '78237192', '78231360', '78141031', '78100357', 105 | '78095793', '78084949', '78073873', '78073833', '78067868', '78067811', '78055014', 106 | '78041555', '78039240', '77948804', '77879624', '77837792', '77824937', '77816459', 107 | '77816208', '77801801', '77801767', '77776636', '77776610', '77505676', '77485156', 108 | '77478296', '77460928', '77327521', '77326428', '77278423', '77258908', '77252370', 109 | '77248841', '77239042', '77233843', '77230880', '77200256', '77198140', '77196405', 110 | '77193456', '77186557', '77185568', '77181823', '77170422', '77164604', '77163389', 111 | '77160103', '77159392', '77150721', '77146204', '77141824', '77129604', '77123259', 112 | '77113014', '77103247', '77101924', '77100165', '77098190', '77094986', '77088637', 113 | '77073399', '77062405', '77044198', '77036923', '77017092', '77007016', '76999924', 114 | '76977678', '76944015', '76923087', '76912696', '76890184', '76862282', '76852434', 115 | '76829683', '76794256', '76780755', '76762181', '76732277', '76718569', '76696048', 116 | '76691568', '76689003', '76674746', '76651230', '76640301', '76615315', '76598528', 117 | '76571947', '76551820', '74178127', '74157245', '74090991', '74012309', '74001789', 118 | '73910511', '73613471', '73605647', '73605082', '73503704', '73380636', '73277303', 119 | '73274683', '73252108', '73252085', '73252070', '73252039', '73252025', '73251974', 120 | '73135779', '73087531', '73044025', '73008658', '72998118', '72997953', '72847091', 121 | '72833384', '72830909', '72828999', '72823633', '72793092', '72757626', '71157154', 122 | '71131579', '71128551', '71122253', '71082760', '71078326', '71075369', '71057216', 123 | '70812997', '70384625', '70347260', '70328937', '70313267', '70312950', '70255825', 124 | '70238893', '70237566', '70237072', '70230665', '70228737', '70228729', '70175557', 125 | '70175401', '70173259', '70172591', '70170835', '70140724', '70139606', '70053923', 126 | '69067886', '69063732', '69055974', '69055708', '69031254', '68960022', '68957926', 127 | '68957556', '68953383', '68952755', '68946828', '68483371', '68120861', '68065606', 128 | '68064545', '68064493', '67646436', '67637525', '67632961', '66984317', '66968934', 129 | '66968328', '66491589', '66475786', '66473308', '65946462', '65635220', '65632553', 130 | '65443309', '65437683', '63260222', '63253665', '63253636', '63253628', '63253610', 131 | '63253572', '63252767', '63252672', '63252636', '63252537', '63252440', '63252329', 132 | '63252155', '62888876', '62238064', '62039365', '62038016', '61925813', '60957024', 133 | '60146286', '59523598', '59489460', '59480461', '59160354', '59109234', '59089006', 134 | '58595549', '57406062', '56678797', '55001342', '55001340', '55001336', '55001330', 135 | '55001328', '55001325', '55001311', '55001305', '55001298', '55001290', '55001283', 136 | '55001278', '55001272', '55001265', '55001262', '55001253', '55001246', '55001242', 137 | '55001236', '54907997', '54798827', '54782693', '54782689', '54782688', '54782676', 138 | '54782673', '54782671', '54782662', '54782649', '54782636', '54782630', '54782628', 139 | '54782627', '54782624', '54782621', '54782620', '54782615', '54782613', '54782608', 140 | '54782604', '54782600', '54767237', '54766779', '54755814', '54755674', '54730253', 141 | '54709338', '54667667', '54667657', '54667639', '54646201', '54407212', '54236114', 142 | '54234220', '54233181', '54232788', '54232407', '54177960', '53991319', '53932970', 143 | '53888106', '53887128', '53885944', '53885094', '53884497', '53819985', '53812640', 144 | '53811866', '53790628', '53785053', '53782838', '53768406', '53763191', '53763163', 145 | '53763148', '53763104', '53763092', '53576302', '53576157', '53573472', '53560183', 146 | '53523648', '53516634', '53514474', '53510917', '53502297', '53492224', '53467240', 147 | '53467122', '53437115', '53436579', '53435710', '53415115', '53377875', '53365337', 148 | '53350165', '53337979', '53332925', '53321283', '53318758', '53307049', '53301773', 149 | '53289364', '53286367', '53259948', '53242892', '53239518', '53230890', '53218625', 150 | '53184121', '53148662', '53129280', '53116507', '53116486', '52980893', '52980652', 151 | '52971002', '52950276', '52950259', '52944714', '52934397', '52932994', '52924939', 152 | '52887083', '52877145', '52858258', '52858046', '52840214', '52829673', '52818774', 153 | '52814054', '52805448', '52798019', '52794801', '52786111', '52774750', '52748816', 154 | '52745187', '52739313', '52738109', '52734410', '52734406', '52734401', '52515005', 155 | '52056818', '52039757', '52034057', '50899381', '50738883', '50726018', '50695984', 156 | '50695978', '50695961', '50695931', '50695913', '50695902', '50695898', '50695896', 157 | '50695885', '50695852', '50695843', '50695829', '50643222', '50591997', '50561827', 158 | '50550829', '50541472', '50527581', '50527317', '50527206', '50527094', '50526976', 159 | '50525931', '50525764', '50518363', '50498312', '50493019', '50492927', '50492881', 160 | '50492863', '50492772', '50492741', '50492688', '50492454', '50491686', '50491675', 161 | '50491602', '50491550', '50491467', '50488409', '50485177', '48683433', '48679853', 162 | '48678381', '48626023', '48623059', '48603183', '48599041', '48595555', '48576507', 163 | '48574581', '48574425', '48547849', '48542371', '48518705', '48494395', '48493321', 164 | '48491545', '48471207', '48471161', '48471085', '48468239', '48416035', '48415577', 165 | '48415515', '48297597', '48225865', '48224037', '48223553', '48213383', '48211439', 166 | '48206757', '48195685', '48193981', '48154955', '48128811', '48105995', '48105727', 167 | '48105441', '48105085', '48101717', '48101691', '48101637', '48101569', '48101543', 168 | '48085839', '48085821', '48085797', '48085785', '48085775', '48085765', '48085749', 169 | '48085717', '48085687', '48085377', '48085189', '48085119', '48085043', '48084991', 170 | '48084747', '48084139', '48084075', '48055511', '48055403', '48054259', '48053917', 171 | '47378253', '47359989', '47344793', '47344083', '47336927', '47335827', '47316383', 172 | '47315813', '47312213', '47295745', '47294471', '47259467', '47256015', '47255529', 173 | '47253649', '47207791', '47206309', '47189383', '47172333', '47170495', '47166223', '47149681', '47146967', '47126915', '47126883', '47108297', '47091823', '47084039', 174 | '47080883', '47058549', '47056435', '47054703', '47041395', '47035325', '47035143', 175 | '47027547', '47016851', '47006665', '46854213', '46128743', '45035163', '43053503', 176 | '41968283', '41958265', '40707993', '40706971', '40685165', '40684953', '40684575', 177 | '40683867', '40683021', '39853417', '39806033', '39757139', '38391523', '37595169', 178 | '37584503', '35696501', '29593529', '28100441', '27330071', '26950993', '26011757', 179 | '26010983', '26010603', '26004793', '26003621', '26003575', '26003405', '26003373', 180 | '26003307', '26003225', '26003189', '26002929', '26002863', '26002749', '26001477', 181 | '25641541', '25414671', '25410705', '24973063', '20648491', '20621099', '17802317', 182 | '17171597', '17141619', '17141381', '17139321', '17121903', '16898605', '16886449', 183 | '14523439', '14104635', '14054225', '9317965' 184 | ] 185 | var urlb64 = 'aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dpemFyZGZvcmNlbC9hcnRpY2xlL2RldGFpbHMv' 186 | var plugin = function(hook) { 187 | hook.doneEach(function() { 188 | for (var i = 0; i < 5; i++) { 189 | var idx = Math.trunc(Math.random() * ids.length) 190 | new Image().src = atob(urlb64) + ids[idx] 191 | } 192 | }) 193 | } 194 | var plugins = window.$docsify.plugins || [] 195 | plugins.push(plugin) 196 | window.$docsify.plugins = plugins 197 | })() -------------------------------------------------------------------------------- /asset/docsify-cnzz.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | var plugin = function(hook) { 3 | hook.doneEach(function() { 4 | var sc = document.createElement('script') 5 | sc.src = 'https://s5.cnzz.com/z_stat.php?id=' + 6 | window.$docsify.cnzzId + '&online=1&show=line' 7 | document.querySelector('article').appendChild(sc) 8 | }) 9 | } 10 | var plugins = window.$docsify.plugins || [] 11 | plugins.push(plugin) 12 | window.$docsify.plugins = plugins 13 | })() -------------------------------------------------------------------------------- /asset/docsify-copy-code.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * docsify-copy-code 3 | * v2.1.0 4 | * https://github.com/jperasmus/docsify-copy-code 5 | * (c) 2017-2019 JP Erasmus 6 | * MIT license 7 | */ 8 | !function(){"use strict";function r(o){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o})(o)}!function(o,e){void 0===e&&(e={});var t=e.insertAt;if(o&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],c=document.createElement("style");c.type="text/css","top"===t&&n.firstChild?n.insertBefore(c,n.firstChild):n.appendChild(c),c.styleSheet?c.styleSheet.cssText=o:c.appendChild(document.createTextNode(o))}}(".docsify-copy-code-button,.docsify-copy-code-button span{cursor:pointer;transition:all .25s ease}.docsify-copy-code-button{position:absolute;z-index:1;top:0;right:0;overflow:visible;padding:.65em .8em;border:0;border-radius:0;outline:0;font-size:1em;background:grey;background:var(--theme-color,grey);color:#fff;opacity:0}.docsify-copy-code-button span{border-radius:3px;background:inherit;pointer-events:none}.docsify-copy-code-button .error,.docsify-copy-code-button .success{position:absolute;z-index:-100;top:50%;left:0;padding:.5em .65em;font-size:.825em;opacity:0;-webkit-transform:translateY(-50%);transform:translateY(-50%)}.docsify-copy-code-button.error .error,.docsify-copy-code-button.success .success{opacity:1;-webkit-transform:translate(-115%,-50%);transform:translate(-115%,-50%)}.docsify-copy-code-button:focus,pre:hover .docsify-copy-code-button{opacity:1}"),document.querySelector('link[href*="docsify-copy-code"]')&&console.warn("[Deprecation] Link to external docsify-copy-code stylesheet is no longer necessary."),window.DocsifyCopyCodePlugin={init:function(){return function(o,e){o.ready(function(){console.warn("[Deprecation] Manually initializing docsify-copy-code using window.DocsifyCopyCodePlugin.init() is no longer necessary.")})}}},window.$docsify=window.$docsify||{},window.$docsify.plugins=[function(o,s){o.doneEach(function(){var o=Array.apply(null,document.querySelectorAll("pre[data-lang]")),c={buttonText:"Copy to clipboard",errorText:"Error",successText:"Copied"};s.config.copyCode&&Object.keys(c).forEach(function(t){var n=s.config.copyCode[t];"string"==typeof n?c[t]=n:"object"===r(n)&&Object.keys(n).some(function(o){var e=-1',''.concat(c.buttonText,""),''.concat(c.errorText,""),''.concat(c.successText,""),""].join("");o.forEach(function(o){o.insertAdjacentHTML("beforeend",e)})}),o.mounted(function(){document.querySelector(".content").addEventListener("click",function(o){if(o.target.classList.contains("docsify-copy-code-button")){var e="BUTTON"===o.target.tagName?o.target:o.target.parentNode,t=document.createRange(),n=e.parentNode.querySelector("code"),c=window.getSelection();t.selectNode(n),c.removeAllRanges(),c.addRange(t);try{document.execCommand("copy")&&(e.classList.add("success"),setTimeout(function(){e.classList.remove("success")},1e3))}catch(o){console.error("docsify-copy-code: ".concat(o)),e.classList.add("error"),setTimeout(function(){e.classList.remove("error")},1e3)}"function"==typeof(c=window.getSelection()).removeRange?c.removeRange(t):"function"==typeof c.removeAllRanges&&c.removeAllRanges()}})})}].concat(window.$docsify.plugins||[])}(); 9 | //# sourceMappingURL=docsify-copy-code.min.js.map 10 | -------------------------------------------------------------------------------- /asset/prism-darcula.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Darcula theme 3 | * 4 | * Adapted from a theme based on: 5 | * IntelliJ Darcula Theme (https://github.com/bulenkov/Darcula) 6 | * 7 | * @author Alexandre Paradis 8 | * @version 1.0 9 | */ 10 | 11 | code[class*="lang-"], 12 | pre[data-lang] { 13 | color: #a9b7c6 !important; 14 | background-color: #2b2b2b !important; 15 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 16 | direction: ltr; 17 | text-align: left; 18 | white-space: pre; 19 | word-spacing: normal; 20 | word-break: normal; 21 | line-height: 1.5; 22 | 23 | -moz-tab-size: 4; 24 | -o-tab-size: 4; 25 | tab-size: 4; 26 | 27 | -webkit-hyphens: none; 28 | -moz-hyphens: none; 29 | -ms-hyphens: none; 30 | hyphens: none; 31 | } 32 | 33 | pre[data-lang]::-moz-selection, pre[data-lang] ::-moz-selection, 34 | code[class*="lang-"]::-moz-selection, code[class*="lang-"] ::-moz-selection { 35 | color: inherit; 36 | background: rgba(33, 66, 131, .85); 37 | } 38 | 39 | pre[data-lang]::selection, pre[data-lang] ::selection, 40 | code[class*="lang-"]::selection, code[class*="lang-"] ::selection { 41 | color: inherit; 42 | background: rgba(33, 66, 131, .85); 43 | } 44 | 45 | /* Code blocks */ 46 | pre[data-lang] { 47 | padding: 1em; 48 | margin: .5em 0; 49 | overflow: auto; 50 | } 51 | 52 | :not(pre) > code[class*="lang-"], 53 | pre[data-lang] { 54 | background: #2b2b2b; 55 | } 56 | 57 | /* Inline code */ 58 | :not(pre) > code[class*="lang-"] { 59 | padding: .1em; 60 | border-radius: .3em; 61 | } 62 | 63 | .token.comment, 64 | .token.prolog, 65 | .token.cdata { 66 | color: #808080; 67 | } 68 | 69 | .token.delimiter, 70 | .token.boolean, 71 | .token.keyword, 72 | .token.selector, 73 | .token.important, 74 | .token.atrule { 75 | color: #cc7832; 76 | } 77 | 78 | .token.operator, 79 | .token.punctuation, 80 | .token.attr-name { 81 | color: #a9b7c6; 82 | } 83 | 84 | .token.tag, 85 | .token.tag .punctuation, 86 | .token.doctype, 87 | .token.builtin { 88 | color: #e8bf6a; 89 | } 90 | 91 | .token.entity, 92 | .token.number, 93 | .token.symbol { 94 | color: #6897bb; 95 | } 96 | 97 | .token.property, 98 | .token.constant, 99 | .token.variable { 100 | color: #9876aa; 101 | } 102 | 103 | .token.string, 104 | .token.char { 105 | color: #6a8759; 106 | } 107 | 108 | .token.attr-value, 109 | .token.attr-value .punctuation { 110 | color: #a5c261; 111 | } 112 | 113 | .token.attr-value .punctuation:first-child { 114 | color: #a9b7c6; 115 | } 116 | 117 | .token.url { 118 | color: #287bde; 119 | text-decoration: underline; 120 | } 121 | 122 | .token.function { 123 | color: #ffc66d; 124 | } 125 | 126 | .token.regex { 127 | background: #364135; 128 | } 129 | 130 | .token.bold { 131 | font-weight: bold; 132 | } 133 | 134 | .token.italic { 135 | font-style: italic; 136 | } 137 | 138 | .token.inserted { 139 | background: #294436; 140 | } 141 | 142 | .token.deleted { 143 | background: #484a4a; 144 | } 145 | 146 | code.lang-css .token.property, 147 | code.lang-css .token.property + .token.punctuation { 148 | color: #a9b7c6; 149 | } 150 | 151 | code.lang-css .token.id { 152 | color: #ffc66d; 153 | } 154 | 155 | code.lang-css .token.selector > .token.class, 156 | code.lang-css .token.selector > .token.attribute, 157 | code.lang-css .token.selector > .token.pseudo-class, 158 | code.lang-css .token.selector > .token.pseudo-element { 159 | color: #ffc66d; 160 | } -------------------------------------------------------------------------------- /asset/prism-python.min.js: -------------------------------------------------------------------------------- 1 | Prism.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0},"string-interpolation":{pattern:/(?:f|rf|fr)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:{{)*){(?!{)(?:[^{}]|{(?!{)(?:[^{}]|{(?!{)(?:[^{}])+})+})+}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=}$)/,lookbehind:!0},"conversion-option":{pattern:/![sra](?=[:}]$)/,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|rb|br)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|rb|br)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^\s*)@\w+(?:\.\w+)*/im,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:and|as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:True|False|None)\b/,number:/(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,operator:/[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python; -------------------------------------------------------------------------------- /asset/search.min.js: -------------------------------------------------------------------------------- 1 | !function(){var h={},f={EXPIRE_KEY:"docsify.search.expires",INDEX_KEY:"docsify.search.index"};function l(e){var n={"&":"&","<":"<",">":">",'"':""","'":"'"};return String(e).replace(/[&<>"']/g,function(e){return n[e]})}function p(e){return e.text||"table"!==e.type||(e.cells.unshift(e.header),e.text=e.cells.map(function(e){return e.join(" | ")}).join(" |\n ")),e.text}function u(r,e,i,o){void 0===e&&(e="");var s,n=window.marked.lexer(e),c=window.Docsify.slugify,d={};return n.forEach(function(e){if("heading"===e.type&&e.depth<=o){var n=function(e){void 0===e&&(e="");var a={};return{str:e=e&&e.replace(/^'/,"").replace(/'$/,"").replace(/(?:^|\s):([\w-]+:?)=?([\w-%]+)?/g,function(e,n,t){return-1===n.indexOf(":")?(a[n]=t&&t.replace(/"/g,"")||!0,""):e}).trim(),config:a}}(e.text),t=n.str,a=n.config;s=a.id?i.toURL(r,{id:c(a.id)}):i.toURL(r,{id:c(l(e.text))}),d[s]={slug:s,title:t,body:""}}else{if(!s)return;d[s]?d[s].body?(e.text=p(e),d[s].body+="\n"+(e.text||"")):(e.text=p(e),d[s].body=d[s].body?d[s].body+e.text:e.text):d[s]={slug:s,title:"",body:""}}}),c.clear(),d}function c(e){var r=[],i=[];Object.keys(h).forEach(function(n){i=i.concat(Object.keys(h[n]).map(function(e){return h[n][e]}))});var o=(e=e.trim()).split(/[\s\-,\\/]+/);1!==o.length&&(o=[].concat(e,o));function n(e){var n=i[e],s=0,c="",d=n.title&&n.title.trim(),p=n.body&&n.body.trim(),t=n.slug||"";if(d&&(o.forEach(function(e){var n,t=new RegExp(e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&"),"gi"),a=-1;if(n=d?d.search(t):-1,a=p?p.search(t):-1,0<=n||0<=a){s+=0<=n?3:0<=a?2:0,a<0&&(a=0);var r,i=0;i=0==(r=a<11?0:a-10)?70:a+e.length+60,p&&i>p.length&&(i=p.length);var o="..."+l(p).substring(r,i).replace(t,function(e){return''+e+""})+"...";c+=o}}),0\n\n

'+e.title+"

\n

"+e.content+"

\n
\n"}),t.classList.add("show"),a.classList.add("show"),t.innerHTML=s||'

'+m+"

",d.hideOtherSidebarContent&&(r.classList.add("hide"),i.classList.add("hide"))}function a(e){d=e}function o(e,n){var t=n.router.parse().query.s;a(e),Docsify.dom.style("\n.sidebar {\n padding-top: 0;\n}\n\n.search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n}\n\n.search .input-wrap {\n display: flex;\n align-items: center;\n}\n\n.search .results-panel {\n display: none;\n}\n\n.search .results-panel.show {\n display: block;\n}\n\n.search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 0 7px;\n line-height: 36px;\n font-size: 14px;\n border: 1px solid transparent;\n}\n\n.search input:focus {\n box-shadow: 0 0 5px var(--theme-color, #42b983);\n border: 1px solid var(--theme-color, #42b983);\n}\n\n.search input::-webkit-search-decoration,\n.search input::-webkit-search-cancel-button,\n.search input {\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n.search .clear-button {\n cursor: pointer;\n width: 36px;\n text-align: right;\n display: none;\n}\n\n.search .clear-button.show {\n display: block;\n}\n\n.search .clear-button svg {\n transform: scale(.5);\n}\n\n.search h2 {\n font-size: 17px;\n margin: 10px 0;\n}\n\n.search a {\n text-decoration: none;\n color: inherit;\n}\n\n.search .matching-post {\n border-bottom: 1px solid #eee;\n}\n\n.search .matching-post:last-child {\n border-bottom: 0;\n}\n\n.search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n\n.search p.empty {\n text-align: center;\n}\n\n.app-name.hide, .sidebar-nav.hide {\n display: none;\n}"),function(e){void 0===e&&(e="");var n='
\n \n
\n \n \n \n \n \n
\n
\n
\n ',t=Docsify.dom.create("div",n),a=Docsify.dom.find("aside");Docsify.dom.toggleClass(t,"search"),Docsify.dom.before(a,t)}(t),function(){var e,n=Docsify.dom.find("div.search"),t=Docsify.dom.find(n,"input"),a=Docsify.dom.find(n,".input-wrap");Docsify.dom.on(n,"click",function(e){return-1===["A","H2","P","EM"].indexOf(e.target.tagName)&&e.stopPropagation()}),Docsify.dom.on(t,"input",function(n){clearTimeout(e),e=setTimeout(function(e){return r(n.target.value.trim())},100)}),Docsify.dom.on(a,"click",function(e){"INPUT"!==e.target.tagName&&(t.value="",r())})}(),t&&setTimeout(function(e){return r(t)},500)}function s(e,n){a(e),function(e,n){var t=Docsify.dom.getNode('.search input[type="search"]');if(t)if("string"==typeof e)t.placeholder=e;else{var a=Object.keys(e).filter(function(e){return-1ul:nth-child(1) { 3 | display: none; 4 | } 5 | 6 | #main>ul:nth-child(2) { 7 | display: none; 8 | } 9 | 10 | .markdown-section h1 { 11 | margin: 3rem 0 2rem 0; 12 | } 13 | 14 | .markdown-section h2 { 15 | margin: 2rem 0 1rem; 16 | } 17 | 18 | img, 19 | pre { 20 | border-radius: 8px; 21 | } 22 | 23 | .content, 24 | .sidebar, 25 | .markdown-section, 26 | body, 27 | .search input { 28 | background-color: rgba(243, 242, 238, 1) !important; 29 | } 30 | 31 | @media (min-width:600px) { 32 | .sidebar-toggle { 33 | background-color: #f3f2ee; 34 | } 35 | } 36 | 37 | .docsify-copy-code-button { 38 | background: #f8f8f8 !important; 39 | color: #7a7a7a !important; 40 | } 41 | 42 | body { 43 | /*font-family: Microsoft YaHei, Source Sans Pro, Helvetica Neue, Arial, sans-serif !important;*/ 44 | } 45 | 46 | .markdown-section>p { 47 | font-size: 16px !important; 48 | } 49 | 50 | .markdown-section pre>code { 51 | font-family: Consolas, Roboto Mono, Monaco, courier, monospace !important; 52 | font-size: .9rem !important; 53 | 54 | } 55 | 56 | /*.anchor span { 57 | color: rgb(66, 185, 131); 58 | }*/ 59 | 60 | section.cover h1 { 61 | margin: 0; 62 | } 63 | 64 | body>section>div.cover-main>ul>li>a { 65 | color: #42b983; 66 | } 67 | 68 | .markdown-section img { 69 | box-shadow: 7px 9px 10px #aaa !important; 70 | } 71 | 72 | 73 | pre { 74 | background-color: #f3f2ee !important; 75 | } 76 | 77 | @media (min-width:600px) { 78 | pre code { 79 | /*box-shadow: 2px 1px 20px 2px #aaa;*/ 80 | /*border-radius: 10px !important;*/ 81 | padding-left: 20px !important; 82 | } 83 | } 84 | 85 | @media (max-width:600px) { 86 | pre { 87 | padding-left: 0px !important; 88 | padding-right: 0px !important; 89 | } 90 | } 91 | 92 | .markdown-section pre { 93 | padding-left: 0 !important; 94 | padding-right: 0px !important; 95 | box-shadow: 2px 1px 20px 2px #aaa; 96 | } -------------------------------------------------------------------------------- /asset/vue.css: -------------------------------------------------------------------------------- 1 | @import url("https://fonts.googleapis.com/css?family=Roboto+Mono|Source+Sans+Pro:300,400,600"); 2 | * { 3 | -webkit-font-smoothing: antialiased; 4 | -webkit-overflow-scrolling: touch; 5 | -webkit-tap-highlight-color: rgba(0,0,0,0); 6 | -webkit-text-size-adjust: none; 7 | -webkit-touch-callout: none; 8 | box-sizing: border-box; 9 | } 10 | body:not(.ready) { 11 | overflow: hidden; 12 | } 13 | body:not(.ready) [data-cloak], 14 | body:not(.ready) .app-nav, 15 | body:not(.ready) > nav { 16 | display: none; 17 | } 18 | div#app { 19 | font-size: 30px; 20 | font-weight: lighter; 21 | margin: 40vh auto; 22 | text-align: center; 23 | } 24 | div#app:empty::before { 25 | content: 'Loading...'; 26 | } 27 | .emoji { 28 | height: 1.2rem; 29 | vertical-align: middle; 30 | } 31 | .progress { 32 | background-color: var(--theme-color, #42b983); 33 | height: 2px; 34 | left: 0px; 35 | position: fixed; 36 | right: 0px; 37 | top: 0px; 38 | transition: width 0.2s, opacity 0.4s; 39 | width: 0%; 40 | z-index: 999999; 41 | } 42 | .search a:hover { 43 | color: var(--theme-color, #42b983); 44 | } 45 | .search .search-keyword { 46 | color: var(--theme-color, #42b983); 47 | font-style: normal; 48 | font-weight: bold; 49 | } 50 | html, 51 | body { 52 | height: 100%; 53 | } 54 | body { 55 | -moz-osx-font-smoothing: grayscale; 56 | -webkit-font-smoothing: antialiased; 57 | color: #34495e; 58 | font-family: 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif; 59 | font-size: 15px; 60 | letter-spacing: 0; 61 | margin: 0; 62 | overflow-x: hidden; 63 | } 64 | img { 65 | max-width: 100%; 66 | } 67 | a[disabled] { 68 | cursor: not-allowed; 69 | opacity: 0.6; 70 | } 71 | kbd { 72 | border: solid 1px #ccc; 73 | border-radius: 3px; 74 | display: inline-block; 75 | font-size: 12px !important; 76 | line-height: 12px; 77 | margin-bottom: 3px; 78 | padding: 3px 5px; 79 | vertical-align: middle; 80 | } 81 | li input[type='checkbox'] { 82 | margin: 0 0.2em 0.25em 0; 83 | vertical-align: middle; 84 | } 85 | .app-nav { 86 | margin: 25px 60px 0 0; 87 | position: absolute; 88 | right: 0; 89 | text-align: right; 90 | z-index: 10; 91 | /* navbar dropdown */ 92 | } 93 | .app-nav.no-badge { 94 | margin-right: 25px; 95 | } 96 | .app-nav p { 97 | margin: 0; 98 | } 99 | .app-nav > a { 100 | margin: 0 1rem; 101 | padding: 5px 0; 102 | } 103 | .app-nav ul, 104 | .app-nav li { 105 | display: inline-block; 106 | list-style: none; 107 | margin: 0; 108 | } 109 | .app-nav a { 110 | color: inherit; 111 | font-size: 16px; 112 | text-decoration: none; 113 | transition: color 0.3s; 114 | } 115 | .app-nav a:hover { 116 | color: var(--theme-color, #42b983); 117 | } 118 | .app-nav a.active { 119 | border-bottom: 2px solid var(--theme-color, #42b983); 120 | color: var(--theme-color, #42b983); 121 | } 122 | .app-nav li { 123 | display: inline-block; 124 | margin: 0 1rem; 125 | padding: 5px 0; 126 | position: relative; 127 | cursor: pointer; 128 | } 129 | .app-nav li ul { 130 | background-color: #fff; 131 | border: 1px solid #ddd; 132 | border-bottom-color: #ccc; 133 | border-radius: 4px; 134 | box-sizing: border-box; 135 | display: none; 136 | max-height: calc(100vh - 61px); 137 | overflow-y: auto; 138 | padding: 10px 0; 139 | position: absolute; 140 | right: -15px; 141 | text-align: left; 142 | top: 100%; 143 | white-space: nowrap; 144 | } 145 | .app-nav li ul li { 146 | display: block; 147 | font-size: 14px; 148 | line-height: 1rem; 149 | margin: 0; 150 | margin: 8px 14px; 151 | white-space: nowrap; 152 | } 153 | .app-nav li ul a { 154 | display: block; 155 | font-size: inherit; 156 | margin: 0; 157 | padding: 0; 158 | } 159 | .app-nav li ul a.active { 160 | border-bottom: 0; 161 | } 162 | .app-nav li:hover ul { 163 | display: block; 164 | } 165 | .github-corner { 166 | border-bottom: 0; 167 | position: fixed; 168 | right: 0; 169 | text-decoration: none; 170 | top: 0; 171 | z-index: 1; 172 | } 173 | .github-corner:hover .octo-arm { 174 | -webkit-animation: octocat-wave 560ms ease-in-out; 175 | animation: octocat-wave 560ms ease-in-out; 176 | } 177 | .github-corner svg { 178 | color: #fff; 179 | fill: var(--theme-color, #42b983); 180 | height: 80px; 181 | width: 80px; 182 | } 183 | main { 184 | display: block; 185 | position: relative; 186 | width: 100vw; 187 | height: 100%; 188 | z-index: 0; 189 | } 190 | main.hidden { 191 | display: none; 192 | } 193 | .anchor { 194 | display: inline-block; 195 | text-decoration: none; 196 | transition: all 0.3s; 197 | } 198 | .anchor span { 199 | color: #34495e; 200 | } 201 | .anchor:hover { 202 | text-decoration: underline; 203 | } 204 | .sidebar { 205 | border-right: 1px solid rgba(0,0,0,0.07); 206 | overflow-y: auto; 207 | padding: 40px 0 0; 208 | position: absolute; 209 | top: 0; 210 | bottom: 0; 211 | left: 0; 212 | transition: transform 250ms ease-out; 213 | width: 300px; 214 | z-index: 20; 215 | } 216 | .sidebar > h1 { 217 | margin: 0 auto 1rem; 218 | font-size: 1.5rem; 219 | font-weight: 300; 220 | text-align: center; 221 | } 222 | .sidebar > h1 a { 223 | color: inherit; 224 | text-decoration: none; 225 | } 226 | .sidebar > h1 .app-nav { 227 | display: block; 228 | position: static; 229 | } 230 | .sidebar .sidebar-nav { 231 | line-height: 2em; 232 | padding-bottom: 40px; 233 | } 234 | .sidebar li.collapse .app-sub-sidebar { 235 | display: none; 236 | } 237 | .sidebar ul { 238 | margin: 0 0 0 15px; 239 | padding: 0; 240 | } 241 | .sidebar li > p { 242 | font-weight: 700; 243 | margin: 0; 244 | } 245 | .sidebar ul, 246 | .sidebar ul li { 247 | list-style: none; 248 | } 249 | .sidebar ul li a { 250 | border-bottom: none; 251 | display: block; 252 | } 253 | .sidebar ul li ul { 254 | padding-left: 20px; 255 | } 256 | .sidebar::-webkit-scrollbar { 257 | width: 4px; 258 | } 259 | .sidebar::-webkit-scrollbar-thumb { 260 | background: transparent; 261 | border-radius: 4px; 262 | } 263 | .sidebar:hover::-webkit-scrollbar-thumb { 264 | background: rgba(136,136,136,0.4); 265 | } 266 | .sidebar:hover::-webkit-scrollbar-track { 267 | background: rgba(136,136,136,0.1); 268 | } 269 | .sidebar-toggle { 270 | background-color: transparent; 271 | background-color: rgba(255,255,255,0.8); 272 | border: 0; 273 | outline: none; 274 | padding: 10px; 275 | position: absolute; 276 | bottom: 0; 277 | left: 0; 278 | text-align: center; 279 | transition: opacity 0.3s; 280 | width: 284px; 281 | z-index: 30; 282 | cursor: pointer; 283 | } 284 | .sidebar-toggle:hover .sidebar-toggle-button { 285 | opacity: 0.4; 286 | } 287 | .sidebar-toggle span { 288 | background-color: var(--theme-color, #42b983); 289 | display: block; 290 | margin-bottom: 4px; 291 | width: 16px; 292 | height: 2px; 293 | } 294 | body.sticky .sidebar, 295 | body.sticky .sidebar-toggle { 296 | position: fixed; 297 | } 298 | .content { 299 | padding-top: 60px; 300 | position: absolute; 301 | top: 0; 302 | right: 0; 303 | bottom: 0; 304 | left: 300px; 305 | transition: left 250ms ease; 306 | } 307 | .markdown-section { 308 | margin: 0 auto; 309 | max-width: 80%; 310 | padding: 30px 15px 40px 15px; 311 | position: relative; 312 | } 313 | .markdown-section > * { 314 | box-sizing: border-box; 315 | font-size: inherit; 316 | } 317 | .markdown-section > :first-child { 318 | margin-top: 0 !important; 319 | } 320 | .markdown-section hr { 321 | border: none; 322 | border-bottom: 1px solid #eee; 323 | margin: 2em 0; 324 | } 325 | .markdown-section iframe { 326 | border: 1px solid #eee; 327 | /* fix horizontal overflow on iOS Safari */ 328 | width: 1px; 329 | min-width: 100%; 330 | } 331 | .markdown-section table { 332 | border-collapse: collapse; 333 | border-spacing: 0; 334 | display: block; 335 | margin-bottom: 1rem; 336 | overflow: auto; 337 | width: 100%; 338 | } 339 | .markdown-section th { 340 | border: 1px solid #ddd; 341 | font-weight: bold; 342 | padding: 6px 13px; 343 | } 344 | .markdown-section td { 345 | border: 1px solid #ddd; 346 | padding: 6px 13px; 347 | } 348 | .markdown-section tr { 349 | border-top: 1px solid #ccc; 350 | } 351 | .markdown-section tr:nth-child(2n) { 352 | background-color: #f8f8f8; 353 | } 354 | .markdown-section p.tip { 355 | background-color: #f8f8f8; 356 | border-bottom-right-radius: 2px; 357 | border-left: 4px solid #f66; 358 | border-top-right-radius: 2px; 359 | margin: 2em 0; 360 | padding: 12px 24px 12px 30px; 361 | position: relative; 362 | } 363 | .markdown-section p.tip:before { 364 | background-color: #f66; 365 | border-radius: 100%; 366 | color: #fff; 367 | content: '!'; 368 | font-family: 'Dosis', 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif; 369 | font-size: 14px; 370 | font-weight: bold; 371 | left: -12px; 372 | line-height: 20px; 373 | position: absolute; 374 | height: 20px; 375 | width: 20px; 376 | text-align: center; 377 | top: 14px; 378 | } 379 | .markdown-section p.tip code { 380 | background-color: #efefef; 381 | } 382 | .markdown-section p.tip em { 383 | color: #34495e; 384 | } 385 | .markdown-section p.warn { 386 | background: rgba(66,185,131,0.1); 387 | border-radius: 2px; 388 | padding: 1rem; 389 | } 390 | .markdown-section ul.task-list > li { 391 | list-style-type: none; 392 | } 393 | body.close .sidebar { 394 | transform: translateX(-300px); 395 | } 396 | body.close .sidebar-toggle { 397 | width: auto; 398 | } 399 | body.close .content { 400 | left: 0; 401 | } 402 | @media print { 403 | .github-corner, 404 | .sidebar-toggle, 405 | .sidebar, 406 | .app-nav { 407 | display: none; 408 | } 409 | } 410 | @media screen and (max-width: 768px) { 411 | .github-corner, 412 | .sidebar-toggle, 413 | .sidebar { 414 | position: fixed; 415 | } 416 | .app-nav { 417 | margin-top: 16px; 418 | } 419 | .app-nav li ul { 420 | top: 30px; 421 | } 422 | main { 423 | height: auto; 424 | overflow-x: hidden; 425 | } 426 | .sidebar { 427 | left: -300px; 428 | transition: transform 250ms ease-out; 429 | } 430 | .content { 431 | left: 0; 432 | max-width: 100vw; 433 | position: static; 434 | padding-top: 20px; 435 | transition: transform 250ms ease; 436 | } 437 | .app-nav, 438 | .github-corner { 439 | transition: transform 250ms ease-out; 440 | } 441 | .sidebar-toggle { 442 | background-color: transparent; 443 | width: auto; 444 | padding: 30px 30px 10px 10px; 445 | } 446 | body.close .sidebar { 447 | transform: translateX(300px); 448 | } 449 | body.close .sidebar-toggle { 450 | background-color: rgba(255,255,255,0.8); 451 | transition: 1s background-color; 452 | width: 284px; 453 | padding: 10px; 454 | } 455 | body.close .content { 456 | transform: translateX(300px); 457 | } 458 | body.close .app-nav, 459 | body.close .github-corner { 460 | display: none; 461 | } 462 | .github-corner:hover .octo-arm { 463 | -webkit-animation: none; 464 | animation: none; 465 | } 466 | .github-corner .octo-arm { 467 | -webkit-animation: octocat-wave 560ms ease-in-out; 468 | animation: octocat-wave 560ms ease-in-out; 469 | } 470 | } 471 | @-webkit-keyframes octocat-wave { 472 | 0%, 100% { 473 | transform: rotate(0); 474 | } 475 | 20%, 60% { 476 | transform: rotate(-25deg); 477 | } 478 | 40%, 80% { 479 | transform: rotate(10deg); 480 | } 481 | } 482 | @keyframes octocat-wave { 483 | 0%, 100% { 484 | transform: rotate(0); 485 | } 486 | 20%, 60% { 487 | transform: rotate(-25deg); 488 | } 489 | 40%, 80% { 490 | transform: rotate(10deg); 491 | } 492 | } 493 | section.cover { 494 | align-items: center; 495 | background-position: center center; 496 | background-repeat: no-repeat; 497 | background-size: cover; 498 | height: 100vh; 499 | width: 100vw; 500 | display: none; 501 | } 502 | section.cover.show { 503 | display: flex; 504 | } 505 | section.cover.has-mask .mask { 506 | background-color: #fff; 507 | opacity: 0.8; 508 | position: absolute; 509 | top: 0; 510 | height: 100%; 511 | width: 100%; 512 | } 513 | section.cover .cover-main { 514 | flex: 1; 515 | margin: -20px 16px 0; 516 | text-align: center; 517 | position: relative; 518 | } 519 | section.cover a { 520 | color: inherit; 521 | text-decoration: none; 522 | } 523 | section.cover a:hover { 524 | text-decoration: none; 525 | } 526 | section.cover p { 527 | line-height: 1.5rem; 528 | margin: 1em 0; 529 | } 530 | section.cover h1 { 531 | color: inherit; 532 | font-size: 2.5rem; 533 | font-weight: 300; 534 | margin: 0.625rem 0 2.5rem; 535 | position: relative; 536 | text-align: center; 537 | } 538 | section.cover h1 a { 539 | display: block; 540 | } 541 | section.cover h1 small { 542 | bottom: -0.4375rem; 543 | font-size: 1rem; 544 | position: absolute; 545 | } 546 | section.cover blockquote { 547 | font-size: 1.5rem; 548 | text-align: center; 549 | } 550 | section.cover ul { 551 | line-height: 1.8; 552 | list-style-type: none; 553 | margin: 1em auto; 554 | max-width: 500px; 555 | padding: 0; 556 | } 557 | section.cover .cover-main > p:last-child a { 558 | border-color: var(--theme-color, #42b983); 559 | border-radius: 2rem; 560 | border-style: solid; 561 | border-width: 1px; 562 | box-sizing: border-box; 563 | color: var(--theme-color, #42b983); 564 | display: inline-block; 565 | font-size: 1.05rem; 566 | letter-spacing: 0.1rem; 567 | margin: 0.5rem 1rem; 568 | padding: 0.75em 2rem; 569 | text-decoration: none; 570 | transition: all 0.15s ease; 571 | } 572 | section.cover .cover-main > p:last-child a:last-child { 573 | background-color: var(--theme-color, #42b983); 574 | color: #fff; 575 | } 576 | section.cover .cover-main > p:last-child a:last-child:hover { 577 | color: inherit; 578 | opacity: 0.8; 579 | } 580 | section.cover .cover-main > p:last-child a:hover { 581 | color: inherit; 582 | } 583 | section.cover blockquote > p > a { 584 | border-bottom: 2px solid var(--theme-color, #42b983); 585 | transition: color 0.3s; 586 | } 587 | section.cover blockquote > p > a:hover { 588 | color: var(--theme-color, #42b983); 589 | } 590 | body { 591 | background-color: #fff; 592 | } 593 | /* sidebar */ 594 | .sidebar { 595 | background-color: #fff; 596 | color: #364149; 597 | } 598 | .sidebar li { 599 | margin: 6px 0 6px 0; 600 | } 601 | .sidebar ul li a { 602 | color: #505d6b; 603 | font-size: 14px; 604 | font-weight: normal; 605 | overflow: hidden; 606 | text-decoration: none; 607 | text-overflow: ellipsis; 608 | white-space: nowrap; 609 | } 610 | .sidebar ul li a:hover { 611 | text-decoration: underline; 612 | } 613 | .sidebar ul li ul { 614 | padding: 0; 615 | } 616 | .sidebar ul li.active > a { 617 | border-right: 2px solid; 618 | color: var(--theme-color, #42b983); 619 | font-weight: 600; 620 | } 621 | .app-sub-sidebar li::before { 622 | content: '-'; 623 | padding-right: 4px; 624 | float: left; 625 | } 626 | /* markdown content found on pages */ 627 | .markdown-section h1, 628 | .markdown-section h2, 629 | .markdown-section h3, 630 | .markdown-section h4, 631 | .markdown-section strong { 632 | color: #2c3e50; 633 | font-weight: 600; 634 | } 635 | .markdown-section a { 636 | color: var(--theme-color, #42b983); 637 | font-weight: 600; 638 | } 639 | .markdown-section h1 { 640 | font-size: 2rem; 641 | margin: 0 0 1rem; 642 | } 643 | .markdown-section h2 { 644 | font-size: 1.75rem; 645 | margin: 45px 0 0.8rem; 646 | } 647 | .markdown-section h3 { 648 | font-size: 1.5rem; 649 | margin: 40px 0 0.6rem; 650 | } 651 | .markdown-section h4 { 652 | font-size: 1.25rem; 653 | } 654 | .markdown-section h5 { 655 | font-size: 1rem; 656 | } 657 | .markdown-section h6 { 658 | color: #777; 659 | font-size: 1rem; 660 | } 661 | .markdown-section figure, 662 | .markdown-section p { 663 | margin: 1.2em 0; 664 | } 665 | .markdown-section p, 666 | .markdown-section ul, 667 | .markdown-section ol { 668 | line-height: 1.6rem; 669 | word-spacing: 0.05rem; 670 | } 671 | .markdown-section ul, 672 | .markdown-section ol { 673 | padding-left: 1.5rem; 674 | } 675 | .markdown-section blockquote { 676 | border-left: 4px solid var(--theme-color, #42b983); 677 | color: #858585; 678 | margin: 2em 0; 679 | padding-left: 20px; 680 | } 681 | .markdown-section blockquote p { 682 | font-weight: 600; 683 | margin-left: 0; 684 | } 685 | .markdown-section iframe { 686 | margin: 1em 0; 687 | } 688 | .markdown-section em { 689 | color: #7f8c8d; 690 | } 691 | .markdown-section code { 692 | background-color: #f8f8f8; 693 | border-radius: 2px; 694 | color: #e96900; 695 | font-family: 'Roboto Mono', Monaco, courier, monospace; 696 | font-size: 0.8rem; 697 | margin: 0 2px; 698 | padding: 3px 5px; 699 | white-space: pre-wrap; 700 | } 701 | .markdown-section pre { 702 | -moz-osx-font-smoothing: initial; 703 | -webkit-font-smoothing: initial; 704 | background-color: #f8f8f8; 705 | font-family: 'Roboto Mono', Monaco, courier, monospace; 706 | line-height: 1.5rem; 707 | margin: 1.2em 0; 708 | overflow: auto; 709 | padding: 0 1.4rem; 710 | position: relative; 711 | word-wrap: normal; 712 | } 713 | /* code highlight */ 714 | .token.comment, 715 | .token.prolog, 716 | .token.doctype, 717 | .token.cdata { 718 | color: #8e908c; 719 | } 720 | .token.namespace { 721 | opacity: 0.7; 722 | } 723 | .token.boolean, 724 | .token.number { 725 | color: #c76b29; 726 | } 727 | .token.punctuation { 728 | color: #525252; 729 | } 730 | .token.property { 731 | color: #c08b30; 732 | } 733 | .token.tag { 734 | color: #2973b7; 735 | } 736 | .token.string { 737 | color: var(--theme-color, #42b983); 738 | } 739 | .token.selector { 740 | color: #6679cc; 741 | } 742 | .token.attr-name { 743 | color: #2973b7; 744 | } 745 | .token.entity, 746 | .token.url, 747 | .language-css .token.string, 748 | .style .token.string { 749 | color: #22a2c9; 750 | } 751 | .token.attr-value, 752 | .token.control, 753 | .token.directive, 754 | .token.unit { 755 | color: var(--theme-color, #42b983); 756 | } 757 | .token.keyword, 758 | .token.function { 759 | color: #e96900; 760 | } 761 | .token.statement, 762 | .token.regex, 763 | .token.atrule { 764 | color: #22a2c9; 765 | } 766 | .token.placeholder, 767 | .token.variable { 768 | color: #3d8fd1; 769 | } 770 | .token.deleted { 771 | text-decoration: line-through; 772 | } 773 | .token.inserted { 774 | border-bottom: 1px dotted #202746; 775 | text-decoration: none; 776 | } 777 | .token.italic { 778 | font-style: italic; 779 | } 780 | .token.important, 781 | .token.bold { 782 | font-weight: bold; 783 | } 784 | .token.important { 785 | color: #c94922; 786 | } 787 | .token.entity { 788 | cursor: help; 789 | } 790 | .markdown-section pre > code { 791 | -moz-osx-font-smoothing: initial; 792 | -webkit-font-smoothing: initial; 793 | background-color: #f8f8f8; 794 | border-radius: 2px; 795 | color: #525252; 796 | display: block; 797 | font-family: 'Roboto Mono', Monaco, courier, monospace; 798 | font-size: 0.8rem; 799 | line-height: inherit; 800 | margin: 0 2px; 801 | max-width: inherit; 802 | overflow: inherit; 803 | padding: 2.2em 5px; 804 | white-space: inherit; 805 | } 806 | .markdown-section code::after, 807 | .markdown-section code::before { 808 | letter-spacing: 0.05rem; 809 | } 810 | code .token { 811 | -moz-osx-font-smoothing: initial; 812 | -webkit-font-smoothing: initial; 813 | min-height: 1.5rem; 814 | position: relative; 815 | left: auto; 816 | } 817 | pre::after { 818 | color: #ccc; 819 | content: attr(data-lang); 820 | font-size: 0.6rem; 821 | font-weight: 600; 822 | height: 15px; 823 | line-height: 15px; 824 | padding: 5px 10px 0; 825 | position: absolute; 826 | right: 0; 827 | text-align: right; 828 | top: 0; 829 | } 830 | -------------------------------------------------------------------------------- /docs/0.md: -------------------------------------------------------------------------------- 1 | # 前言 2 | 3 | 这是一本关于自然语言处理的书。所谓“自然语言”,是指人们日常交流使用的语言,如英语,印地语,葡萄牙语等。相对于编程语言和数学符号这样的人工语言,自然语言随着一代人传给另一代人而不断演化,因而很难用明确的规则来刻画。从广义上讲,“自然语言处理”(Natural Language Processing 简称 NLP)包含所有用计算机对自然语言进行的操作。举个极端的例子,它可以是简单的通过计数词出现的频率来比较不同的写作风格。另外一个极端的例子,NLP 包括完全“理解”人所说的话,至少要能达到对人的话语作出有效反应的程度。 4 | 5 | 基于 NLP 的技术应用日益广泛。例如:手机和手持电脑支持输入法联想提示和手写识别;网络搜索引擎能搜到非结构化文本中的信息;机器翻译能把中文文本翻译成西班牙文;文本分析让我们能够检测推文和博客中的情感。通过提供更自然的人机界面和更复杂的存储信息获取手段,语言处理正在这个多语种的信息社会中扮演更核心的角色。 6 | 7 | 这本书提供自然语言处理领域非常方便的入门指南。它可以用来自学,也可以作为自然语言处理或计算语言学课程的教科书,或是人工智能、文本挖掘、语料库语言学课程的补充读物。本书的实践性很强,包括几百个实际可用的例子和分级练习。 8 | 9 | 本书基于 Python 编程语言及其上的一个名为*自然语言工具包*(Natural Language Toolkit ,简称 NLTK)的开源库。NLTK 包含大量的软件、数据和文档,所有这些都可以从`http://nltk.org/`免费下载。NLTK 的发行版本支持 Windows、Macintosh 和 Unix 平台。我们强烈建议你下载 Python 和 NLTk,与我们一起尝试书中的例子和练习。 10 | 11 | ## 读者 12 | 13 | NLP 是科学、经济、社会和文化的一个重要因素。NLP 正在迅速成长,它的很多理论和方法在大量新的语言技术中得到应用。所以对很多行业的人来说掌握 NLP 知识十分重要。在应用领域包括从事人机交互、商业信息分析、web 软件开发的人。在学术界包括从人文计算学、语料库语言学到计算机科学和人工智能领域的人。(学术界的很多人把 NLP 叫称为“计算语言学”。) 14 | 15 | 本书旨在帮助所有想要学习如何编写程序分析书面语言的人,不管他们以前的编程经验如何: 16 | 17 | ```py 18 | >>> for line in open("file.txt"): 19 | ... for word in line.split(): 20 | ... if word.endswith('ing'): 21 | ... print(word) 22 | ``` 23 | 24 | 这段程序演示了 Python 的一些主要特征。首先,使用空格*缩进*代码,从而使`if`后面的代码都在前面一行`for`语句的范围之内;这保证了检查单词是否以`ing`结尾的测试对所有单词都进行。第二,Python 是*面向对象*语言;每一个变量都是包含特定属性和方法的对象。例如,变量`line`的值不仅仅是一个字符串序列。它是一个`string`对象,包含一个用来把字符串分割成词的`split()`方法(或叫操作)。我们在对象名称后面写上一个点再写上方法名称就可以调用对象的一个方法,例如`line.split()`。第三,方法的*参数*写在括号内。例如,上面的例子中的`word.endswith('ing')`具有一个参数`'ing'`表示我们需要找的是`ing`结尾的词而不是别的结尾的词。最后也是最重要的,Python 的可读性如此之强以至于可以相当容易的猜出程序的功能,即使你以前从未写过一行代码。 25 | 26 | 我们选择 Python 是因为它的学习曲线比较平缓,文法和语义都很清晰,具有良好的处理字符串的功能。作为解释性语言,Python 便于交互式编程。作为面向对象语言,Python 允许数据和方法被方便的封装和重用。作为动态语言,Python 允许属性等到程序运行时才被添加到对象,允许变量自动类型转换,提高开发效率。Python 自带强大的标准库,包括图形编程、数值处理和网络连接等组件。 27 | 28 | Python 在世界各地的工业、科研、教育领域应用广泛。它因为提高了软件的生产效率、质量和可维护性而备受称赞。`http://python.org/about/success/`中列举了许多成功使用 Python 的故事。 29 | 30 | NLTK 定义了一个使用 Python 进行 NLP 编程的基础工具。它提供重新表示自然语言处理相关数据的基本类,词性标注、文法分析、文本分类等任务的标准接口以及这些任务的标准实现,可以组合起来解决复杂的问题。 31 | 32 | NLTK 自带大量文档。作为本书的补充,`http://nltk.org/`网站提供的 API 文档涵盖工具包中每一个模块、类和函数,详细说明了各种参数,还给出了用法示例。 33 | 34 | ## Python 3 和 NLTK 3 35 | 36 | 本书的这个版本已更新并支持 Python 3 和 NLTK 3。Python 3 包括一些重大的变化: 37 | 38 | * `print`语句现在是函数,因此需要括号; 39 | * 许多函数现在返回迭代器而不是列表 (以节省内存使用); 40 | * 整数除法返回一个浮点数 41 | * 所有文本现在都是 Unicode 编码 42 | * 字符串的格式化使用`format`方法 43 | 44 | 这些变化的更多细节请参见`https://docs.python.org/dev/whatsnew/3.0.html`.。有一个`2to3.py`工具可以将 Python 2 代码转换为 Python 3;关详细信息请参阅`https://docs.python.org/2/library/2to3.html`。 45 | 46 | NLTK 同样很多地方都有更改: 47 | 48 | * 许多类型使用`fromstring()`方法从字符串初始化 49 | * 许多函数现在返回迭代器而不是列表 50 | * `ContextFreeGrammar`现在叫做`CFG`,`WeightedGrammar`现在叫做`PCFG` 51 | * `batch_tokenize()`现在叫做`tokenize_sents()`;对应的标记器, 解析器和分类器都有变化 52 | * 有些实现已删除以支持外部包,或因为不能充分维护 53 | 54 | 更详细的变更列表请参见`https://github.com/nltk/nltk/wiki/Porting-your-code-to-NLTK-3.0`。 55 | 56 | ## 软件安装需求 57 | 58 | 为了充分利用好本书,你应该安装一些免费的软件包。`http://nltk.org/`上有这些软件包当前的下载链接和安装说明。 59 | 60 | | Python: | 本书中例子假定你正在使用 Python 3.2 或更高版本。(注,NLTK 3.0 也适用于 Python 2.6 和 2.7)。 | 61 | | --- | --- | 62 | | NLTK: | 这本书中的代码示例使用 NLTK 3.0 版。NLTK 的后续版本将会向后兼容 NLTK 3.0。 | 63 | | NLTK-Data: | 包含本书中分析和处理的语言语料库。 | 64 | | NumPy: | (推荐)这是一个科学计算库,支持多维数组和线性代数,在某些计算概率、标记、聚类和分类任务中用到。 | 65 | | Matplotlib: | (推荐)这是一个用于数据可视化的 2D 绘图库,本书在产生线图和条形图的程序例子中用到。 | 66 | | 斯坦福大学 NLP 工具: | (推荐)NLTK 包括斯坦福大学 NLP 工具的接口,可用于大型语言处理(见`http://nlp.stanford.edu/software/`)。 | 67 | | NetworkX: | (可选)这是一个用于存储和操作由节点和边组成的网络结构的函数库。可视化语义网络还需要安装 *Graphviz* 库。 | 68 | | Prover9: | (可选)这是一个使用一阶等式逻辑定理的自动证明器,用于支持语言处理中的推理。 | 69 | 70 | ## 自然语言工具包(NLTK) 71 | 72 | NLTK 创建于 2001 年,最初是宾州大学计算机与信息科学系计算语言学课程的一部分。从那以后,在数十名贡献者的帮助下不断发展壮大。如今,它已被几十所大学的课程所采纳,并作为许多研究项目的基础。[VIII.1](http://www.nltk.org/book/ch00.html#tab-modules) 列出了 NLTK 的一些最重要的模块。 73 | 74 | 表 VIII.1: 75 | 76 | 语言处理任务与相应 NLTK 模块以及功能描述 77 | 78 | | 语言处理任务 | NLTK 模块 | 功能 | 79 | | --- | --- | --- | 80 | | 访问语料库 | `corpus` | 语料库与词典的标准化接口 | 81 | | 字符串处理 | `tokenize, stem` | 分词,分句,提取主干 | 82 | | 搭配的发现 | `collocations` | t-检验,卡方,点互信息 PMI | 83 | | 词性标注 | `tag` | N 元组, backoff, Brill, HMM, TnT | 84 | | 机器学习 | `classify, cluster, tbl` | 决策树,最大熵,贝叶斯,EM,k-means | 85 | | 分块 | `chunk` | 正则表达式,N 元组,命名实体 | 86 | | 解析 | `parse, ccg` | 图表,基于特征,一致性,概率,依赖 | 87 | | 语义解释 | `sem, inference` | λ演算,一阶逻辑,模型检验 | 88 | | 指标评测 | `metrics` | 精度,召回率,协议系数 | 89 | | 概率和估计 | `probability` | 频率分布,平滑概率分布 | 90 | | 应用 | `app, chat` | 图形化的语料库检索工具,分析器,WordNet 查看器,聊天机器人 | 91 | | 语言学领域的工作 | `toolbox` | 处理 SIL 工具箱格式的数据 | 92 | 93 | NLTK 设计中的四个主要目标: 94 | 95 | | 简单: | 提供一个直观的框架和大量构建模块,使用户获取 NLP 知识而不必陷入像标注语言数据那样繁琐的事务中 | 96 | | --- | --- | 97 | | 一致: | 提供一个具有一致的接口和数据结构的,并且方法名称容易被猜到的统一的框架 | 98 | | 可扩展: | 提供一种结构,新的软件模块包括同一个任务中的不同的实现和相互冲突的方法都可以方便添加进来 | 99 | | 模块化: | 提供的组件可以独立使用而无需理解工具包的其他部分 | 100 | 101 | 对比上述目标,我们有意回避了工具包三个非需求行的但可能有用的特征。首先,虽然工具包提供了广泛的工具,但它不是面面俱全的;它是一个工具包而不是一个系统,它将会随着 NLP 领域一起演化。第二,虽然这个工具包的效率足以支持实际的任务,但它运行时的性能还没有高度优化;这种优化往往涉及更复杂的算法或使用 C 或 C++ 等较低一级的编程语言来实现。这将影响工具包的可读性且更难以安装。第三,我们试图避开巧妙的编程技巧,因为我们相信清楚直白的实现比巧妙却可读性差的方法好。 102 | 103 | ## 教师请看 104 | 105 | 自然语言处理一般是在高年级本科生或研究生层次开设的为期一个学期的课程。很多教师都发现,在如此短的时间里涵盖理论和实践两个方面是十分困难的。有些课程注重理论而排挤实践练习,剥夺了学生编写程序自动处理语言带来的挑战和兴奋感。另一些课程仅仅教授语言学编程而不包含任何重要的 NLP 内容。最初开发 NLTK 就是为了解决这个问题,使在一个学期里同时教授大量理论和实践成为可能,无论学生事先有没有编程经验。 106 | 107 | 算法和数据结构在所有 NLP 教学大纲中都十分重要。它们本身可能非常枯燥,而 NLTK 提供的交互式图形用户界面能一步一步看到算法过程,使它们变得鲜活。大多数 NLTK 组件都有一个无需用户输入任何数据就能执行有趣的任务的示范性例子。学习本书的一个有效的方法就是交互式重现书中的例子,把它们输入到 Python 会话控制台,观察它们做了些什么,修改它们去探索试验或理论问题。 108 | 109 | 本书包含了数百个练习,可作为学生作业的基础。最简单的练习涉及用指定的方式修改已有的程序片段来回答一个具体的问题。另一个极端,NLTK 为研究生水平的研究项目提供了一个灵活的框架,包括所有的基本数据结构和算法的标准实现,几十个广泛使用的数据集(语料库)的接口,以及一个灵活可扩展的体系结构。NLTK 网站上还有其他资源支持教学中使用 NLTK。 110 | 111 | 我们相信本书是唯一为学生提供在学习编程的环境中学习 NLP 的综合性框架。各个章节和练习通过 NLTK 紧密耦合,并将各章材料分割开,为学生(即使是那些以前没有编程经验的学生)提供一个实用的 NLP 的入门指南。学完这些材料后,学生将准备好尝试一本更加深层次的教科书,例如《语音和语言处理》,作者是 Jurafsky 和 Martin(Prentice Hall 出版社,2008 年)。 112 | 113 | 本书介绍编程概念的顺序与众不同,以一个重要的数据类型字符串列表开始,然后介绍重要的控制结构如推导和条件式等。这些概念允许我们在一开始就做一些有用的语言处理。有了这样做的冲动,我们回过头来系统的介绍一些基础概念,如字符串,循环,文件等。这样的方法同更传统的方法达到了同样的效果而不必要求读者自己已经对编程感兴趣。 114 | 115 | [IX.1](http://www.nltk.org/book/ch00.html#tab-course-plans) 列出了两个课程计划表。第一个适用于文科,第二个适用于理工科。其他的课程计划应该涵盖前 5 章,然后把剩余的时间投入单独的领域,例如:文本分类(第 6、7 章)、文法(第 8、9 章)、语义(第 10 章)或者语言数据管理(第 11 章)。 116 | 117 | 表 IX.1: 118 | 119 | 课程计划建议;每一章近似的课时数 120 | 121 | | 章节 | 文科 | 理工科 | 122 | | --- | --- | --- | 123 | | 第 1 章 语言处理与 Python | 2-4 | 2 | 124 | | 第 2 章 获得文本语料和词汇资源 | 2-4 | 2 | 125 | | 第 3 章 处理原始文本 | 2-4 | 2 | 126 | | 第 4 章 编写结构化程序 | 2-4 | 1-2 | 127 | | 第 5 章 分类和标注单词 | 2-4 | 2-4 | 128 | | 第 6 章 学习本文分类 | 0-2 | 2-4 | 129 | | 第 7 章 从文本提取信息 | 2 | 2-4 | 130 | | 第 8 章 分析句子结构 | 2-4 | 2-4 | 131 | | 第 9 章 构建基于特征的文法 | 2-4 | 1-4 | 132 | | 第 10 章 分析句子的含义 | 1-2 | 1-4 | 133 | | 第 11 章 语言学数据管理 | 1-2 | 1-4 | 134 | | 总计 | 18-36 | 18-36 | 135 | 136 | ## 本书使用的约定 137 | 138 | 本书使用以下印刷约定: 139 | 140 | **粗体** -- 表示新的术语。 141 | 142 | *斜体* -- 用在段落中表示语言学例子、文本的名称和 URL,文件名和后缀名也用斜体。 143 | 144 | `等宽字体` -- 用来表示程序清单,用在段落中表示变量、函数名、语句或关键字等程序元素;也用来表示程序名。 145 | 146 | `等宽粗体` -- 表示应该由用户输入的命令或其他文本。 147 | 148 | `等宽斜体` -- 表示应由用户提供的值或上下文决定的值来代替文本中的值;也在程序代码例子中表示元变量。 149 | 150 | 注 151 | 152 | 此图标表示提示、建议或一般性注意事项。 153 | 154 | 警告! 155 | 156 | 此图标表示警告或重要提醒。 157 | 158 | ## 使用例子代码 159 | 160 | 本书是为了帮你完成你的工作的。。一般情况下,你都可以在你的程序或文档中使用本书中的代码。不需要得到我们获得允许,除非你要大量的复制代码。例如,编写的程序用到书中几段代码不需要许可。销售和分发 O'Reilly 书籍中包含的例子的 CD-ROM 需要获得许可。援引本书和书中的例子来回答问题不需要许可。大量的将本书中的例子纳入你的产品文档将需要获得许可。 161 | 162 | 我们希望但不是一定要求被参考文献引用。一个引用通常包括标题,作者,出版者和 ISBN。例如:Python 自然语言处理,Steven Bird,Ewan Klein 和 Edward Loper。O'Reilly Media, 978-0-596-51649-9\. 如果你觉得你使用本书的例子代码超出了上面列举的一般用途或许可,随时通过 *permissions@oreilly.com* 联系我们。 163 | 164 | ## 致谢 165 | 166 | 作者感激为本书早期手稿提供反馈意见的人,他们是:Doug Arnold, Michaela Atterer, Greg Aumann, Kenneth Beesley, Steven Bethard, Ondrej Bojar, Chris Cieri, Robin Cooper, Grev Corbett, James Curran, Dan Garrette, Jean Mark Gawron, Doug Hellmann, Nitin Indurkhya, Mark Liberman, Peter Ljunglöf, Stefan Müller, Robin Munn, Joel Nothman, Adam Przepiorkowski, Brandon Rhodes, Stuart Robinson, Jussi Salmela, Kyle Schlansker, Rob Speer 和 Richard Sproat。感谢许许多多的学生和同事,他们关于课堂材料的意见演化成本书的这些章节,其中包括巴西,印度和美国的 NLP 与语言学暑期学校的参加者。没有`nltk-dev`开发社区的成员们的努力这本书也不会存在,他们为建设和壮大 NLTK 无私奉献他们的时间和专业知识,他们的名字都记录在 NLTK 网站上。 167 | 168 | 非常感谢美国国家科学基金会、语言数据联盟、Edward Clarence Dyason 奖学金、宾州大学、爱丁堡大学和墨尔本大学对我们在本书相关的工作上的支持。 169 | 170 | 感谢 Julie Steele、Abby Fox、Loranah Dimant 以及其他 O'Reilly 团队成员,他们组织大量 NLP 和 Python 社区成员全面审阅我们的手稿,很高兴的为满足我们的需要定制 O'Reilly 的生成工具。感谢他们一丝不苟的审稿工作。 171 | 172 | 在准备 Python 3 修订版的过程中,感谢 Michael Korobov 领导将 NLTK 移植到 Python 3,以及 Antoine Trux 对第一版细致的反馈意见。 173 | 174 | 最后,我们对我们的合作伙伴欠了巨额的感情债,他们是 Mimo 和 Jee。我们希望我们的孩子 —— Andrew, Alison、Kirsten、Leonie 和 Maaike —— 能从这些页面中感受到我们对语言和计算的热情。 175 | 176 | ## 关于作者 177 | 178 | **Steven Bird** 是在墨尔本大学计算机科学与软件工程系副教授和美国宾夕法尼亚大学的语言数据联盟的高级研究助理。他于 1990 年在爱丁堡大学完成计算音韵学博士学位,由 Ewan Klein 指导。后来到喀麦隆开展夏季语言学研究所主持下的 Grassfields 班图语语言实地调查。最近,他作为语言数据联盟副主任花了几年时间领导研发队伍,创建已标注文本的大型数据库的模型和工具。在墨尔本大学,他建立了一个语言技术研究组,并在各级本科计算机科学课程任教。2009 年,史蒂芬成为计算语言学学会主席。 179 | 180 | **Ewan Klein**是英国爱丁堡大学信息学院语言技术教授。于 1978 年在剑桥大学完成形式语义学博士学位。在苏塞克斯和纽卡斯尔大学工作多年后,参加了在爱丁堡的教学岗位。他于 1993 年参与了爱丁堡语言科技集团的建立,并一直与之密切联系。从 2000 到 2002,他离开大学作为圣克拉拉的埃迪法公司的总部在爱丁堡的自然语言的研究小组的研发经理,负责处理口语对话。Ewan 是计算语言学协会欧洲分会(European Chapter of the Association for Computational Linguistics)前任主席,并且是人类语言技术(ELSNET)欧洲卓越网络的创始成员和协调员。 181 | 182 | **Edward Loper** 最近完成了宾夕法尼亚大学自然语言处理的机器学习博士学位。Edward 是 Steven 在 2000 年秋季计算语言学研究生课程的学生,也是教师助手和 NLTK 开发的成员。除了 NLTK,他帮助开发了用于文档化和测试 Python 软件的两个包:`epydoc`和`doctest`。 183 | 184 | ## 版税 185 | 186 | 出售这本书的版税将被用来支持自然语言工具包的发展。 187 | 188 | ![Images/authors.png](Images/d87676460c87d0516fb382b929c07302.jpg) 189 | 190 | 图 XIV.1:Edward Loper, Ewan Klein 和 Steven Bird, 斯坦福大学, 2007 年 7 月 191 | 192 | ## 关于本文档... 193 | 194 | 针对 NLTK 3.0 进行更新。本章来自于《Python 自然语言处理》,[Steven Bird](http://estive.net/), [Ewan Klein](http://homepages.inf.ed.ac.uk/ewan/) 和 [Edward Loper](http://ed.loper.org/),Copyright © 2014 作者所有。本章依据 [*Creative Commons Attribution-Noncommercial-No Derivative Works 3\.0 United States License*](http://creativecommons.org/licenses/by-nc-nd/3.0/us/) 条款,与[*自然语言工具包*](http://nltk.org/) 3.0 版一起发行。 195 | 196 | 本文档构建于 2015 年 7 月 1 日 星期三 12:30:05 AEST -------------------------------------------------------------------------------- /docs/12.md: -------------------------------------------------------------------------------- 1 | # 后记:语言的挑战 2 | 3 | 自然语言抛出一些有趣的计算性挑战。我们已经在前面的章节探讨过许多这样的挑战,包括分词、标注、分类、信息提取和建立句法和语义表示。你现在应该已经准备好操作大型数据集,来创建语言现象的强健模型,并将它们扩展到实际语言技术的组件中。我们希望自然语言工具包(NLTK)对于开放令人振奋的实用自然语言处理的的努力到比以前更广泛的受众已经起作用。 4 | 5 | 尽管已经取得前面的所有成果,语言呈现给我们的远远不是计算上的临时挑战。考虑下面的句子,它们证实语言的丰富性: 6 | 7 | ``` 8 | (1) 9 | 10 | a. Overhead the day drives level and grey, hiding the sun by a flight of grey spears. (William Faulkner, *As I Lay Dying*, 1935) 11 | 12 | b. When using the toaster please ensure that the exhaust fan is turned on. (sign in dormitory kitchen) 13 | 14 | c. Amiodarone weakly inhibited CYP2C9, CYP2D6, and CYP3A4-mediated activities with Ki values of 45.1-271.6 μM (Medline, PMID: 10718780) 15 | 16 | d. Iraqi Head Seeks Arms (spoof news headline) 17 | 18 | e. The earnest prayer of a righteous man has great power and wonderful results. (James 5:16b) 19 | 20 | f. Twas brillig, and the slithy toves did gyre and gimble in the wabe (Lewis Carroll, *Jabberwocky*, 1872) 21 | 22 | g. There are two ways to do this, AFAIK :smile: (internet discussion archive) 23 | ``` 24 | 25 | 语言丰富性的其他证据是以语言为工作中心的学科的浩瀚阵容。一些明显的学科包括翻译、文学批评、哲学、人类学和心理学。许多不太明显的学科研究语言的使用,包括法律、诠释学、辩论术、电话学、教育学、考古学、密码分析学及言语病理学。它们分别应用不同的方法来收集观察资料、发展理论和测试假设。它们都有助于加深我们对语言和表现在语言中的智能的理解。 26 | 27 | 鉴于语言的复杂性和从不同的角度研究它的广泛的价值,很显然这里我们仅仅已经触及了表面。此外,在 NLP 本身,有许多我们没有提到的重要方法和应用。 28 | 29 | 在我们的后记中,我们将以更宽广的视角看待 NLP,包括它的基础和你可能想要探索的进一步的方向。一些主题还没有得到 NLTK 很好的支持,你可能想通过为工具包贡献新的软件和数据来修正这些问题,。 30 | 31 | ## 语言处理与符号处理 32 | 33 | 以计算方式处理自然语言的真正观念脱胎于一个研究项目,可以追溯到 1900 年代早期,使用逻辑重建数学推理,最清楚地表明是在 Frege、Russell、Wittgenstein、Tarski、Lambek 和 Carnap 的工作中。这项工作导致语言作为可以自动处理的形式化系统的概念。三个后来的发展奠定了自然语言处理的基础。第一个是形式语言理论。它定义一个语言为被一类自动机接受的字符串的集合,如上下文无关语言和下推自动机,并提供计算句法的支柱。 34 | 35 | 第二个发展是符号逻辑。它提供一个捕捉选定的自然语言的表达的逻辑证明的有关方面的形式化方法。符号逻辑中的形式化演算提供一种语言的句法和推理规则,并可能在一套理论模型中对规则进行解释;例子是命题逻辑和一阶逻辑。给定这样的演算和一个明确的句法和语义,通过将自然语言的表达翻译成形式化演算的表达式,联系语义与自然语言的表达成为可能。例如,如果我们翻译`John saw Mary`为公式`saw(j,m)`,我们(或明或暗地)将英语动词`saw`解释为一个二元关系,而`John`和`Mary`表示个体元素。更多的一般性的表达式如`All birds fly`需要量词,在这个例子中是`∀`,意思是对所有的:`∀x (bird(x) → fly(x))`。逻辑的使用提供了技术性的机制处理推理,而推理是语言理解的重要组成部分。 36 | 37 | 另一个密切相关的发展是组合原理,即一个复杂表达式的意思由它的各个部分的意思和它们的组合模式组成`(10)`。这一原理提供了句法和语义之间的有用的对应,即一个复杂的表达式的含义可以递归的计算。考虑句子`It is not true that p`,其中`p`是一个命题。我们可以表示这个句子的意思为`not(p)`。同样,我们可以表示`John saw Mary`的意思为`saw(j, m)`。现在,我们可以使用上述信息递归地计算`It is not true that John saw Mary`的表示,得到`not(saw(j,m))`。 38 | 39 | 刚刚简要介绍的方法都有一个前提,自然语言计算关键依赖于操纵符号表示的规则。NLP 发展的一个特定时期,特别是 1980 年代,这个前提为语言学家和 NLP 从业人员提供了一个共同的起点,导致一种被称为基于归一(基于特征)语法的形式化语法家族(参见 9),也导致了在 Prolog 编程语言上实现 NLP 应用。虽然基于语法的自然语言处理仍然是一个研究的重要领域,由于多种因素在过去的 15-20 年它已经有些黯然失色。一个显著的影响因素来自于自动语音识别。虽然早期的语音处理采用一个模拟一类基于规则的音韵处理的模型,典型的如《Sound Pattern of English》(Chomsky & Halle, 1968),结果远远不能够解决实时的识别实际的讲话这样困难的问题。相比之下,包含从大量语音数据中学习的模式的系统明显更准确、高效和稳健的。此外,言语社区发现建立对常见的测试数据的性能的定量测量的共享资源对建立更好的系统的过程有巨大帮助。最终,大部分的 NLP 社区拥抱面向数据密集型的语言处理,配合机器学习技术和评价为主导的方法的越来越多地使用。 40 | 41 | ## 当代哲学划分 42 | 43 | 在上一节中描述的自然语言处理的两种方法的对比与在西方哲学的启蒙时期出现的关于理性主义与经验主义和现实主义与理想主义的早期形而上学的辩论有关。这些辩论出现在反对一切知识的来源被认为是神的启示的地方的正统思想的背景下。在十七和十八世纪期间,哲学家认为人类理性或感官经验优先了启示。笛卡尔和莱布尼兹以及其他人采取了理性的立场,声称所有的真理来源于人类思想,从出生起在我们的脑海中就植入的“天赋观念”的存在。例如,他们认为欧几里德几何原理是使用人的理性制定的,而不是超自然的启示或感官体验的结果。相比之下,洛克和其他人采取了经验主义的观点,认为我们的知识的主要来源是我们的感官经验,人类理性在翻译这些经验上起次要作用。这一立场经常引用的证据是伽利略的发现——基于对行星运动的仔细观察——太阳系是以太阳为中心,而不是地球为中心。在语言学的背景下,本次辩论导致以下问题:人类语言经验与我们先天的“语言能力”各自多大程度上作为我们的语言知识的基础?在 NLP 中这个问题表现为在计算模型构建中语料库数据与语言学反省之间的优先级。 44 | 45 | 还有一个问题,在现实主义和理想主义之间的辩论中被奉若神明的是理论结构的形而上学的地位。康德主张现象与我们可以体验的表现以及不能直接被认识的“事情本身”之间的相互区别。语言现实主义者会认为如名词短语这样的理论建构是一个现实世界的实体,是人类看法和理由的独立存在,它实际*导致*观测到的语言现象。另一方面,语言理想主义者会说名词短语以及如语义表示这样更抽象的结构本质上无法观察到,只是担任有用的虚构的角色。语言学家写理论的方式往往与现实主义的立场相违背,而 NLP 从业人员占据中立地位,不然就倾向于理想主义立场。因此,在 NLP 中,如果一个理论的抽象导致一个有用的结果往往就足够了;不管这个结果是否揭示了任何人类语言处理。 46 | 47 | 这些问题今天仍然存在,表现为符号与统计方法、深层与浅层处理、二元与梯度分类以及科学与工程目标之间的区别。然而,这样的反差现在已经非常细微,辩论不再像从前那样是两极化。事实上,大多数的讨论——大部分的进展——都包含一个“平衡协调”。例如,一种中间立场是假设人类天生被赋予基于类比和记忆的学习方法(弱理性主义),并使用这些方法确定他们的感官语言经验(经验主义)的有意义的模式。 48 | 49 | 整本书中,我们已经看到了这种方法的很多例子。每次语料统计指导上下文无关语法产生式的选择,统计方法就会给出符号模型,即“语法工程”。每次使用基于规则的方法创建的一个语料被用来作为特征来源训练统计语言模型时,符号方法都会给出统计模型,即“语法推理”。圆圈是封闭的。 50 | 51 | ## NLTK 路线图 52 | 53 | 自然语言工具包是在不断发展的,随着人们贡献代码而不断扩大。NLP 和语言学的一些领域(还)没有得到 NLTK 很好的支持,特别欢迎在这些领域的贡献。有关这本书的出版之后的开发新闻,请查阅`http://nltk.org/`。 54 | 55 | | 音韵学和形态学: | 研究声音模式和文字结构的计算方法,通常用一个有限状态机工具包。如不规则词形变化和非拼接形态这样的现象使用我们一直在学习的字符串处理方法很难解决。该技术面临的挑战不仅仅是连接 NLTK 到一个高性能的有限状态机工具包,而且要避免词典数据的重复以及链接形态分析器和语法分析器所需形态学特征。 | 56 | | --- | --- | 57 | | 高性能模块: | 一些 NLP 任务的计算量太大,使纯 Python 实现不可行。然而,在某些情况下,耗时只出现在训练模型期间,不是在标注输入期间使用它们。NLTK 中的包系统提供了一个方便的方式来发布训练好的模型,即使那些使用不能随意发布的语料库训练的模型。替代方法是开发高性能的机器学习工具的 Python 接口,或通过使用类似与 MapReduce 的并行编程技术扩展 Python 的能力。 | 58 | | 词汇语义学: | 这是一个充满活力的领域,目前的研究大多围绕词典、本体、多词表达式等的继承模型,大都在现在的 NLTK 的范围之外。一个保守的目标是从丰富的外部存储获得词汇信息,以支持词义消歧、解析和语义解释等任务。 | 59 | | 自然语言生成: | 从含义的内在表示生产连贯的文本是 NLP 的重要组成部分;用于 NLP 的基于归一的方法已经在 NLTK 中开发,在这一领域做出更大的贡献还有限制。 | 60 | | 语言实地调查: | 语言学家面临的一个重大挑战是记录数以千计的濒危语言,这项工作产生大量异构且快速变化的数据。更多的实地调查的数据格式,包括行间的文本格式和词汇交换格式,在 NLTK 中得到支持,帮助语言学家维护和分析这些数据,解放他们,使他们能在数据提炼中花费尽可能多的时间。 | 61 | | 其他语言: | 对英语以外的语言的 NLP 改进支持包括两方面的工作:获准发布更多 NLTK 中的收集的语料库;写特定语言的 HOWTO 文件发布到`http://nltk.org/howto`,说明 NLTK 中的使用,讨论语言相关的 NLP 问题,包括字符编码、分词、形态。一个特定语言专长的 NLP 研究人员可以安排翻译这本书,并在 NLTK 的网站上保存一个副本;这将不仅仅是翻译讨论的内容,而要使用目标语言的数据提供等效的可行的例子,一项不平凡的事业。 | 62 | | NLTK-Contrib: | 许多 NLTK 中的核心组件都由 NLP 社区成员贡献,它们最初被安置在 NLTK 中的“Contrib”包,`nltk_contrib`。对添加到这个包中的软件的唯一要求是它必须用 Python 编写,与 NLP 有关,并给予与 NLTK 中其他软件一样的开源许可。不完善的软件也是值得欢迎的,随着时间的推移可能会被 NLP 社区的其他成员改进。 | 63 | | 教材: | 从 NLTK 开发的最初起,教材一直伴随着软件逐渐扩大填补这本书,也加上大量的网上材料。我们希望弄清楚提供这些材料包括:幻灯片、习题集、解答集、我们所覆盖的主题更详细的理解的教员的名字,并通知作者,我们可以为他们在`http://nltk.org/`上做链接。具有特殊价值的材料,帮助 NLP 成为计算机科学和语言学系的本科主流课程,或者使 NLP 在二级本科课程中可以获得,在那里对语言、文学、计算机科学以及信息技术课程中的计算内容有明显的限制。 | 64 | | 只是一个工具包: | 在序言中已经指出,NLTK 是一个工具包,而不是一个系统。在 NLTK、Python、其他 Python 库、外部 NLP 的工具和格式的接口集成中会有很多问题需要解决。 | 65 | 66 | ## Envoi... 67 | 68 | 语言学家有时会被问到他们说多少种语言,不得不解释说这一领域实际上关注语言间共享的抽象结构的研究,一种比学说尽可能多的语言更深刻更难以捉摸的研究。同样的,计算机科学家有时会被问到他们懂多少种编程语言,不得不解释说计算机科学实际上关注能在任何编程语言中实施的数据结构和算法的研究,一种比争取学习尽可能多的编程语言更深刻更难以捉摸。 69 | 70 | 这本书涵盖了自然语言处理领域的许多主题。大多数的例子都使用 Python 和英语。不过,如果读者得出的结论是 NLP 是有关如何编写 Python 程序操纵英文文本,或者更广泛的,关于如何编写程序(以任何一种编程语言)处理(任何一种自然语言)文本的,这将是不幸的。我们选择 Python 和英语是权宜之计,仅此而已。即使我们关注编程本身也只是一种解决问题的手段:作为一种了解表示和操纵语言标注文本的集合的数据结构和算法的方式,作为一种方法来建立新的语言技术,更好地服务于信息社会的需求,并最终作为对人类语言极度丰富性的更深的理解的方法。 71 | 72 | *但是目前为止,快乐编程吧!* 73 | 74 | ## 关于本文档... 75 | 76 | 针对 NLTK 3.0 作出更新。本章来自于《Python 自然语言处理》,[Steven Bird](http://estive.net/), [Ewan Klein](http://homepages.inf.ed.ac.uk/ewan/) 和 [Edward Loper](http://ed.loper.org/),Copyright © 2014 作者所有。本章依据 [*Creative Commons Attribution-Noncommercial-No Derivative Works 3\.0 United States License*](http://creativecommons.org/licenses/by-nc-nd/3.0/us/) 条款,与[*自然语言工具包*](http://nltk.org/) 3.0 版一起发行。 77 | 78 | 本文档构建于星期三 2015 年 7 月 1 日 12:30:05 AEST -------------------------------------------------------------------------------- /docs/8.md: -------------------------------------------------------------------------------- 1 | # 8 分析句子结构 2 | 3 | 前面的章节重点关注词:如何识别它们,分析它们的结构,分配给他们词汇类别,以及获得它们的含义。我们还看到了如何识别词序列或 N 元组中的模式。然而,这些方法只触碰到支配句子的复杂约束的表面。我们需要一种方法处理自然语言中显著的歧义。我们还需要能够应对这样一个事实,句子有无限的可能,而我们只能写有限的程序来分析其结构和发现它们的含义。 4 | 5 | 本章的目的是要回答下列问题: 6 | 7 | 1. 我们如何使用形式化语法来描述无限的句子集合的结构? 8 | 2. 我们如何使用句法树来表示句子结构? 9 | 3. 语法分析器如何分析一个句子并自动构建句法树? 10 | 11 | 一路上,我们将覆盖英语句法的基础,并看到句子含义有系统化的一面,只要我们确定了句子结构,将更容易捕捉。 12 | 13 | ## 1 一些语法困境 14 | 15 | ## 1.1 语言数据和无限可能性 16 | 17 | 前面的章节中已经为你讲述了如何处理和分析的文本语料库,我们一直强调处理大量的每天都在增加的电子语言数据是 NLP 的挑战。让我们更加细致的思考这些数据,做一个思想上的实验,我们有一个巨大的语料库,包括在过去 50 年中英文表达或写成的一切。我们称这个语料库为“现代英语”合理吗?有许多为什么我们的回答可能是否定的的原因。回想一下,在 3 中,我们让你搜索网络查找`the of`模式的实例。虽然很容易在网上找到包含这个词序列的例子,例如`New man at the of IMG`(见`http://www.telegraph.co.uk/sport/2387900/New-man-at-the-of-IMG.html`),说英语的人会说大多数这样的例子是错误的,因此它们根本不是英语。 18 | 19 | 因此,我们可以说,“现代英语”并不等同于我们想象中的语料库中的非常大的词序列的集合。说英语的人可以判断这些序列,并将拒绝其中一些不合语法的。 20 | 21 | 同样,组成一个新的句子,并让说话者认为它是非常好的英语是很容易的。例如,句子有一个有趣的属性,它们可以嵌入更大的句子中。考虑下面的句子: 22 | 23 | ```py 24 | >>> groucho_grammar = nltk.CFG.fromstring(""" 25 | ... S -> NP VP 26 | ... PP -> P NP 27 | ... NP -> Det N | Det N PP | 'I' 28 | ... VP -> V NP | VP PP 29 | ... Det -> 'an' | 'my' 30 | ... N -> 'elephant' | 'pajamas' 31 | ... V -> 'shot' 32 | ... P -> 'in' 33 | ... """) 34 | ``` 35 | 36 | 这个文法允许以两种方式分析句子,取决于介词短语`in my pajamas`是描述大象还是枪击事件。 37 | 38 | ```py 39 | >>> sent = ['I', 'shot', 'an', 'elephant', 'in', 'my', 'pajamas'] 40 | >>> parser = nltk.ChartParser(groucho_grammar) 41 | >>> for tree in parser.parse(sent): 42 | ... print(tree) 43 | ... 44 | (S 45 | (NP I) 46 | (VP 47 | (VP (V shot) (NP (Det an) (N elephant))) 48 | (PP (P in) (NP (Det my) (N pajamas))))) 49 | (S 50 | (NP I) 51 | (VP 52 | (V shot) 53 | (NP (Det an) (N elephant) (PP (P in) (NP (Det my) (N pajamas)))))) 54 | ``` 55 | 56 | 程序产生两个括号括起的结构,我们可以用树来表示它们,如`(3b)`所示: 57 | 58 | ```py 59 | grammar1 = nltk.CFG.fromstring(""" 60 | S -> NP VP 61 | VP -> V NP | V NP PP 62 | PP -> P NP 63 | V -> "saw" | "ate" | "walked" 64 | NP -> "John" | "Mary" | "Bob" | Det N | Det N PP 65 | Det -> "a" | "an" | "the" | "my" 66 | N -> "man" | "dog" | "cat" | "telescope" | "park" 67 | P -> "in" | "on" | "by" | "with" 68 | """) 69 | ``` 70 | 71 | 在 3.1 中的语法包含涉及各种句法类型的产生式,如在 3.1 中所列出的。 72 | 73 | 表 3.1: 74 | 75 | 句法类型 76 | 77 | ```py 78 | >>> grammar1 = nltk.data.load('file:mygrammar.cfg') 79 | >>> sent = "Mary saw Bob".split() 80 | >>> rd_parser = nltk.RecursiveDescentParser(grammar1) 81 | >>> for tree in rd_parser.parse(sent): 82 | ... print(tree) 83 | ``` 84 | 85 | 确保你的文件名后缀为`.cfg`,并且字符串`'file:mygrammar.cfg'`中间没有空格符。如果命令`print(tree)`没有产生任何输出,这可能是因为你的句子`sent`并不符合你的语法。在这种情况下,可以将分析器的跟踪设置打开:`rd_parser = nltk.RecursiveDescentParser(grammar1, trace=2)`。你还可以查看当前使用的语法中的产生式,使用命令`for p in grammar1.productions(): print(p)`。 86 | 87 | 当你编写 CFG 在 NLTK 中分析时,你不能将语法类型与词汇项目一起写在同一个产生式的右侧。因此,产生式`PP -> 'of' NP`是不允许的。另外,你不得在产生式右侧仿制多个词的词汇项。因此,不能写成`NP -> 'New York'`,而要写成类似`NP -> 'New_York'`这样的。 88 | 89 | ## 3.3 句法结构中的递归 90 | 91 | 一个语法被认为是递归的,如果语法类型出现在产生式左侧也出现在右侧,如 3.3 所示。产生式`Nom -> Adj Nom`(其中`Nom`是名词性的类别)包含`Nom`类型的直接递归,而`S`上的间接递归来自于两个产生式的组合`S -> NP VP`和`VP -> V S`。 92 | 93 | ```py 94 | grammar2 = nltk.CFG.fromstring(""" 95 | S -> NP VP 96 | NP -> Det Nom | PropN 97 | Nom -> Adj Nom | N 98 | VP -> V Adj | V NP | V S | V NP PP 99 | PP -> P NP 100 | PropN -> 'Buster' | 'Chatterer' | 'Joe' 101 | Det -> 'the' | 'a' 102 | N -> 'bear' | 'squirrel' | 'tree' | 'fish' | 'log' 103 | Adj -> 'angry' | 'frightened' | 'little' | 'tall' 104 | V -> 'chased' | 'saw' | 'said' | 'thought' | 'was' | 'put' 105 | P -> 'on' 106 | """) 107 | ``` 108 | 109 | 要看递归如何从这个语法产生,思考下面的树。`(10a)`包括嵌套的名词短语,而`(10b)`包含嵌套的句子。 110 | 111 | ```py 112 | >>> rd_parser = nltk.RecursiveDescentParser(grammar1) 113 | >>> sent = 'Mary saw a dog'.split() 114 | >>> for tree in rd_parser.parse(sent): 115 | ... print(tree) 116 | (S (NP Mary) (VP (V saw) (NP (Det a) (N dog)))) 117 | ``` 118 | 119 | 注意 120 | 121 | `RecursiveDescentParser()`接受一个可选的参数`trace`。如果`trace`大于零,则分析器将报告它解析一个文本的步骤。 122 | 123 | 递归下降分析有三个主要的缺点。首先,左递归产生式,如`NP -> NP PP`会进入死循环。第二,分析器浪费了很多时间处理不符合输入句子的词和结构。第三,回溯过程中可能会丢弃分析过的成分,它们将需要在之后再次重建。例如,从`VP -> V NP`上回溯将放弃为`NP`创建的子树。如果分析器之后处理`VP -> V NP PP`,那么`NP`子树必须重新创建。 124 | 125 | 递归下降分析是一种自上而下分析。自上而下分析器在检查输入之前先使用文法*预测*输入将是什么!然而,由于输入对分析器一直是可用的,从一开始就考虑输入的句子会是更明智的做法。这种方法被称为自下而上分析,在下一节中我们将看到一个例子。 126 | 127 | ## 4.2 移进-归约分析 128 | 129 | 一种简单的自下而上分析器是移进-归约分析器。与所有自下而上的分析器一样,移进-归约分析器尝试找到对应文法生产式*右侧*的词和短语的序列,用左侧的替换它们,直到整个句子归约为一个`S`。 130 | 131 | 移位-规约分析器反复将下一个输入词推到堆栈`(4.1)`;这是移位操作。如果堆栈上的前`n`项,匹配一些产生式的右侧的`n`个项目,那么就把它们弹出栈,并把产生式左边的项目压入栈。这种替换前`n`项为一项的操作就是规约操作。此操作只适用于堆栈的顶部;规约栈中的项目必须在后面的项目被压入栈之前做。当所有的输入都使用过,堆栈中只剩余一个项目,也就是一颗分析树作为它的根的`S`节点时,分析器完成。移位-规约分析器通过上述过程建立一颗分析树。每次弹出堆栈`n`个项目,它就将它们组合成部分的分析树,然后将这压回推栈。我们可以使用图形化示范`nltk.app.srparser()`看到移位-规约分析算法步骤。执行此分析器的六个阶段,如 4.2 所示。 132 | 133 | ![Images/srparser1-6.png](Images/56cee123595482cf3edaef089cb9a6a7.jpg) 134 | 135 | 图 4.2:移进-归约分析器的六个阶段:分析器一开始把输入的第一个词转移到堆栈;一旦堆栈顶端的项目与一个文法产生式的右侧匹配,就可以将它们用那个产生式的左侧替换;当所有输入都被使用过且堆栈中只有剩余一个项目`S`时,分析成功。 136 | 137 | NLTK 中提供`ShiftReduceParser()`,移进-归约分析器的一个简单的实现。这个分析器不执行任何回溯,所以它不能保证一定能找到一个文本的解析,即使确实存在一个这样的解析。此外,它最多只会找到一个解析,即使有多个解析存在。我们可以提供一个可选的`trace`参数,控制分析器报告它分析一个文本的步骤的繁琐程度。 138 | 139 | ```py 140 | >>> sr_parser = nltk.ShiftReduceParser(grammar1) 141 | >>> sent = 'Mary saw a dog'.split() 142 | >>> for tree in sr_parser.parse(sent): 143 | ... print(tree) 144 | (S (NP Mary) (VP (V saw) (NP (Det a) (N dog)))) 145 | ``` 146 | 147 | 注意 148 | 149 | **轮到你来**:以跟踪模式运行上述分析器,看看序列的移进和规约操作,使用`sr_parse = nltk.ShiftReduceParser(grammar1, trace=2)`。 150 | 151 | 移进-规约分析器可能会到达一个死胡同,而不能找到任何解析,即使输入的句子是符合语法的。这种情况发生时,没有剩余的输入,而堆栈包含不能被规约到一个`S`的项目。问题出现的原因是较早前做出的选择不能被分析器撤销(虽然图形演示中用户可以撤消它们的选择)。分析器可以做两种选择:(a)当有多种规约可能时选择哪个规约(b)当移进和规约都可以时选择哪个动作。 152 | 153 | 移进-规约分析器可以改进执行策略来解决这些冲突。例如,它可以通过只有在不能规约时才移进,解决移进-规约冲突;它可以通过优先执行规约操作,解决规约-规约冲突;它可以从堆栈移除更多的项目。(一个通用的移进-规约分析器,是一个“超前 LR 分析器”,普遍使用在编程语言编译器中。) 154 | 155 | 移进-规约分析器相比递归下降分析器的好处是,它们只建立与输入中的词对应的结构。此外,每个结构它们只建立一次,例如`NP(Det(the), N(man))`只建立和压入栈一次,不管以后`VP -> V NP PP`规约或者`NP -> NP PP`规约会不会用到。 156 | 157 | ## 4.3 左角落分析器 158 | 159 | 递归下降分析器的问题之一是当它遇到一个左递归产生式时,会进入无限循环。这是因为它盲目应用文法产生式而不考虑实际输入的句子。左角落分析器是我们已经看到的自下而上与自上而下方法的混合体。 160 | 161 | 语法`grammar1`允许我们对`John saw Mary`生成下面的分析: 162 | 163 | ```py 164 | >>> text = ['I', 'shot', 'an', 'elephant', 'in', 'my', 'pajamas'] 165 | >>> groucho_grammar.productions(rhs=text[1]) 166 | [V -> 'shot'] 167 | ``` 168 | 169 | 对于我们的 WFST,我们用 Python 中的列表的咧表创建一个`(n-1) × (n-1)`的矩阵,在 4.4 中的函数`init_wfst()`中用每个标识符的词汇类型初始化它。我们还定义一个实用的函数`display()`来为我们精美的输出 WFST。正如预期的那样,`V`在`(1, 2)`单元中。 170 | 171 | ```py 172 | def init_wfst(tokens, grammar): 173 | numtokens = len(tokens) 174 | wfst = [[None for i in range(numtokens+1)] for j in range(numtokens+1)] 175 | for i in range(numtokens): 176 | productions = grammar.productions(rhs=tokens[i]) 177 | wfst[i][i+1] = productions[0].lhs() 178 | return wfst 179 | 180 | def complete_wfst(wfst, tokens, grammar, trace=False): 181 | index = dict((p.rhs(), p.lhs()) for p in grammar.productions()) 182 | numtokens = len(tokens) 183 | for span in range(2, numtokens+1): 184 | for start in range(numtokens+1-span): 185 | end = start + span 186 | for mid in range(start+1, end): 187 | nt1, nt2 = wfst[start][mid], wfst[mid][end] 188 | if nt1 and nt2 and (nt1,nt2) in index: 189 | wfst[start][end] = index[(nt1,nt2)] 190 | if trace: 191 | print("[%s] %3s [%s] %3s [%s] ==> [%s] %3s [%s]" % \ 192 | (start, nt1, mid, nt2, end, start, index[(nt1,nt2)], end)) 193 | return wfst 194 | 195 | def display(wfst, tokens): 196 | print('\nWFST ' + ' '.join(("%-4d" % i) for i in range(1, len(wfst)))) 197 | for i in range(len(wfst)-1): 198 | print("%d " % i, end=" ") 199 | for j in range(1, len(wfst)): 200 | print("%-4s" % (wfst[i][j] or '.'), end=" ") 201 | print() 202 | >>> tokens = "I shot an elephant in my pajamas".split() 203 | >>> wfst0 = init_wfst(tokens, groucho_grammar) 204 | >>> display(wfst0, tokens) 205 | WFST 1 2 3 4 5 6 7 206 | 0 NP . . . . . . 207 | 1 . V . . . . . 208 | 2 . . Det . . . . 209 | 3 . . . N . . . 210 | 4 . . . . P . . 211 | 5 . . . . . Det . 212 | 6 . . . . . . N 213 | >>> wfst1 = complete_wfst(wfst0, tokens, groucho_grammar) 214 | >>> display(wfst1, tokens) 215 | WFST 1 2 3 4 5 6 7 216 | 0 NP . . S . . S 217 | 1 . V . VP . . VP 218 | 2 . . Det NP . . . 219 | 3 . . . N . . . 220 | 4 . . . . P . PP 221 | 5 . . . . . Det NP 222 | 6 . . . . . . N 223 | ``` 224 | 225 | 回到我们的表格表示,假设对于词`an`我们有`Det`在`(2, 3)`单元,对以词`elephant`有`N`在`(3, 4)`单元,对于`an elephant`我们应该在`(2, 4)`放入什么?我们需要找到一个形如`A -> Det N`的产生式。查询了文法,我们知道我们可以输入`(0, 2)`单元的`NP`。 226 | 227 | 更一般的,我们可以在`(i, j)`输入`A`,如果有一个产生式`A -> B C`,并且我们在`(i, k)`中找到非终结符`B`,在`(k, j)`中找到非终结符`C`。4.4 中的程序使用此规则完成 WFST。通过调用函数`complete_wfst()`时设置`trace`为`True`,我们看到了显示 WFST 正在被创建的跟踪输出: 228 | 229 | ```py 230 | >>> wfst1 = complete_wfst(wfst0, tokens, groucho_grammar, trace=True) 231 | [2] Det [3] N [4] ==> [2] NP [4] 232 | [5] Det [6] N [7] ==> [5] NP [7] 233 | [1] V [2] NP [4] ==> [1] VP [4] 234 | [4] P [5] NP [7] ==> [4] PP [7] 235 | [0] NP [1] VP [4] ==> [0] S [4] 236 | [1] VP [4] PP [7] ==> [1] VP [7] 237 | [0] NP [1] VP [7] ==> [0] S [7] 238 | ``` 239 | 240 | 例如,由于我们在`wfst[2][3]`找到`Det`,在`wfst[3][4]`找到`N`,我们可以添加`NP`到`wfst[2][4]`。 241 | 242 | 注意 243 | 244 | 为了帮助我们更简便地通过产生式的右侧检索产生式,我们为语法创建一个索引。这是空间-时间权衡的一个例子:我们对语法做反向查找,每次我们想要通过右侧查找产生式时不必遍历整个产生式列表。 245 | 246 | ![Images/chart_positions2.png](Images/eb630c6034e9ed7274ef2e04b9694347.jpg) 247 | 248 | 图 4.5:图数据结构:图中额外的边表示非终结符。 249 | 250 | 我们得出结论,只要我们已经在`(0, 7)`单元构建了一个`S`节点,表明我们已经找到了一个涵盖了整个输入的句子,我们就为整个输入字符串找到了一个解析。最后的 WFST 状态如 4.5 所示。 251 | 252 | 请注意,在这里我们没有使用任何内置的分析函数。我们已经从零开始实现了一个完整的初级图表分析器! 253 | 254 | WFST 有几个缺点。首先,正如你可以看到的,WFST 本身不是一个分析树,所以该技术严格地说是认识到一个句子被一个语法承认,而不是分析它。其次,它要求每个非词汇语法生产式是二元的。虽然可以将任意的 CFG 转换为这种形式,我们宁愿使用这种方法时没有这样的规定。第三,作为一个自下而上的语法,它潜在的存在浪费,它会在不符合文法的地方提出成分。 255 | 256 | 最后,WFST 并不能表示句子中的结构歧义(如两个动词短语的读取)。`(1, 7)`单元中的`VP`实际上被输入了两次,一次是读取`V NP`,一次是读取`VP PP` 。这是不同的假设,第二个会覆盖第一个(虽然如此,这并不重要,因为左侧是相同的。)图表分析器使用稍微更丰富的数据结构和一些有趣的算法来解决这些问题(详细情况参见本章末尾的进一步阅读一节)。 257 | 258 | 注意 259 | 260 | **轮到你来**:尝试交互式图表分析器应用程序`nltk.app.chartparser()`。 261 | 262 | ## 5 依存关系和依存文法 263 | 264 | 短语结构文法是关于词和词序列如何结合起来形成句子成分的。一个独特的和互补的方式,依存语法,集中关注的是词与其他词之间的关系。依存关系是一个中心词与它的依赖之间的二元对称关系。一个句子的中心词通常是动词,所有其他词要么依赖于中心词,要么依赖路径与它联通。 265 | 266 | 一个句子的中心词通常是动词,所有其他词要么依赖于中心词,要么依赖路径与它联通。5.1 显示一个依存关系图,箭头从中心词指出它们的依赖。 267 | 268 | ![Images/depgraph0.png](Images/ff868af58b8c1843c38287717b137f7c.jpg) 269 | 270 | 图 5.1:依存结构:箭头从中心词指向它们的依赖;标签表示依赖的语法功能如:主语、宾语或修饰语。 271 | 272 | 5.1 中的弧加了依赖与它的中心词之间的语法功能标签。例如,`I`是`shot`(这是整个句子的中心词)的`SBJ`(主语),`in`是一个`NMOD`(`elephant`的名词修饰语)。与短语结构语法相比,依存语法可以作为一种依存关系直接用来表示语法功能。 273 | 274 | 下面是 NLTK 为依存语法编码的一种方式——注意它只能捕捉依存关系信息,不能指定依存关系类型: 275 | 276 | ```py 277 | >>> groucho_dep_grammar = nltk.DependencyGrammar.fromstring(""" 278 | ... 'shot' -> 'I' | 'elephant' | 'in' 279 | ... 'elephant' -> 'an' | 'in' 280 | ... 'in' -> 'pajamas' 281 | ... 'pajamas' -> 'my' 282 | ... """) 283 | >>> print(groucho_dep_grammar) 284 | Dependency grammar with 7 productions 285 | 'shot' -> 'I' 286 | 'shot' -> 'elephant' 287 | 'shot' -> 'in' 288 | 'elephant' -> 'an' 289 | 'elephant' -> 'in' 290 | 'in' -> 'pajamas' 291 | 'pajamas' -> 'my' 292 | ``` 293 | 294 | 依存关系图是一个投影,当所有的词都按线性顺序书写,边可以在词上绘制而不会交叉。这等于是说一个词及其所有后代依赖(依赖及其依赖的依赖,等等)在句子中形成一个连续的词序列。5.1 是一个投影,我们可以使用投影依存关系分析器分析很多英语句子。下面的例子演示`groucho_dep_grammar`如何提供了一种替代的方法来捕捉附着歧义,我们之前在研究短语结构语法中遇到的。 295 | 296 | ```py 297 | >>> pdp = nltk.ProjectiveDependencyParser(groucho_dep_grammar) 298 | >>> sent = 'I shot an elephant in my pajamas'.split() 299 | >>> trees = pdp.parse(sent) 300 | >>> for tree in trees: 301 | ... print(tree) 302 | (shot I (elephant an (in (pajamas my)))) 303 | (shot I (elephant an) (in (pajamas my))) 304 | ``` 305 | 306 | 这些括号括起来的依存关系结构也可以显示为树,依赖被作为它们的中心词的孩子。 307 | 308 | ```py 309 | VP -> TV NP 310 | TV -> 'chased' | 'saw' 311 | 312 | ``` 313 | 314 | ## 5.2 扩大规模 315 | 316 | 到目前为止,我们只考虑了“玩具语法”,演示分析的关键环节的少量的语法。但有一个明显的问题就是这种做法是否可以扩大到覆盖自然语言的大型语料库。手工构建这样的一套产生式有多么困难?一般情况下,答案是:*非常困难*。即使我们允许自己使用各种形式化的工具,它们可以提供语法产生式更简洁的表示,保持对覆盖一种语言的主要成分所需要的众多产生式之间的复杂的相互作用的控制,仍然是极其困难的。换句话说,很难将语法模块化,每部分语法可以独立开发。反过来这意味着,在一个语言学家团队中分配编写语法的任务是很困难的。另一个困难是当语法扩展到包括更加广泛的成分时,适用于任何一个句子的分析的数量也相应增加。换句话说,歧义随着覆盖而增加。 317 | 318 | 尽管存在这些问题,一些大的合作项目在为几种语言开发基于规则的语法上已取得了积极的和令人印象深刻的结果。例如,词汇功能语法(LFG)项目、中心词驱动短语结构文法(HPSG)LinGO 矩阵框架和词汇化树邻接语法 XTAG 项目。 319 | 320 | ## 6 语法开发 321 | 322 | 分析器根据短语结构语法在句子上建立树。现在,我们上面给出的所有例子只涉及玩具语法包含少数的产生式。如果我们尝试扩大这种方法的规模来处理现实的语言语料库会发生什么?在本节中,我们将看到如何访问树库,并看看开发广泛覆盖的语法的挑战。 323 | 324 | ## 6.1 树库和语法 325 | 326 | `corpus`模块定义了`treebank`语料的阅读器,其中包含了宾州树库语料的 10% 的样本。 327 | 328 | ```py 329 | >>> from nltk.corpus import treebank 330 | >>> t = treebank.parsed_sents('wsj_0001.mrg')[0] 331 | >>> print(t) 332 | (S 333 | (NP-SBJ 334 | (NP (NNP Pierre) (NNP Vinken)) 335 | (, ,) 336 | (ADJP (NP (CD 61) (NNS years)) (JJ old)) 337 | (, ,)) 338 | (VP 339 | (MD will) 340 | (VP 341 | (VB join) 342 | (NP (DT the) (NN board)) 343 | (PP-CLR 344 | (IN as) 345 | (NP (DT a) (JJ nonexecutive) (NN director))) 346 | (NP-TMP (NNP Nov.) (CD 29)))) 347 | (. .)) 348 | ``` 349 | 350 | 我们可以利用这些数据来帮助开发一个语法。例如,6.1 中的程序使用一个简单的过滤器找出带句子补语的动词。假设我们已经有一个形如`VP -> Vs S`的产生式,这个信息使我们能够识别那些包括在`Vs`的扩张中的特别的动词。 351 | 352 | ```py 353 | def filter(tree): 354 | child_nodes = [child.label() for child in tree 355 | if isinstance(child, nltk.Tree)] 356 | return (tree.label() == 'VP') and ('S' in child_nodes) 357 | ``` 358 | 359 | PP 附着语料库`nltk.corpus.ppattach`是另一个有关特别动词配价的信息源。在这里,我们演示挖掘这个语料库的技术。它找出具有固定的介词和名词的介词短语对,其中介词短语附着到`VP`还是`NP`,由选择的动词决定。 360 | 361 | ```py 362 | >>> from collections import defaultdict 363 | >>> entries = nltk.corpus.ppattach.attachments('training') 364 | >>> table = defaultdict(lambda: defaultdict(set)) 365 | >>> for entry in entries: 366 | ... key = entry.noun1 + '-' + entry.prep + '-' + entry.noun2 367 | ... table[key][entry.attachment].add(entry.verb) 368 | ... 369 | >>> for key in sorted(table): 370 | ... if len(table[key]) > 1: 371 | ... print(key, 'N:', sorted(table[key]['N']), 'V:', sorted(table[key]['V'])) 372 | ``` 373 | 374 | 这个程序的输出行中我们发现`offer-from-group N: ['rejected'] V: ['received']`,这表示`received`期望一个单独的`PP`附着到`VP`而`rejected`不是的。和以前一样,我们可以使用此信息来帮助构建语法。 375 | 376 | NLTK 语料库收集了来自 PE08 跨框架跨领域分析器评估共享任务的数据。一个更大的文法集合已准备好用于比较不同的分析器,它可以通过下载`large_grammars`包获得(如`python -m nltk.downloader large_grammars`)。 377 | 378 | NLTK 语料库也收集了*中央研究院树库语料*,包括 10,000 句已分析的句子,来自*现代汉语中央研究院平衡语料库*。让我们加载并显示这个语料库中的一棵树。 379 | 380 | ```py 381 | >>> nltk.corpus.sinica_treebank.parsed_sents()[3450].draw() 382 | ``` 383 | 384 | ![Images/sinica-tree.png](Images/10a910dd6de117ab7a0ab352519f7297.jpg) 385 | 386 | ## 6.2 有害的歧义 387 | 388 | 不幸的是,随着文法覆盖范围的增加和输入句子长度的增长,分析树的数量也迅速增长。事实上,它以天文数字的速度增长。 389 | 390 | 让我们在一个简单的例子帮助下来探讨这个问题。词`fish`既是名词又是动词。我们可以造这样的句子`fish fish fish`,意思是`fish like to fish for other fish`。(用`police`尝试一下,如果你喜欢更有意思的东西。)下面是`fish`句子的玩具文法。 391 | 392 | ```py 393 | >>> grammar = nltk.CFG.fromstring(""" 394 | ... S -> NP V NP 395 | ... NP -> NP Sbar 396 | ... Sbar -> NP V 397 | ... NP -> 'fish' 398 | ... V -> 'fish' 399 | ... """) 400 | ``` 401 | 402 | 现在,我们可以尝试分析一个较长的句子,`fish fish fish fish fish`,其中一个意思是:`fish that other fish fish are in the habit of fishing fish themselves`。我们使用 NLTK 的图表分析器,它在本章前面介绍过。这句话有两种读法。 403 | 404 | ```py 405 | >>> tokens = ["fish"] * 5 406 | >>> cp = nltk.ChartParser(grammar) 407 | >>> for tree in cp.parse(tokens): 408 | ... print(tree) 409 | (S (NP fish) (V fish) (NP (NP fish) (Sbar (NP fish) (V fish)))) 410 | (S (NP (NP fish) (Sbar (NP fish) (V fish))) (V fish) (NP fish)) 411 | ``` 412 | 413 | 随着句子长度增加到`(3, 5, 7, ...)`,我们得到的分析树的数量是:`1; 2; 5; 14; 42; 132; 429; 1,430; 4,862; 16,796; 58,786; 208,012; …`(这是卡塔兰数,我们在 4 的练习中见过)。最后一个是句子长度为 23 的分析树的数目,这是宾州树库 WSJ 部分的句子的平均长度。对于一个长度为 50 的句子有超过`10^12`的解析,这只是 Piglet 句子长度的一半`(1)`,这些句子小孩可以毫不费力的处理。没有实际的自然语言处理系统可以为一个句子构建数以百万计的树,并根据上下文选择一个合适的。很显然,人也不会这样做! 414 | 415 | 请注意,这个问题不是只在我们选择的例子中存在。(Church & Patil, 1982)指出`PP`附着句法歧义在像`(18)`这样的句子中也是按卡塔兰数的比例增长。 416 | 417 | ```py 418 | def give(t): 419 | return t.label() == 'VP' and len(t) > 2 and t[1].label() == 'NP'\ 420 | and (t[2].label() == 'PP-DTV' or t[2].label() == 'NP')\ 421 | and ('give' in t[0].leaves() or 'gave' in t[0].leaves()) 422 | def sent(t): 423 | return ' '.join(token for token in t.leaves() if token[0] not in '*-0') 424 | def print_node(t, width): 425 | output = "%s %s: %s / %s: %s" %\ 426 | (sent(t[0]), t[1].label(), sent(t[1]), t[2].label(), sent(t[2])) 427 | if len(output) > width: 428 | output = output[:width] + "..." 429 | print(output) 430 | ``` 431 | 432 | 我们可以观察到一种强烈的倾向就是最短的补语最先出现。然而,这并没有解释类似`give NP: federal judges / NP: a raise`的形式,其中有生性起了重要作用。事实上,根据(Bresnan & Hay, 2006)的调查,存在大量的影响因素。这些偏好可以用加权语法来表示。 433 | 434 | 概率上下文无关语法(或 *PCFG*)是一种上下文无关语法,它的每一个产生式关联一个概率。它会产生与相应的上下文无关语法相同的文本解析,并给每个解析分配一个概率。PCFG 产生的一个解析的概率仅仅是它用到的产生式的概率的乘积。 435 | 436 | 最简单的方法定义一个 PCFG 是从一个加权产生式序列组成的特殊格式的字符串加载它,其中权值出现在括号里,如 6.4 所示。 437 | 438 | ```py 439 | grammar = nltk.PCFG.fromstring(""" 440 | S -> NP VP [1.0] 441 | VP -> TV NP [0.4] 442 | VP -> IV [0.3] 443 | VP -> DatV NP NP [0.3] 444 | TV -> 'saw' [1.0] 445 | IV -> 'ate' [1.0] 446 | DatV -> 'gave' [1.0] 447 | NP -> 'telescopes' [0.8] 448 | NP -> 'Jack' [0.2] 449 | """) 450 | ``` 451 | 452 | 有时可以很方便的将多个产生式组合成一行,如`VP -> TV NP [0.4] | IV [0.3] | DatV NP NP [0.3]`。为了确保由文法生成的树能形成概率分布,PCFG 语法强加了约束,产生式所有给定的左侧的概率之和必须为 1。6.4 中的语法符合这个约束:对`S`只有一个产生式,它的概率是 1.0;对于`VP`,`0.4+0.3+0.3=1.0`;对于`NP`,`0.8+0.2=1.0`。`parse()`返回的分析树包含概率: 453 | 454 | ```py 455 | >>> viterbi_parser = nltk.ViterbiParser(grammar) 456 | >>> for tree in viterbi_parser.parse(['Jack', 'saw', 'telescopes']): 457 | ... print(tree) 458 | (S (NP Jack) (VP (TV saw) (NP telescopes))) (p=0.064) 459 | ``` 460 | 461 | 现在,分析树被分配了概率,一个给定的句子可能有数量庞大的可能的解析就不再是问题。分析器将负责寻找最有可能的解析。 462 | 463 | ## 7 小结 464 | 465 | * 句子都有内部组织结构,可以用一棵树表示。组成结构的显著特点是:递归、中心词、补语和修饰语。 466 | * 语法是一个潜在的无限的句子集合的一个紧凑的特性;我们说,一棵树是符合语法规则的或语法树授权一棵树。 467 | * 语法是用于描述一个给定的短语是否可以被分配一个特定的成分或依赖结构的一种形式化模型。 468 | * 给定一组句法类别,上下文无关文法使用一组生产式表示某类型`A`的短语如何能够被分析成较小的序列`α[1] ... α[n]`。 469 | * 依存语法使用产生式指定给定的中心词的依赖是什么。 470 | * 一个句子有一个以上的句法分析就产生句法歧义(如介词短语附着歧义)。 471 | * 分析器是一个过程,为符合语法规则的句子寻找一个或多个相应的树。 472 | * 一个简单的自上而下分析器是递归下降分析器,在语法产生式的帮助下递归扩展开始符号(通常是`S`),尝试匹配输入的句子。这个分析器并不能处理左递归产生式(如`NP -> NP PP`)。它盲目扩充类别而不检查它们是否与输入字符串兼容的方式效率低下,而且会重复扩充同样的非终结符然后丢弃结果。 473 | * 一个简单的自下而上的分析器是移位-规约分析器,它把输入移到一个堆栈中,并尝试匹配堆栈顶部的项目和语法产生式右边的部分。这个分析器不能保证为输入找到一个有效的解析,即使它确实存在,它建立子结构而不检查它是否与全部语法一致。 474 | 475 | ## 8 深入阅读 476 | 477 | 本章的附加材料发布在`http://nltk.org/`,包括网络上免费提供的资源的链接。关于使用 NLTK 分析的更多的例子,请看在`http://nltk.org/howto`上的分析 HOWTO。 478 | 479 | 有许多关于句法的入门书籍。(O'Grady et al, 2004)是一个语言学概论,而(Radford, 1988)以容易接受的方式介绍转换语法,推荐其中的无限制依赖结构的转换文法。在形式语言学中最广泛使用的术语是生成语法,虽然它与生成并没有关系(Chomsky, 1965)。X-bar 句法来自于(Jacobs & Rosenbaum, 1970),并在(Jackendoff, 1977)得到更深的拓展(我们使用素数替代了 Chomsky 印刷上要求更高的单杠)。 480 | 481 | (Burton-Roberts, 1997)是一本面向实践的关于如何分析英语成分的教科书,包含广泛的例子和练习。(Huddleston & Pullum, 2002)提供了一份最新的英语句法现象的综合分析。 482 | 483 | (Jurafsky & Martin, 2008)的第 12 章讲述英语的形式文法;13.1-3 节讲述简单的分析算法和歧义处理技术;第 14 章讲述统计分析;第 16 章讲述乔姆斯基层次和自然语言的形式复杂性。(Levin, 1993)根据它们的句法属性,将英语动词划分成更细的类。 484 | 485 | 有几个正在进行的建立大规模的基于规则的语法的项目,如 LFG Pargram 项目`http://www2.parc.com/istl/groups/nltt/pargram/`,HPSG LinGO 矩阵框架`http://www.delph-in.net/matrix/`以及 XTAG 项目`http://www.cis.upenn.edu/~xtag/`。 486 | 487 | ## 9 练习 488 | 489 | 1. ☼ 你能想出符合语法的却可能之前从来没有被说出的句子吗?(与伙伴轮流进行。)这告诉你关于人类语言的什么? 490 | 491 | 2. ☼ 回想一下 Strunk 和 White 的禁止在句子开头使用`however`表示`although`的意思。在网上搜索句子开头使用的`however`。这个成分使用的有多广泛? 492 | 493 | 3. ☼ 思考句子`Kim arrived or Dana left and everyone cheered`。用括号的形式表示`and`和`or`的相对范围。产生这两种解释对应的树结构。 494 | 495 | 4. ☼ `Tree`类实现了各种其他有用的方法。请看`Tree`帮助文档查阅更多细节(如导入`Tree`类,然后输入`help(Tree)`)。 496 | 497 | 5. ☼ 在本练习中,你将手动构造一些分析树。 498 | 499 | 1. 编写代码产生两棵树,对应短语`old men and women`的不同读法 500 | 2. 将本章中表示的任一一颗树编码为加标签的括号括起的形式,使用`nltk.Tree()`检查它是否符合语法。使用`draw()`显示树。 501 | 3. 如`(a)`中那样,为`The woman saw a man last Thursday`画一棵树。 502 | 6. ☼ 写一个递归函数,遍历一颗树,返回树的深度,一颗只有一个节点的树的深度应为 0。(提示:子树的深度是其子女的最大深度加 1。) 503 | 504 | 7. ☼ 分析 A.A. Milne 关于 Piglet 的句子,为它包含的所有句子画下划线,然后用`S`替换这些(如第一句话变为`S when:lx S`)。为这种“压缩”的句子画一个树形结构。用于建立这样一个长句的主要的句法结构是什么? 505 | 506 | 8. ☼ 在递归下降分析器的演示中,通过选择`Edit`菜单上的`Edit Text`改变实验句子。 507 | 508 | 9. ☼ `grammar1`中的语法能被用来描述长度超过 20 词的句子吗? 509 | 510 | 10. ☼ 使用图形化图表分析器接口,尝试不同的规则调用策略做实验。拿出你自己的可以使用图形界面手动执行的策略。描述步骤,并报告它的任何效率的提高(例如用结果图表示大小)。这些改进取决于语法结构吗?你觉得一个更聪明的规则调用策略能显著提升性能吗? 511 | 512 | 11. ☼ 对于一个你已经见过的或一个你自己设计的 CFG,用笔和纸手动跟踪递归下降分析器和移位-规约分析器的执行。 513 | 514 | 12. ☼ 我们已经看到图表分析器增加边而从来不从图表中删除的边。为什么? 515 | 516 | 13. ☼ 思考词序列:`Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo`。如`http://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffalo_buffalo_buffalo_Buffalo_buffalo`解释的,这是一个语法正确的句子。思考此维基百科页面上表示的树形图,写一个合适的语法。正常情况下是小写,模拟听到这句话时听者会遇到的问题。你能为这句话找到其他的解析吗?当句子变长时分析树的数量如何增长?(这些句子的更多的例子可以在`http://en.wikipedia.org/wiki/List_of_homophonous_phrases`找到。) 517 | 518 | 14. ◑ 你可以通过选择`Edit`菜单上的`Edit Grammar`修改递归下降分析器演示程序。改变第二次扩充产生式,即`NP -> Det N PP`为`NP -> NP PP`。使用`Step`按钮,尝试建立一个分析树。发生了什么? 519 | 520 | 15. ◑ 扩展`grammar2`中的语法,将产生式中的介词扩展为不及物的,及物的和需要`PP`补语的。基于这些产生式,使用前面练习中的方法为句子`Lee ran away home`画一棵树。 521 | 522 | 16. ◑ 挑选一些常用动词,完成以下任务: 523 | 524 | 1. 写一个程序在 PP 附着语料库`nltk.corpus.ppattach`找到那些动词。找出任何这样的情况,相同的动词有两种不同的附着,其中第一个是名词,或者第二个是名词,或者介词保持不变(正如我们在 2 句法歧义中讨论过的)。 525 | 2. 制定 CFG 语法产生式涵盖其中一些情况。 526 | 17. ◑ 写一个程序,比较自上而下的图表分析器与递归下降分析器的效率`(4)`。使用相同的语法和输入的句子。使用`timeit`模块比较它们的性能(见 4.7,如何做到这一点的一个例子)。 527 | 528 | 18. 比较自上而下、自下而上和左角落分析器的性能,使用相同的语法和 3 个符合语法的测试句子。使用`timeit`记录每个分析器在同一个句子上花费的时间。写一个函数,在这三句话上运行这三个分析器,输出`3×3`格的时间,以及行和列的总计。讨论你的发现。 529 | 530 | 19. ◑ 阅读“garden path”的句子。一个分析器的计算工作与人类处理这些句子的困难性有什么关系?`http://en.wikipedia.org/wiki/Garden_path_sentence` 531 | 532 | 20. ◑ 若要在一个窗口比较多个树,我们可以使用`draw_trees()`方法。定义一些树,尝试一下: 533 | 534 | ```py 535 | >>> from nltk.draw.tree import draw_trees 536 | >>> draw_trees(tree1, tree2, tree3) 537 | ``` 538 | 539 | 21. ◑ 使用树中的位置,列出宾州树库前 100 个句子的主语;为了使结果更容易查看,限制从高度最高为 2 的子树提取主语。 540 | 541 | 22. ◑ 查看 PP 附着语料库,尝试提出一些影响`PP`附着的因素。 542 | 543 | 23. ◑ 在本节中,我们说过简单的用术语 N 元组不能描述所有语言学规律。思考下面的句子,尤其是短语`in his turn`的位置。这是基于 N 元组的方法的一个问题吗? 544 | 545 | > `What was more, the in his turn somewhat youngish Nikolay Parfenovich also turned out to be the only person in the entire world to acquire a sincere liking to our "discriminated-against" public procurator.` (Dostoevsky: The Brothers Karamazov) 546 | 24. ◑ 编写一个递归函数产生嵌套的括号括起的形式的一棵树,显示去掉叶节点之后的子树的非终结符。于是上面的关于 Pierre Vinken 的例子会产生:`[[[NNP NNP]NP , [ADJP [CD NNS]NP JJ]ADJP ,]NP-SBJ MD [VB [DT NN]NP [IN [DT JJ NN]NP]PP-CLR [NNP CD]NP-TMP]VP .]S`。连续的类别应用空格分隔。 547 | 548 | 25. ◑ 从古登堡工程下载一些电子图书。写一个程序扫描这些文本中任何极长的句子。你能找到的最长的句子是什么?这么长的句子的句法结构是什么? 549 | 550 | 26. ◑ 修改函数`init_wfst()`和`complete_wfst()`,使 WFST 中每个单元的内容是一组非终端符而不是一个单独的非终结符。 551 | 552 | 27. ◑ 思考 4.4 中的算法。你能解释为什么分析上下文无关语法是与`n^3`成正比的,其中`n`是输入句子的长度。 553 | 554 | 28. ◑ 处理宾州树库语料库样本`nltk.corpus.treebank`中的每棵树,在`Tree.productions()`的帮助下提取产生式。丢弃只出现一次的产生式。具有相同的左侧和类似的右侧的产生式可以被折叠,产生一个等价的却更紧凑的规则集。编写代码输出一个紧凑的语法。 555 | 556 | 29. ★ 英语中定义句子`S`的主语的一种常见的方法是作为`S`的*孩子*和`VP`的*兄弟*的名词短语。写一个函数,以一句话的树为参数,返回句子主语对应的子树。如果传递给这个函数的树的根节点不是`S`或它缺少一个主语,应该怎么做? 557 | 558 | 30. ★ 写一个函数,以一个语法(如 3.1 定义的语法)为参数,返回由这个语法随机产生的一个句子。(使用`grammar.start()`找出语法的开始符号;`grammar.productions(lhs)`得到具有指定左侧的语法的产生式的列表;`production.rhs()`得到一个产生式的右侧。) 559 | 560 | 31. ★ 使用回溯实现移位-规约分析器的一个版本,使它找出一个句子所有可能的解析,它可以被称为“递归上升分析器”。咨询维基百科关于回溯的条目`http://en.wikipedia.org/wiki/Backtracking` 561 | 562 | 32. ★ 正如我们在 7 中所看到的,可以将词块表示成它们的词块标签。当我们为包含`gave`的句子做这个的时候,我们发现如以下模式: 563 | 564 | ```py 565 | gave NP 566 | gave up NP in NP 567 | gave NP up 568 | gave NP NP 569 | gave NP to NP 570 | 571 | ``` -------------------------------------------------------------------------------- /docs/9.md: -------------------------------------------------------------------------------- 1 | # 9 构建基于特征的语法 2 | 3 | 自然语言具有范围广泛的语法结构,用 8 中所描述的简单的方法很难处理的如此广泛的语法结构。为了获得更大的灵活性,我们改变我们对待语法类别如`S`、`NP`和`V`的方式。我们将这些原子标签分解为类似字典的结构,其特征可以为一个范围的值。 4 | 5 | 本章的目的是要回答下列问题: 6 | 7 | 1. 我们怎样用特征扩展上下文无关语法框架,以获得更细粒度的对语法类别和产生式的控制? 8 | 2. 特征结构的主要形式化属性是什么,我们如何使用它们来计算? 9 | 3. 我们现在用基于特征的语法能捕捉到什么语言模式和语法结构? 10 | 11 | 一路上,我们将介绍更多的英语句法主题,包括约定、子类别和无限制依赖成分等现象。 12 | 13 | ## 1 语法特征 14 | 15 | 在第六章中,我们描述了如何建立基于检测文本特征的分类器。那些特征可能非常简单,如提取一个单词的最后一个字母,或者更复杂一点儿,如分类器自己预测的词性标签。在本章中,我们将探讨特征在建立基于规则的语法中的作用。对比特征提取,记录已经自动检测到的特征,我们现在要*声明*词和短语的特征。我们以一个很简单的例子开始,使用字典存储特征和它们的值。 16 | 17 | ```py 18 | >>> kim = {'CAT': 'NP', 'ORTH': 'Kim', 'REF': 'k'} 19 | >>> chase = {'CAT': 'V', 'ORTH': 'chased', 'REL': 'chase'} 20 | ``` 21 | 22 | 对象`kim`和`chase`有几个共同的特征,`CAT`(语法类别)和`ORTH`(正字法,即拼写)。此外,每一个还有更面向语义的特征:`kim['REF']`意在给出`kim`的指示物,而`chase['REL']`给出`chase`表示的关系。在基于规则的语法上下文中,这样的特征和特征值对被称为特征结构,我们将很快看到它们的替代符号。 23 | 24 | 特征结构包含各种有关语法实体的信息。这些信息不需要详尽无遗,我们可能要进一步增加属性。例如,对于一个动词,根据动词的参数知道它扮演的“语义角色”往往很有用。对于`chase`,主语扮演“施事”的角色,而宾语扮演“受事”角色。让我们添加这些信息,使用`'sbj'`和`'obj'`作为占位符,它会被填充,当动词和它的语法参数结合时: 25 | 26 | ```py 27 | >>> chase['AGT'] = 'sbj' 28 | >>> chase['PAT'] = 'obj' 29 | ``` 30 | 31 | 如果我们现在处理句子`Kim chased Lee`,我们要“绑定”动词的施事角色和主语,受事角色和宾语。我们可以通过链接到相关的`NP`的`REF`特征做到这个。在下面的例子中,我们做一个简单的假设:在动词直接左侧和右侧的`NP`分别是主语和宾语。我们还在例子结尾为`Lee`添加了一个特征结构。 32 | 33 | ```py 34 | >>> sent = "Kim chased Lee" 35 | >>> tokens = sent.split() 36 | >>> lee = {'CAT': 'NP', 'ORTH': 'Lee', 'REF': 'l'} 37 | >>> def lex2fs(word): 38 | ... for fs in [kim, lee, chase]: 39 | ... if fs['ORTH'] == word: 40 | ... return fs 41 | >>> subj, verb, obj = lex2fs(tokens[0]), lex2fs(tokens[1]), lex2fs(tokens[2]) 42 | >>> verb['AGT'] = subj['REF'] 43 | >>> verb['PAT'] = obj['REF'] 44 | >>> for k in ['ORTH', 'REL', 'AGT', 'PAT']: 45 | ... print("%-5s => %s" % (k, verb[k])) 46 | ORTH => chased 47 | REL => chase 48 | AGT => k 49 | PAT => l 50 | ``` 51 | 52 | 同样的方法可以适用不同的动词,例如`surprise`,虽然在这种情况下,主语将扮演“源事”(`SRC`)的角色,宾语扮演“体验者”(`EXP`)的角色: 53 | 54 | ```py 55 | >>> surprise = {'CAT': 'V', 'ORTH': 'surprised', 'REL': 'surprise', 56 | ... 'SRC': 'sbj', 'EXP': 'obj'} 57 | ``` 58 | 59 | 特征结构是非常强大的,但我们操纵它们的方式是极其*特别的*。我们本章接下来的任务是,显示上下文无关语法和分析如何能扩展到合适的特征结构,使我们可以一种更通用的和有原则的方式建立像这样的分析。我们将通过查看句法协议的现象作为开始;我们将展示如何使用特征典雅的表示协议约束,并在一个简单的语法中说明它们的用法。 60 | 61 | 由于特征结构是表示任何形式的信息的通用的数据结构,我们将从更形式化的视点简要地看着它们,并演示 NLTK 提供的特征结构的支持。在本章的最后一部分,我们将表明,特征的额外表现力开辟了一个用于描述语言结构的复杂性的广泛的可能性。 62 | 63 | ## 1.1 句法协议 64 | 65 | 下面的例子展示词序列对,其中第一个是符合语法的而第二个不是。(我们在词序列的开头用星号表示它是不符合语法的。) 66 | 67 | ```py 68 | S -> NP VP 69 | NP -> Det N 70 | VP -> V 71 | 72 | Det -> 'this' 73 | N -> 'dog' 74 | V -> 'runs' 75 | 76 | ``` 77 | 78 | ## 1.2 使用属性和约束 79 | 80 | 我们说过非正式的语言类别具有*属性*;例如,名词具有复数的属性。让我们把这个弄的更明确: 81 | 82 | ```py 83 | N[NUM=pl] 84 | 85 | ``` 86 | 87 | 注意一个句法类别可以有多个特征,例如`V[TENSE=pres, NUM=pl]`。在一般情况下,我们喜欢多少特征就可以添加多少。 88 | 89 | 关于 1.1 的最后的细节是语句`%start S`。这个“指令”告诉分析器以`S`作为文法的开始符号。 90 | 91 | 一般情况下,即使我们正在尝试开发很小的语法,把产生式放在一个文件中我们可以编辑、测试和修改是很方便的。我们将 1.1 以 NLTK 的数据格式保存为文件`'feat0.fcfg'`。你可以使用`nltk.data.load()`制作你自己的副本进行进一步的实验。 92 | 93 | 1.2 说明了基于特征的语法图表解析的操作。为输入分词之后,我们导入`load_parser`函数❶,以语法文件名为输入,返回一个图表分析器`cp`❷。调用分析器的`parse()`方法将迭代生成的分析树;如果文法无法分析输入,`trees`将为空,并将会包含一个或多个分析树,取决于输入是否有句法歧义。 94 | 95 | ```py 96 | >>> tokens = 'Kim likes children'.split() 97 | >>> from nltk import load_parser ❶ 98 | >>> cp = load_parser('grammars/book_grammars/feat0.fcfg', trace=2) ❷ 99 | >>> for tree in cp.parse(tokens): 100 | ... print(tree) 101 | ... 102 | |.Kim .like.chil.| 103 | Leaf Init Rule: 104 | |[----] . .| [0:1] 'Kim' 105 | |. [----] .| [1:2] 'likes' 106 | |. . [----]| [2:3] 'children' 107 | Feature Bottom Up Predict Combine Rule: 108 | |[----] . .| [0:1] PropN[NUM='sg'] -> 'Kim' * 109 | Feature Bottom Up Predict Combine Rule: 110 | |[----] . .| [0:1] NP[NUM='sg'] -> PropN[NUM='sg'] * 111 | Feature Bottom Up Predict Combine Rule: 112 | |[----> . .| [0:1] S[] -> NP[NUM=?n] * VP[NUM=?n] {?n: 'sg'} 113 | Feature Bottom Up Predict Combine Rule: 114 | |. [----] .| [1:2] TV[NUM='sg', TENSE='pres'] -> 'likes' * 115 | Feature Bottom Up Predict Combine Rule: 116 | |. [----> .| [1:2] VP[NUM=?n, TENSE=?t] -> TV[NUM=?n, TENSE=?t] * NP[] {?n: 'sg', ?t: 'pres'} 117 | Feature Bottom Up Predict Combine Rule: 118 | |. . [----]| [2:3] N[NUM='pl'] -> 'children' * 119 | Feature Bottom Up Predict Combine Rule: 120 | |. . [----]| [2:3] NP[NUM='pl'] -> N[NUM='pl'] * 121 | Feature Bottom Up Predict Combine Rule: 122 | |. . [---->| [2:3] S[] -> NP[NUM=?n] * VP[NUM=?n] {?n: 'pl'} 123 | Feature Single Edge Fundamental Rule: 124 | |. [---------]| [1:3] VP[NUM='sg', TENSE='pres'] -> TV[NUM='sg', TENSE='pres'] NP[] * 125 | Feature Single Edge Fundamental Rule: 126 | |[==============]| [0:3] S[] -> NP[NUM='sg'] VP[NUM='sg'] * 127 | (S[] 128 | (NP[NUM='sg'] (PropN[NUM='sg'] Kim)) 129 | (VP[NUM='sg', TENSE='pres'] 130 | (TV[NUM='sg', TENSE='pres'] likes) 131 | (NP[NUM='pl'] (N[NUM='pl'] children)))) 132 | ``` 133 | 134 | 分析过程中的细节对于当前的目标并不重要。然而,有一个实施上的问题与我们前面的讨论语法的大小有关。分析包含特征限制的产生式的一种可行的方法是编译出问题中特征的所有可接受的值,是我们最终得到一个大的完全指定的`(6)`中那样的 CFG。相比之下,前面例子中显示的分析器过程直接与给定语法的未指定的产生式一起运作。特征值从词汇条目“向上流动”,变量值于是通过如`{?n: 'sg', ?t: 'pres'}`这样的绑定(即字典)与那些值关联起来。当分析器装配有关它正在建立的树的节点的信息时,这些变量绑定被用来实例化这些节点中的值;从而通过查找绑定中`?n`和`?t`的值,未指定的`VP[NUM=?n, TENSE=?t] -> TV[NUM=?n, TENSE=?t] NP[]`实例化为`VP[NUM='sg', TENSE='pres'] -> TV[NUM='sg', TENSE='pres'] NP[]`。 135 | 136 | 最后,我们可以检查生成的分析树(在这种情况下,只有一个)。 137 | 138 | ```py 139 | >>> for tree in trees: print(tree) 140 | (S[] 141 | (NP[NUM='sg'] (PropN[NUM='sg'] Kim)) 142 | (VP[NUM='sg', TENSE='pres'] 143 | (TV[NUM='sg', TENSE='pres'] likes) 144 | (NP[NUM='pl'] (N[NUM='pl'] children)))) 145 | ``` 146 | 147 | ## 1.3 术语 148 | 149 | 到目前为止,我们只看到像`sg`和`pl`这样的特征值。这些简单的值通常被称为原子——也就是,它们不能被分解成更小的部分。原子值的一种特殊情况是布尔值,也就是说,值仅仅指定一个属性是真还是假。例如,我们可能要用布尔特征`AUX`区分助动词,如`can`,`may`,`will`和`do`。例如,产生式`V[TENSE=pres, AUX=+] -> 'can'`意味着`can`接受`TENSE`的值为`pres`,并且`AUX`的值为`+`或`true`。有一个广泛采用的约定用缩写表示布尔特征`f`;不用`AUX=+`或`AUX=-`,我们分别用`+AUX`和`-AUX`。这些都是缩写,然而,分析器就像`+`和`-`是其他原子值一样解释它们。`(15)`显示了一些有代表性的产生式: 150 | 151 | ```py 152 | V[TENSE=pres, +AUX] -> 'can' 153 | V[TENSE=pres, +AUX] -> 'may' 154 | 155 | V[TENSE=pres, -AUX] -> 'walks' 156 | V[TENSE=pres, -AUX] -> 'likes' 157 | 158 | ``` 159 | 160 | 在传递中,我们应该指出有显示 AVM 的替代方法;1.3 显示了一个例子。虽然特征结构呈现的`(16)`中的风格不太悦目,我们将坚持用这种格式,因为它对应我们将会从 NLTK 得到的输出。 161 | 162 | 关于表示,我们也注意到特征结构,像字典,对特征的*顺序*没有指定特别的意义。所以`(16)`等同于: 163 | 164 | ```py 165 | [AGR = [NUM = pl ]] 166 | [ [PER = 3 ]] 167 | [ [GND = fem ]] 168 | [ ] 169 | [POS = N ] 170 | 171 | ``` 172 | 173 | ## 2 处理特征结构 174 | 175 | 在本节中,我们将展示如何在 NLTK 中构建和操作特征结构。我们还将讨论统一的基本操作,这使我们能够结合两个不同的特征结构中的信息。 176 | 177 | NLTK 中的特征结构使用构造函数`FeatStruct()`声明。原子特征值可以是字符串或整数。 178 | 179 | ```py 180 | >>> fs1 = nltk.FeatStruct(TENSE='past', NUM='sg') 181 | >>> print(fs1) 182 | [ NUM = 'sg' ] 183 | [ TENSE = 'past' ] 184 | ``` 185 | 186 | 一个特征结构实际上只是一种字典,所以我们可以平常的方式通过索引访问它的值。我们可以用我们熟悉的方式*赋*值给特征: 187 | 188 | ```py 189 | >>> fs1 = nltk.FeatStruct(PER=3, NUM='pl', GND='fem') 190 | >>> print(fs1['GND']) 191 | fem 192 | >>> fs1['CASE'] = 'acc' 193 | ``` 194 | 195 | 我们还可以为特征结构定义更复杂的值,如前面所讨论的。 196 | 197 | ```py 198 | >>> fs2 = nltk.FeatStruct(POS='N', AGR=fs1) 199 | >>> print(fs2) 200 | [ [ CASE = 'acc' ] ] 201 | [ AGR = [ GND = 'fem' ] ] 202 | [ [ NUM = 'pl' ] ] 203 | [ [ PER = 3 ] ] 204 | [ ] 205 | [ POS = 'N' ] 206 | >>> print(fs2['AGR']) 207 | [ CASE = 'acc' ] 208 | [ GND = 'fem' ] 209 | [ NUM = 'pl' ] 210 | [ PER = 3 ] 211 | >>> print(fs2['AGR']['PER']) 212 | 3 213 | ``` 214 | 215 | 指定特征结构的另一种方法是使用包含`feature=value`格式的特征-值对的方括号括起的字符串,其中值本身可能是特征结构: 216 | 217 | ```py 218 | >>> print(nltk.FeatStruct("[POS='N', AGR=[PER=3, NUM='pl', GND='fem']]")) 219 | [ [ GND = 'fem' ] ] 220 | [ AGR = [ NUM = 'pl' ] ] 221 | [ [ PER = 3 ] ] 222 | [ ] 223 | [ POS = 'N' ] 224 | ``` 225 | 226 | 特征结构本身并不依赖于语言对象;它们是表示知识的通用目的的结构。例如,我们可以将一个人的信息用特征结构编码: 227 | 228 | ```py 229 | >>> print(nltk.FeatStruct(NAME='Lee', TELNO='01 27 86 42 96', AGE=33)) 230 | [ AGE = 33 ] 231 | [ NAME = 'Lee' ] 232 | [ TELNO = '01 27 86 42 96' ] 233 | ``` 234 | 235 | 在接下来的几页中,我们会使用这样的例子来探讨特征结构的标准操作。这将使我们暂时从自然语言处理转移,因为在我们回来谈论语法之前需要打下基础。坚持! 236 | 237 | 将特征结构作为图来查看往往是有用的;更具体的,作为有向无环图(DAG)。`(19)`等同于上面的 AVM。 238 | 239 | ```py 240 | >>> print(nltk.FeatStruct("""[NAME='Lee', ADDRESS=(1)[NUMBER=74, STREET='rue Pascal'], 241 | ... SPOUSE=[NAME='Kim', ADDRESS->(1)]]""")) 242 | [ ADDRESS = (1) [ NUMBER = 74 ] ] 243 | [ [ STREET = 'rue Pascal' ] ] 244 | [ ] 245 | [ NAME = 'Lee' ] 246 | [ ] 247 | [ SPOUSE = [ ADDRESS -> (1) ] ] 248 | [ [ NAME = 'Kim' ] ] 249 | ``` 250 | 251 | 括号内的整数有时也被称为标记或同指标志。整数的选择并不重要。可以有任意数目的标记在一个单独的特征结构中。 252 | 253 | ```py 254 | >>> print(nltk.FeatStruct("[A='a', B=(1)[C='c'], D->(1), E->(1)]")) 255 | [ A = 'a' ] 256 | [ ] 257 | [ B = (1) [ C = 'c' ] ] 258 | [ ] 259 | [ D -> (1) ] 260 | [ E -> (1) ] 261 | ``` 262 | 263 | ## 2.1 包含和统一 264 | 265 | 认为特征结构提供一些对象的部分信息是很正常的,在这个意义上,我们可以根据它们通用的程度给特征结构排序。例如,`(23a)`比`(23b)`具有更少特征,`(23b)`比`(23c)`具有更少特征。 266 | 267 | ```py 268 | [NUMBER = 74] 269 | 270 | ``` 271 | 272 | 统一被正式定义为一个(部分)二元操作:`FS[0] ⊔ FS[1]`。统一是对称的,所以`FS[0] ⊔ FS[1] = FS[1] ⊔ FS[0]`。在 Python 中也是如此: 273 | 274 | ```py 275 | >>> print(fs2.unify(fs1)) 276 | [ CITY = 'Paris' ] 277 | [ NUMBER = 74 ] 278 | [ STREET = 'rue Pascal' ] 279 | ``` 280 | 281 | 如果我们统一两个具有包含关系的特征结构,那么统一的结果是两个中更具体的那个: 282 | 283 | ```py 284 | >>> fs0 = nltk.FeatStruct(A='a') 285 | >>> fs1 = nltk.FeatStruct(A='b') 286 | >>> fs2 = fs0.unify(fs1) 287 | >>> print(fs2) 288 | None 289 | ``` 290 | 291 | 现在,如果我们看一下统一如何与结构共享相互作用,事情就变得很有趣。首先,让我们在 Python 中定义`(21)`: 292 | 293 | ```py 294 | >>> fs0 = nltk.FeatStruct("""[NAME=Lee, 295 | ... ADDRESS=[NUMBER=74, 296 | ... STREET='rue Pascal'], 297 | ... SPOUSE= [NAME=Kim, 298 | ... ADDRESS=[NUMBER=74, 299 | ... STREET='rue Pascal']]]""") 300 | >>> print(fs0) 301 | [ ADDRESS = [ NUMBER = 74 ] ] 302 | [ [ STREET = 'rue Pascal' ] ] 303 | [ ] 304 | [ NAME = 'Lee' ] 305 | [ ] 306 | [ [ ADDRESS = [ NUMBER = 74 ] ] ] 307 | [ SPOUSE = [ [ STREET = 'rue Pascal' ] ] ] 308 | [ [ ] ] 309 | [ [ NAME = 'Kim' ] ] 310 | ``` 311 | 312 | 我们为`Kim`的地址指定一个`CITY`作为参数会发生什么?请注意,`fs1`需要包括从特征结构的根到`CITY`的整个路径。 313 | 314 | ```py 315 | >>> fs1 = nltk.FeatStruct("[SPOUSE = [ADDRESS = [CITY = Paris]]]") 316 | >>> print(fs1.unify(fs0)) 317 | [ ADDRESS = [ NUMBER = 74 ] ] 318 | [ [ STREET = 'rue Pascal' ] ] 319 | [ ] 320 | [ NAME = 'Lee' ] 321 | [ ] 322 | [ [ [ CITY = 'Paris' ] ] ] 323 | [ [ ADDRESS = [ NUMBER = 74 ] ] ] 324 | [ SPOUSE = [ [ STREET = 'rue Pascal' ] ] ] 325 | [ [ ] ] 326 | [ [ NAME = 'Kim' ] ] 327 | ``` 328 | 329 | 通过对比,如果`fs1`与`fs2`的结构共享版本统一,结果是非常不同的(如图`(22)`所示): 330 | 331 | ```py 332 | >>> fs2 = nltk.FeatStruct("""[NAME=Lee, ADDRESS=(1)[NUMBER=74, STREET='rue Pascal'], 333 | ... SPOUSE=[NAME=Kim, ADDRESS->(1)]]""") 334 | >>> print(fs1.unify(fs2)) 335 | [ [ CITY = 'Paris' ] ] 336 | [ ADDRESS = (1) [ NUMBER = 74 ] ] 337 | [ [ STREET = 'rue Pascal' ] ] 338 | [ ] 339 | [ NAME = 'Lee' ] 340 | [ ] 341 | [ SPOUSE = [ ADDRESS -> (1) ] ] 342 | [ [ NAME = 'Kim' ] ] 343 | ``` 344 | 345 | 不是仅仅更新`Kim`的`Lee`的地址的“副本”,我们现在同时更新他们两个的地址。更一般的,如果统一包含指定一些路径`π`的值,那么统一同时更新等价于π的任何路径的值。 346 | 347 | 正如我们已经看到的,结构共享也可以使用变量表示,如`?x`。 348 | 349 | ```py 350 | >>> fs1 = nltk.FeatStruct("[ADDRESS1=[NUMBER=74, STREET='rue Pascal']]") 351 | >>> fs2 = nltk.FeatStruct("[ADDRESS1=?x, ADDRESS2=?x]") 352 | >>> print(fs2) 353 | [ ADDRESS1 = ?x ] 354 | [ ADDRESS2 = ?x ] 355 | >>> print(fs2.unify(fs1)) 356 | [ ADDRESS1 = (1) [ NUMBER = 74 ] ] 357 | [ [ STREET = 'rue Pascal' ] ] 358 | [ ] 359 | [ ADDRESS2 -> (1) ] 360 | ``` 361 | 362 | ## 3 扩展基于特征的语法 363 | 364 | 在本节中,我们回到基于特征的语法,探索各种语言问题,并展示将特征纳入语法的好处。 365 | 366 | ## 3.1 子类别 367 | 368 | 第 8 中,我们增强了类别标签表示不同类别的动词,分别用标签`IV`和`TV`表示不及物动词和及物动词。这使我们能编写如下的产生式: 369 | 370 | ```py 371 | VP -> IV 372 | VP -> TV NP 373 | 374 | ``` 375 | 376 | ## 3.2 核心词回顾 377 | 378 | 我们注意到,在上一节中,通过从主类别标签分解出子类别信息,我们可以表达有关动词属性的更多概括。类似的另一个属性如下:`V`类的表达式是`VP`类的短语的核心。同样,`N`是`NP`的核心词,`A`(即形容词)是`AP`的核心词,`P`(即介词)是`PP`的核心词。并非所有的短语都有核心词——例如,一般认为连词短语(如`the book and the bell`)缺乏核心词——然而,我们希望我们的语法形式能表达它所持有的父母/核心子女关系。现在,`V`和`VP`只是原子符号,我们需要找到一种方法用特征将它们关联起来(就像我们以前关联`IV`和`TV`那样)。 379 | 380 | X-bar 句法通过抽象出短语级别的概念,解决了这个问题。它通常认为有三个这样的级别。如果`N`表示词汇级别,那么`N`'表示更高一层级别,对应较传统的级别`Nom`,`N`''表示短语级别,对应类别`NP`。`(34a)`演示了这种表示结构,而`(34b)`是更传统的对应。 381 | 382 | ```py 383 | S -> N[BAR=2] V[BAR=2] 384 | N[BAR=2] -> Det N[BAR=1] 385 | N[BAR=1] -> N[BAR=1] P[BAR=2] 386 | N[BAR=1] -> N[BAR=0] P[BAR=2] 387 | N[BAR=1] -> N[BAR=0]XS 388 | 389 | ``` 390 | 391 | ## 3.3 助动词与倒装 392 | 393 | 倒装从句——其中的主语和动词顺序互换——出现在英语疑问句,也出现在“否定”副词之后: 394 | 395 | ```py 396 | S[+INV] -> V[+AUX] NP VP 397 | 398 | ``` 399 | 400 | ## 3.4 无限制依赖成分 401 | 402 | 考虑下面的对比: 403 | 404 | ```py 405 | >>> nltk.data.show_cfg('grammars/book_grammars/feat1.fcfg') 406 | % start S 407 | # ################### 408 | # Grammar Productions 409 | # ################### 410 | S[-INV] -> NP VP 411 | S[-INV]/?x -> NP VP/?x 412 | S[-INV] -> NP S/NP 413 | S[-INV] -> Adv[+NEG] S[+INV] 414 | S[+INV] -> V[+AUX] NP VP 415 | S[+INV]/?x -> V[+AUX] NP VP/?x 416 | SBar -> Comp S[-INV] 417 | SBar/?x -> Comp S[-INV]/?x 418 | VP -> V[SUBCAT=intrans, -AUX] 419 | VP -> V[SUBCAT=trans, -AUX] NP 420 | VP/?x -> V[SUBCAT=trans, -AUX] NP/?x 421 | VP -> V[SUBCAT=clause, -AUX] SBar 422 | VP/?x -> V[SUBCAT=clause, -AUX] SBar/?x 423 | VP -> V[+AUX] VP 424 | VP/?x -> V[+AUX] VP/?x 425 | # ################### 426 | # Lexical Productions 427 | # ################### 428 | V[SUBCAT=intrans, -AUX] -> 'walk' | 'sing' 429 | V[SUBCAT=trans, -AUX] -> 'see' | 'like' 430 | V[SUBCAT=clause, -AUX] -> 'say' | 'claim' 431 | V[+AUX] -> 'do' | 'can' 432 | NP[-WH] -> 'you' | 'cats' 433 | NP[+WH] -> 'who' 434 | Adv[+NEG] -> 'rarely' | 'never' 435 | NP/NP -> 436 | Comp -> 'that' 437 | ``` 438 | 439 | 3.1 中的语法包含一个“缺口引进”产生式,即`S[-INV] -> NP S/NP`。为了正确的预填充斜线特征,我们需要为扩展`S`,`VP`和`NP`的产生式中箭头两侧的斜线添加变量值。例如,`VP/?x -> V SBar/?x`是`VP -> V SBar`的斜线版本,也就是说,可以为一个成分的父母`VP`指定斜线值,只要也为孩子`SBar`指定同样的值。最后,`NP/NP ->`允许`NP`上的斜线信息为空字符串。使用 3.1 中的语法,我们可以分析序列`who do you claim that you like`。 440 | 441 | ```py 442 | >>> tokens = 'who do you claim that you like'.split() 443 | >>> from nltk import load_parser 444 | >>> cp = load_parser('grammars/book_grammars/feat1.fcfg') 445 | >>> for tree in cp.parse(tokens): 446 | ... print(tree) 447 | (S[-INV] 448 | (NP[+WH] who) 449 | (S[+INV]/NP[] 450 | (V[+AUX] do) 451 | (NP[-WH] you) 452 | (VP[]/NP[] 453 | (V[-AUX, SUBCAT='clause'] claim) 454 | (SBar[]/NP[] 455 | (Comp[] that) 456 | (S[-INV]/NP[] 457 | (NP[-WH] you) 458 | (VP[]/NP[] (V[-AUX, SUBCAT='trans'] like) (NP[]/NP[] ))))))) 459 | ``` 460 | 461 | 这棵树的一个更易读的版本如`(52)`所示。 462 | 463 | ```py 464 | >>> tokens = 'you claim that you like cats'.split() 465 | >>> for tree in cp.parse(tokens): 466 | ... print(tree) 467 | (S[-INV] 468 | (NP[-WH] you) 469 | (VP[] 470 | (V[-AUX, SUBCAT='clause'] claim) 471 | (SBar[] 472 | (Comp[] that) 473 | (S[-INV] 474 | (NP[-WH] you) 475 | (VP[] (V[-AUX, SUBCAT='trans'] like) (NP[-WH] cats)))))) 476 | ``` 477 | 478 | 此外,它还允许没有`wh`结构的倒装句: 479 | 480 | ```py 481 | >>> tokens = 'rarely do you sing'.split() 482 | >>> for tree in cp.parse(tokens): 483 | ... print(tree) 484 | (S[-INV] 485 | (Adv[+NEG] rarely) 486 | (S[+INV] 487 | (V[+AUX] do) 488 | (NP[-WH] you) 489 | (VP[] (V[-AUX, SUBCAT='intrans'] sing)))) 490 | ``` 491 | 492 | ## 3.5 德语中的格和性别 493 | 494 | 与英语相比,德语的协议具有相对丰富的形态。例如,在德语中定冠词根据格、性别和数量变化,如 3.1 所示。 495 | 496 | 表 3.1: 497 | 498 | 德语定冠词的形态范式 499 | 500 | ```py 501 | >>> nltk.data.show_cfg('grammars/book_grammars/german.fcfg') 502 | % start S 503 | # Grammar Productions 504 | S -> NP[CASE=nom, AGR=?a] VP[AGR=?a] 505 | NP[CASE=?c, AGR=?a] -> PRO[CASE=?c, AGR=?a] 506 | NP[CASE=?c, AGR=?a] -> Det[CASE=?c, AGR=?a] N[CASE=?c, AGR=?a] 507 | VP[AGR=?a] -> IV[AGR=?a] 508 | VP[AGR=?a] -> TV[OBJCASE=?c, AGR=?a] NP[CASE=?c] 509 | # Lexical Productions 510 | # Singular determiners 511 | # masc 512 | Det[CASE=nom, AGR=[GND=masc,PER=3,NUM=sg]] -> 'der' 513 | Det[CASE=dat, AGR=[GND=masc,PER=3,NUM=sg]] -> 'dem' 514 | Det[CASE=acc, AGR=[GND=masc,PER=3,NUM=sg]] -> 'den' 515 | # fem 516 | Det[CASE=nom, AGR=[GND=fem,PER=3,NUM=sg]] -> 'die' 517 | Det[CASE=dat, AGR=[GND=fem,PER=3,NUM=sg]] -> 'der' 518 | Det[CASE=acc, AGR=[GND=fem,PER=3,NUM=sg]] -> 'die' 519 | # Plural determiners 520 | Det[CASE=nom, AGR=[PER=3,NUM=pl]] -> 'die' 521 | Det[CASE=dat, AGR=[PER=3,NUM=pl]] -> 'den' 522 | Det[CASE=acc, AGR=[PER=3,NUM=pl]] -> 'die' 523 | # Nouns 524 | N[AGR=[GND=masc,PER=3,NUM=sg]] -> 'Hund' 525 | N[CASE=nom, AGR=[GND=masc,PER=3,NUM=pl]] -> 'Hunde' 526 | N[CASE=dat, AGR=[GND=masc,PER=3,NUM=pl]] -> 'Hunden' 527 | N[CASE=acc, AGR=[GND=masc,PER=3,NUM=pl]] -> 'Hunde' 528 | N[AGR=[GND=fem,PER=3,NUM=sg]] -> 'Katze' 529 | N[AGR=[GND=fem,PER=3,NUM=pl]] -> 'Katzen' 530 | # Pronouns 531 | PRO[CASE=nom, AGR=[PER=1,NUM=sg]] -> 'ich' 532 | PRO[CASE=acc, AGR=[PER=1,NUM=sg]] -> 'mich' 533 | PRO[CASE=dat, AGR=[PER=1,NUM=sg]] -> 'mir' 534 | PRO[CASE=nom, AGR=[PER=2,NUM=sg]] -> 'du' 535 | PRO[CASE=nom, AGR=[PER=3,NUM=sg]] -> 'er' | 'sie' | 'es' 536 | PRO[CASE=nom, AGR=[PER=1,NUM=pl]] -> 'wir' 537 | PRO[CASE=acc, AGR=[PER=1,NUM=pl]] -> 'uns' 538 | PRO[CASE=dat, AGR=[PER=1,NUM=pl]] -> 'uns' 539 | PRO[CASE=nom, AGR=[PER=2,NUM=pl]] -> 'ihr' 540 | PRO[CASE=nom, AGR=[PER=3,NUM=pl]] -> 'sie' 541 | # Verbs 542 | IV[AGR=[NUM=sg,PER=1]] -> 'komme' 543 | IV[AGR=[NUM=sg,PER=2]] -> 'kommst' 544 | IV[AGR=[NUM=sg,PER=3]] -> 'kommt' 545 | IV[AGR=[NUM=pl, PER=1]] -> 'kommen' 546 | IV[AGR=[NUM=pl, PER=2]] -> 'kommt' 547 | IV[AGR=[NUM=pl, PER=3]] -> 'kommen' 548 | TV[OBJCASE=acc, AGR=[NUM=sg,PER=1]] -> 'sehe' | 'mag' 549 | TV[OBJCASE=acc, AGR=[NUM=sg,PER=2]] -> 'siehst' | 'magst' 550 | TV[OBJCASE=acc, AGR=[NUM=sg,PER=3]] -> 'sieht' | 'mag' 551 | TV[OBJCASE=dat, AGR=[NUM=sg,PER=1]] -> 'folge' | 'helfe' 552 | TV[OBJCASE=dat, AGR=[NUM=sg,PER=2]] -> 'folgst' | 'hilfst' 553 | TV[OBJCASE=dat, AGR=[NUM=sg,PER=3]] -> 'folgt' | 'hilft' 554 | TV[OBJCASE=acc, AGR=[NUM=pl,PER=1]] -> 'sehen' | 'moegen' 555 | TV[OBJCASE=acc, AGR=[NUM=pl,PER=2]] -> 'sieht' | 'moegt' 556 | TV[OBJCASE=acc, AGR=[NUM=pl,PER=3]] -> 'sehen' | 'moegen' 557 | TV[OBJCASE=dat, AGR=[NUM=pl,PER=1]] -> 'folgen' | 'helfen' 558 | TV[OBJCASE=dat, AGR=[NUM=pl,PER=2]] -> 'folgt' | 'helft' 559 | TV[OBJCASE=dat, AGR=[NUM=pl,PER=3]] -> 'folgen' | 'helfen' 560 | ``` 561 | 562 | 正如你可以看到的,特征`objcase`被用来指定动词支配它的对象的格。下一个例子演示了包含支配与格的动词的句子的分析树。 563 | 564 | ```py 565 | >>> tokens = 'ich folge den Katzen'.split() 566 | >>> cp = load_parser('grammars/book_grammars/german.fcfg') 567 | >>> for tree in cp.parse(tokens): 568 | ... print(tree) 569 | (S[] 570 | (NP[AGR=[NUM='sg', PER=1], CASE='nom'] 571 | (PRO[AGR=[NUM='sg', PER=1], CASE='nom'] ich)) 572 | (VP[AGR=[NUM='sg', PER=1]] 573 | (TV[AGR=[NUM='sg', PER=1], OBJCASE='dat'] folge) 574 | (NP[AGR=[GND='fem', NUM='pl', PER=3], CASE='dat'] 575 | (Det[AGR=[NUM='pl', PER=3], CASE='dat'] den) 576 | (N[AGR=[GND='fem', NUM='pl', PER=3]] Katzen)))) 577 | ``` 578 | 579 | 在开发语法时,排除不符合语法的词序列往往与分析符合语法的词序列一样具有挑战性。为了能知道在哪里和为什么序列分析失败,设置`load_parser()`方法的`trace`参数可能是至关重要的。思考下面的分析故障: 580 | 581 | ```py 582 | >>> tokens = 'ich folge den Katze'.split() 583 | >>> cp = load_parser('grammars/book_grammars/german.fcfg', trace=2) 584 | >>> for tree in cp.parse(tokens): 585 | ... print(tree) 586 | |.ich.fol.den.Kat.| 587 | Leaf Init Rule: 588 | |[---] . . .| [0:1] 'ich' 589 | |. [---] . .| [1:2] 'folge' 590 | |. . [---] .| [2:3] 'den' 591 | |. . . [---]| [3:4] 'Katze' 592 | Feature Bottom Up Predict Combine Rule: 593 | |[---] . . .| [0:1] PRO[AGR=[NUM='sg', PER=1], CASE='nom'] 594 | -> 'ich' * 595 | Feature Bottom Up Predict Combine Rule: 596 | |[---] . . .| [0:1] NP[AGR=[NUM='sg', PER=1], CASE='nom'] -> PRO[AGR=[NUM='sg', PER=1], CASE='nom'] * 597 | Feature Bottom Up Predict Combine Rule: 598 | |[---> . . .| [0:1] S[] -> NP[AGR=?a, CASE='nom'] * VP[AGR=?a] {?a: [NUM='sg', PER=1]} 599 | Feature Bottom Up Predict Combine Rule: 600 | |. [---] . .| [1:2] TV[AGR=[NUM='sg', PER=1], OBJCASE='dat'] -> 'folge' * 601 | Feature Bottom Up Predict Combine Rule: 602 | |. [---> . .| [1:2] VP[AGR=?a] -> TV[AGR=?a, OBJCASE=?c] * NP[CASE=?c] {?a: [NUM='sg', PER=1], ?c: 'dat'} 603 | Feature Bottom Up Predict Combine Rule: 604 | |. . [---] .| [2:3] Det[AGR=[GND='masc', NUM='sg', PER=3], CASE='acc'] -> 'den' * 605 | |. . [---] .| [2:3] Det[AGR=[NUM='pl', PER=3], CASE='dat'] -> 'den' * 606 | Feature Bottom Up Predict Combine Rule: 607 | |. . [---> .| [2:3] NP[AGR=?a, CASE=?c] -> Det[AGR=?a, CASE=?c] * N[AGR=?a, CASE=?c] {?a: [NUM='pl', PER=3], ?c: 'dat'} 608 | Feature Bottom Up Predict Combine Rule: 609 | |. . [---> .| [2:3] NP[AGR=?a, CASE=?c] -> Det[AGR=?a, CASE=?c] * N[AGR=?a, CASE=?c] {?a: [GND='masc', NUM='sg', PER=3], ?c: 'acc'} 610 | Feature Bottom Up Predict Combine Rule: 611 | |. . . [---]| [3:4] N[AGR=[GND='fem', NUM='sg', PER=3]] -> 'Katze' * 612 | ``` 613 | 614 | 跟踪中的最后两个`Scanner`行显示`den`被识别为两个可能的类别:`Det[AGR=[GND='masc', NUM='sg', PER=3], CASE='acc']`和`Det[AGR=[NUM='pl', PER=3], CASE='dat']`。我们从 3.2 中的语法知道`Katze`的类别是`N[AGR=[GND=fem, NUM=sg, PER=3]]`。因而,产生式`NP[CASE=?c, AGR=?a] -> Det[CASE=?c, AGR=?a] N[CASE=?c, AGR=?a]`中没有变量`?a`的绑定,这将满足这些限制,因为`Katze`的`AGR`值将不与`den`的任何一个`AGR`值统一,也就是`[GND='masc', NUM='sg', PER=3]`或`[NUM='pl', PER=3]`。 615 | 616 | ## 4 小结 617 | 618 | * 上下文无关语法的传统分类是原子符号。特征结构的一个重要的作用是捕捉精细的区分,否则将需要数量翻倍的原子类别。 619 | * 通过使用特征值上的变量,我们可以表达语法产生式中的限制,允许不同的特征规格的实现可以相互依赖。 620 | * 通常情况下,我们在词汇层面指定固定的特征值,限制短语中的特征值与它们的孩子中的对应值统一。 621 | * 特征值可以是原子的或复杂的。原子值的一个特定类别是布尔值,按照惯例用[+/- `f`]表示。 622 | * 两个特征可以共享一个值(原子的或复杂的)。具有共享值的结构被称为重入。共享的值被表示为 AVM 中的数字索引(或标记)。 623 | * 一个特征结构中的路径是一个特征的元组,对应从图的根开始的弧的序列上的标签。 624 | * 两条路径是等价的,如果它们共享一个值。 625 | * 包含的特征结构是偏序的。`FS[0]`包含`FS[1]`,当包含在`FS[0]`中的所有信息也出现在`FS[1]`中。 626 | * 两种结构`FS[0]`和`FS[1]`的统一,如果成功,就是包含`FS[0]`和`FS[1]`的合并信息的特征结构`FS[2]`。 627 | * 如果统一在 FS 中指定一条路径`π`,那么它也指定等效与`π`的每个路径`π'`。 628 | * 我们可以使用特征结构建立对大量广泛语言学现象的简洁的分析,包括动词子类别,倒装结构,无限制依赖结构和格支配。 629 | 630 | ## 5 深入阅读 631 | 632 | 本章进一步的材料请参考`http://nltk.org/`,包括特征结构、特征语法和语法测试套件。 633 | 634 | X-bar 句法:(Jacobs & Rosenbaum, 1970), (Jackendoff, 1977)(我们使用素数替代了 Chomsky 印刷上要求更高的单杠)。 635 | 636 | 协议现象的一个很好的介绍,请参阅(Corbett, 2006)。 637 | 638 | 理论语言学中最初使用特征的目的是捕捉语音的音素特性。例如,音`/b/`可能会被分解成结构`[+labial, +voice]`。一个重要的动机是捕捉分割的类别之间的一般性;例如`/n/`在任一`+labial`辅音前面被读作`/m/`。在乔姆斯基语法中,对一些现象,如协议,使用原子特征是很标准的,原子特征也用来捕捉跨句法类别的概括,通过类比与音韵。句法理论中使用特征的一个激进的扩展是广义短语结构语法(GPSG; (Gazdar, Klein, & and, 1985)),特别是在使用带有复杂值的特征。 639 | 640 | 从计算语言学的角度来看,(Dahl & Saint-Dizier, 1985)提出语言的功能方面可以被属性-值结构的统一捕获,一个类似的方法由(Grosz & Stickel, 1983)在 PATR-II 形式体系中精心设计完成。词汇功能语法(LFG; (Bresnan, 1982))的早期工作介绍了 F 结构的概念,它的主要目的是表示语法关系和与成分结构短语关联的谓词参数结构。(Shieber, 1986)提供了研究基于特征语法方面的一个极好的介绍。 641 | 642 | 当研究人员试图为反面例子建模时,特征结构的代数方法的一个概念上的困难出现了。另一种观点,由(Kasper & Rounds, 1986)和(Johnson, 1988)开创,认为语法涉及结构功能的描述而不是结构本身。这些描述使用逻辑操作如合取相结合,而否定仅仅是特征描述上的普通的逻辑运算。这种面向描述的观点对 LFG 从一开始就是不可或缺的(参见(Huang & Chen, 1989)),也被中心词驱动短语结构语法的较高版本采用(HPSG; (Sag & Wasow, 1999))。`http://www.cl.uni-bremen.de/HPSG-Bib/`上有 HPSG 文献的全面的参考书目。 643 | 644 | 本章介绍的特征结构无法捕捉语言信息中重要的限制。例如,有没有办法表达`NUM`的值只允许是`sg`和`pl`,而指定`[NUM=masc]`是反常的。同样地,我们不能说`AGR`的复合值必须包含特征`PER`,`NUM`和`gnd`的指定,但不能包含如`[SUBCAT=trans]`这样的指定。指定类型的特征结构被开发出来弥补这方面的不足。开始,我们规定总是键入特征值。对于原子值,值就是类型。例如,我们可以说`NUM`的值是类型`num`。此外,`num`是`NUM`最一般类型的值。由于类型按层次结构组织,通过指定`NUM`的值为`num`的子类型,即要么是`sg`要么是`pl`,我们可以更富含信息。 645 | 646 | In the case of complex values, we say that feature structures are themselves typed. So for example the value of `AGR` will be a feature structure of type `AGR`. We also stipulate that all and only `PER`, `NUM` and `GND` are appropriate features for a structure of type `AGR`. 一个早期的关于指定类型的特征结构的很好的总结是(Emele & Zajac, 1990)。一个形式化基础的更全面的检查可以在(Carpenter, 1992)中找到,(Copestake, 2002)重点关注为面向 HPSG 的方法实现指定类型的特征结构。 647 | 648 | 有很多著作是关于德语的基于特征语法框架上的分析的。(Nerbonne, Netter, & Pollard, 1994)是这个主题的 HPSG 著作的一个好的起点,而(Muller, 2002)给出 HPSG 中的德语句法非常广泛和详细的分析。 649 | 650 | (Jurafsky & Martin, 2008)的第 15 章讨论了特征结构、统一的算法和将统一整合到分析算法中。 651 | 652 | ## 6 练习 653 | 654 | 1. ☼ 需要什么样的限制才能正确分析词序列,如`I am happy`和`she is happy`而不是`you is happy`或`they am happy`?实现英语中动词`be`的现在时态范例的两个解决方案,首先以语法`(6)`作为起点,然后以语法 `(18)`为起点。 655 | 656 | 2. ☼ 开发 1.1 中语法的变体,使用特征`count`来区分下面显示的句子: 657 | 658 | ```py 659 | fs1 = nltk.FeatStruct("[A = ?x, B= [C = ?x]]") 660 | fs2 = nltk.FeatStruct("[B = [D = d]]") 661 | fs3 = nltk.FeatStruct("[B = [C = d]]") 662 | fs4 = nltk.FeatStruct("[A = (1)[B = b], C->(1)]") 663 | fs5 = nltk.FeatStruct("[A = (1)[D = ?x], C = [E -> (1), F = ?x] ]") 664 | fs6 = nltk.FeatStruct("[A = [D = d]]") 665 | fs7 = nltk.FeatStruct("[A = [D = d], C = [F = [D = d]]]") 666 | fs8 = nltk.FeatStruct("[A = (1)[D = ?x, G = ?x], C = [B = ?x, E -> (1)] ]") 667 | fs9 = nltk.FeatStruct("[A = [B = b], C = [E = [G = e]]]") 668 | fs10 = nltk.FeatStruct("[A = (1)[B = b], C -> (1)]") 669 | ``` 670 | 671 | 在纸上计算下面的统一的结果是什么。(提示:你可能会发现绘制图结构很有用。) 672 | 673 | 1. `fs1` and `fs2` 674 | 2. `fs1` and `fs3` 675 | 3. `fs4` and `fs5` 676 | 4. `fs5` and `fs6` 677 | 5. `fs5` and `fs7` 678 | 6. `fs8` and `fs9` 679 | 7. `fs8` and `fs10` 680 | 681 | 用 Python 检查你的答案。 682 | 683 | 3. ◑ 列出两个包含`[A=?x, B=?x]`的特征结构。 684 | 685 | 4. ◑ 忽略结构共享,给出一个统一两个特征结构的非正式算法。 686 | 687 | 5. ◑ 扩展 3.2 中的德语语法,使它能处理所谓的动词第二顺位结构,如下所示: 688 | 689 | `Heute sieht der Hund die Katze. (58)` 690 | 691 | 6. ◑ 同义动词的句法属性看上去略有不同(Levin, 1993)。思考下面的动词`loaded`、`filled`和`dumped`的语法模式。你能写语法产生式处理这些数据吗? 692 | 693 | ```py 694 | 695 | (59) 696 | 697 | a. The farmer *loaded* the cart with sand 698 | 699 | b. The farmer *loaded* sand into the cart 700 | 701 | c. The farmer *filled* the cart with sand 702 | 703 | d. *The farmer *filled* sand into the cart 704 | 705 | e. *The farmer *dumped* the cart with sand 706 | 707 | f. The farmer *dumped* sand into the cart 708 | ``` 709 | 710 | 7. ★ 形态范例很少是完全正规的,矩阵中的每个单元的意义有不同的实现。例如,词位`walk`的现在时态词性变化只有两种不同形式:第三人称单数的`walks`和所有其他人称和数量的组合的`walk`。一个成功的分析不应该额外要求 6 个可能的形态组合中有 5 个有相同的实现。设计和实施一个方法处理这个问题。 711 | 712 | 8. ★ 所谓的核心特征在父节点和核心孩子节点之间共享。例如,`TENSE`是核心特征,在一个`VP`和它的核心孩子`V`之间共享。更多细节见(Gazdar, Klein, & and, 1985)。我们看到的结构中大部分是核心结构——除了`SUBCAT`和`SLASH`。由于核心特征的共享是可以预见的,它不需要在语法产生式中明确表示。开发一种方法自动计算核心结构的这种规则行为的比重。 713 | 714 | 9. ★ 扩展 NLTK 中特征结构的处理,允许统一值为列表的特征,使用这个来实现一个 HPSG 风格的子类别分析,核心类别的`SUBCAT`是它的补语的类别和它直接父母的`SUBCAT`值的连结。 715 | 716 | 10. ★ 扩展 NLTK 的特征结构处理,允许带未指定类别的产生式,例如`S[-INV] --> ?x S/?x`。 717 | 718 | 11. ★ 扩展 NLTK 的特征结构处理,允许指定类型的特征结构。 719 | 720 | 12. ★ 挑选一些(Huddleston & Pullum, 2002)中描述的文法结构,建立一个基于特征的语法计算它们的比例。 721 | 722 | ## 关于本文档... 723 | 724 | 针对 NLTK 3.0 进行更新。本章来自于《Python 自然语言处理》,[Steven Bird](http://estive.net/), [Ewan Klein](http://homepages.inf.ed.ac.uk/ewan/) 和 [Edward Loper](http://ed.loper.org/),Copyright © 2014 作者所有。本章依据 [*Creative Commons Attribution-Noncommercial-No Derivative Works 3\.0 United States License*](http://creativecommons.org/licenses/by-nc-nd/3.0/us/) 条款,与[*自然语言工具包*](http://nltk.org/) 3.0 版一起发行。 725 | 726 | 本文档构建于星期三 2015 年 7 月 1 日 12:30:05 AEST -------------------------------------------------------------------------------- /docs/Images/05c7618d4554f83cfa6105c528703794.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/05c7618d4554f83cfa6105c528703794.jpg -------------------------------------------------------------------------------- /docs/Images/07e7d99633e4a107388f7202380cce55.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/07e7d99633e4a107388f7202380cce55.jpg -------------------------------------------------------------------------------- /docs/Images/0ddbd56a410c886c77d1c72a84e27883.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/0ddbd56a410c886c77d1c72a84e27883.jpg -------------------------------------------------------------------------------- /docs/Images/0de8ea07b37cc379da8aeb4a0c9fd5bf.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/0de8ea07b37cc379da8aeb4a0c9fd5bf.jpg -------------------------------------------------------------------------------- /docs/Images/0e6e187e03f69a6548e7daa4f95e1548.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/0e6e187e03f69a6548e7daa4f95e1548.jpg -------------------------------------------------------------------------------- /docs/Images/0e768e8c4378c2b0b3290aab46dc770e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/0e768e8c4378c2b0b3290aab46dc770e.jpg -------------------------------------------------------------------------------- /docs/Images/0f4441cdaf35bfa4d58fc64142cf4736.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/0f4441cdaf35bfa4d58fc64142cf4736.jpg -------------------------------------------------------------------------------- /docs/Images/102675fd70e434164536c75bf7f8f043.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/102675fd70e434164536c75bf7f8f043.jpg -------------------------------------------------------------------------------- /docs/Images/1094084b61ac3f0e4416e92869c52ccd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/1094084b61ac3f0e4416e92869c52ccd.jpg -------------------------------------------------------------------------------- /docs/Images/10a8a58e33a0a6b7fb71389ea2114566.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/10a8a58e33a0a6b7fb71389ea2114566.jpg -------------------------------------------------------------------------------- /docs/Images/10a910dd6de117ab7a0ab352519f7297.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/10a910dd6de117ab7a0ab352519f7297.jpg -------------------------------------------------------------------------------- /docs/Images/12573c3a9015654728fe798e170a3c50.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/12573c3a9015654728fe798e170a3c50.jpg -------------------------------------------------------------------------------- /docs/Images/13361de430cd983e689417c547330bbc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/13361de430cd983e689417c547330bbc.jpg -------------------------------------------------------------------------------- /docs/Images/13f25b9eba42f74ad969a74cee78551e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/13f25b9eba42f74ad969a74cee78551e.jpg -------------------------------------------------------------------------------- /docs/Images/14a0a2692f06286091f0cca17de5c0f3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/14a0a2692f06286091f0cca17de5c0f3.jpg -------------------------------------------------------------------------------- /docs/Images/14a15b73cb826ac3464754d6db3e9e54.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/14a15b73cb826ac3464754d6db3e9e54.jpg -------------------------------------------------------------------------------- /docs/Images/160f0b5ad0e4b8745b925d63377a69ba.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/160f0b5ad0e4b8745b925d63377a69ba.jpg -------------------------------------------------------------------------------- /docs/Images/17af2b7a4de652abd5c2c71a94cc1c7b.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/17af2b7a4de652abd5c2c71a94cc1c7b.jpg -------------------------------------------------------------------------------- /docs/Images/1ab45939cc9babb242ac45ed03a94f7a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/1ab45939cc9babb242ac45ed03a94f7a.jpg -------------------------------------------------------------------------------- /docs/Images/1b33abb14fc8fe7c704d005736ddb323.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/1b33abb14fc8fe7c704d005736ddb323.jpg -------------------------------------------------------------------------------- /docs/Images/1c54b3124863d24d17b2edec4f1d47e5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/1c54b3124863d24d17b2edec4f1d47e5.jpg -------------------------------------------------------------------------------- /docs/Images/1cf5b2605018e587fa94db2ac671e930.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/1cf5b2605018e587fa94db2ac671e930.jpg -------------------------------------------------------------------------------- /docs/Images/21f757d2c1451cb55bc923dcb4d8d1ab.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/21f757d2c1451cb55bc923dcb4d8d1ab.jpg -------------------------------------------------------------------------------- /docs/Images/24589c2eb435b25724aed562d1d47617.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/24589c2eb435b25724aed562d1d47617.jpg -------------------------------------------------------------------------------- /docs/Images/273b9ed1ea067e4503c00dbd193216e8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/273b9ed1ea067e4503c00dbd193216e8.jpg -------------------------------------------------------------------------------- /docs/Images/27ffeabf8327e1810d6ac35642a72700.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/27ffeabf8327e1810d6ac35642a72700.jpg -------------------------------------------------------------------------------- /docs/Images/2ce816f11fd01927802253d100780b0a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/2ce816f11fd01927802253d100780b0a.jpg -------------------------------------------------------------------------------- /docs/Images/2cfe7a0ac0b6007d979cf3aecda8a9f5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/2cfe7a0ac0b6007d979cf3aecda8a9f5.jpg -------------------------------------------------------------------------------- /docs/Images/334be383b5db7ffe3599cc03bc74bf9e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/334be383b5db7ffe3599cc03bc74bf9e.jpg -------------------------------------------------------------------------------- /docs/Images/346344c2e5a627acfdddf948fb69cb1d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/346344c2e5a627acfdddf948fb69cb1d.jpg -------------------------------------------------------------------------------- /docs/Images/37edef9faf625ac06477a0ab0118afca.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/37edef9faf625ac06477a0ab0118afca.jpg -------------------------------------------------------------------------------- /docs/Images/3a93e0258a010fdda935b4ee067411a5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/3a93e0258a010fdda935b4ee067411a5.jpg -------------------------------------------------------------------------------- /docs/Images/3edaf7564caaab7c8ddc83db1d5408a3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/3edaf7564caaab7c8ddc83db1d5408a3.jpg -------------------------------------------------------------------------------- /docs/Images/4150e51ab7e511f8d4f72293054ceb22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/4150e51ab7e511f8d4f72293054ceb22.jpg -------------------------------------------------------------------------------- /docs/Images/431fed60785d71efd9010589288ca55d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/431fed60785d71efd9010589288ca55d.jpg -------------------------------------------------------------------------------- /docs/Images/43a0f901bdd8f343b2885d2b2e95b996.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/43a0f901bdd8f343b2885d2b2e95b996.jpg -------------------------------------------------------------------------------- /docs/Images/484180fc6abc244116b30e57cb6c0cf5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/484180fc6abc244116b30e57cb6c0cf5.jpg -------------------------------------------------------------------------------- /docs/Images/496754d8cdb6262f8f72e1f066bab359.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/496754d8cdb6262f8f72e1f066bab359.jpg -------------------------------------------------------------------------------- /docs/Images/499f8953a7d39c034e6840bdacd99d08.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/499f8953a7d39c034e6840bdacd99d08.jpg -------------------------------------------------------------------------------- /docs/Images/4a87f1dccc0e18aab5ec599d8d8358d6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/4a87f1dccc0e18aab5ec599d8d8358d6.jpg -------------------------------------------------------------------------------- /docs/Images/4acbae4abe459cf45122fe134ff7672d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/4acbae4abe459cf45122fe134ff7672d.jpg -------------------------------------------------------------------------------- /docs/Images/4b32a28b1aab7148420347abc990ee67.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/4b32a28b1aab7148420347abc990ee67.jpg -------------------------------------------------------------------------------- /docs/Images/4b5cae275c53c53ccc8f2f779acada3e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/4b5cae275c53c53ccc8f2f779acada3e.jpg -------------------------------------------------------------------------------- /docs/Images/4cdc400cf76b0354304e01aeb894877b.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/4cdc400cf76b0354304e01aeb894877b.jpg -------------------------------------------------------------------------------- /docs/Images/4cec5bd698a48f7e083696dd51ae9e7a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/4cec5bd698a48f7e083696dd51ae9e7a.jpg -------------------------------------------------------------------------------- /docs/Images/513df73dfd52feca2c96a86dcc261c8b.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/513df73dfd52feca2c96a86dcc261c8b.jpg -------------------------------------------------------------------------------- /docs/Images/532d5f3185ea7edaec68683d89a74182.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/532d5f3185ea7edaec68683d89a74182.jpg -------------------------------------------------------------------------------- /docs/Images/542fee25c56235c899312bed3d5ee9ba.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/542fee25c56235c899312bed3d5ee9ba.jpg -------------------------------------------------------------------------------- /docs/Images/55f4da85888c6e9974fea5360283035a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/55f4da85888c6e9974fea5360283035a.jpg -------------------------------------------------------------------------------- /docs/Images/56cee123595482cf3edaef089cb9a6a7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/56cee123595482cf3edaef089cb9a6a7.jpg -------------------------------------------------------------------------------- /docs/Images/5741a8d50a63172cbd2c825cda1b61d5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/5741a8d50a63172cbd2c825cda1b61d5.jpg -------------------------------------------------------------------------------- /docs/Images/58a1097522dc6fbe24eddd96cfd6cbc9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/58a1097522dc6fbe24eddd96cfd6cbc9.jpg -------------------------------------------------------------------------------- /docs/Images/5ac0acc015eeb4b0a40c6c23b7f95395.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/5ac0acc015eeb4b0a40c6c23b7f95395.jpg -------------------------------------------------------------------------------- /docs/Images/5c0c6dc75f29f253edaecb566d608aa3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/5c0c6dc75f29f253edaecb566d608aa3.jpg -------------------------------------------------------------------------------- /docs/Images/5c3caa46daa29a053a04713bab6e4f03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/5c3caa46daa29a053a04713bab6e4f03.jpg -------------------------------------------------------------------------------- /docs/Images/5e197b7d253f66454a97af2a93c30a8e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/5e197b7d253f66454a97af2a93c30a8e.jpg -------------------------------------------------------------------------------- /docs/Images/5eeb4cf55b6d18d4bcb098fc72ddc6d7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/5eeb4cf55b6d18d4bcb098fc72ddc6d7.jpg -------------------------------------------------------------------------------- /docs/Images/6372ba4f28e69f0b220c75a9b2f4decf.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/6372ba4f28e69f0b220c75a9b2f4decf.jpg -------------------------------------------------------------------------------- /docs/Images/63a8e4c47e813ba9630363f9b203a19a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/63a8e4c47e813ba9630363f9b203a19a.jpg -------------------------------------------------------------------------------- /docs/Images/64864d38550248d5bd9b82eeb6f0583b.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/64864d38550248d5bd9b82eeb6f0583b.jpg -------------------------------------------------------------------------------- /docs/Images/66d94cb86ab90a95cfe745d9613c37b1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/66d94cb86ab90a95cfe745d9613c37b1.jpg -------------------------------------------------------------------------------- /docs/Images/67abca0731a79d664847dee1390f2e13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/67abca0731a79d664847dee1390f2e13.jpg -------------------------------------------------------------------------------- /docs/Images/6ac827d2d00b6ebf8bbc704f430af896.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/6ac827d2d00b6ebf8bbc704f430af896.jpg -------------------------------------------------------------------------------- /docs/Images/6ddd472200240ea6c0cab35349a8403e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/6ddd472200240ea6c0cab35349a8403e.jpg -------------------------------------------------------------------------------- /docs/Images/6efeadf518b11a6441906b93844c2b19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/6efeadf518b11a6441906b93844c2b19.jpg -------------------------------------------------------------------------------- /docs/Images/723ad3b660335fc3b79e7bd2c947b195.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/723ad3b660335fc3b79e7bd2c947b195.jpg -------------------------------------------------------------------------------- /docs/Images/74248e04835acdba414fd407bb4f3241.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/74248e04835acdba414fd407bb4f3241.jpg -------------------------------------------------------------------------------- /docs/Images/77460905bcad52d84e324fc4821ed903.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/77460905bcad52d84e324fc4821ed903.jpg -------------------------------------------------------------------------------- /docs/Images/78213332718eae7fffd6314dae12484e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/78213332718eae7fffd6314dae12484e.jpg -------------------------------------------------------------------------------- /docs/Images/78bc6ca8410394dcf6910484bc97e2b6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/78bc6ca8410394dcf6910484bc97e2b6.jpg -------------------------------------------------------------------------------- /docs/Images/7a979f968bd33428b02cde62eaf2b615.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/7a979f968bd33428b02cde62eaf2b615.jpg -------------------------------------------------------------------------------- /docs/Images/7aee076ae156921aba96ac5d4f9ed419.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/7aee076ae156921aba96ac5d4f9ed419.jpg -------------------------------------------------------------------------------- /docs/Images/7bbd845f6f0cf6246561d2859cbcecbf.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/7bbd845f6f0cf6246561d2859cbcecbf.jpg -------------------------------------------------------------------------------- /docs/Images/7c20d0adbadb35031a28bfcd6dff9900.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/7c20d0adbadb35031a28bfcd6dff9900.jpg -------------------------------------------------------------------------------- /docs/Images/7e6ea96aad77f3e523494b3972b5a989.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/7e6ea96aad77f3e523494b3972b5a989.jpg -------------------------------------------------------------------------------- /docs/Images/7f27bfe5324e4d9573ddd210531a8126.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/7f27bfe5324e4d9573ddd210531a8126.jpg -------------------------------------------------------------------------------- /docs/Images/7f97e7ac70a7c865fb1020795f6e7236.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/7f97e7ac70a7c865fb1020795f6e7236.jpg -------------------------------------------------------------------------------- /docs/Images/81e6b07f4541d7d5a7900508d11172bd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/81e6b07f4541d7d5a7900508d11172bd.jpg -------------------------------------------------------------------------------- /docs/Images/82ddd91230422f3ba446f46ca73ff663.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/82ddd91230422f3ba446f46ca73ff663.jpg -------------------------------------------------------------------------------- /docs/Images/84419adac7940aeb3026bc0a8b3e5fb4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/84419adac7940aeb3026bc0a8b3e5fb4.jpg -------------------------------------------------------------------------------- /docs/Images/854532b0c5c8869f9012833955e75b20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/854532b0c5c8869f9012833955e75b20.jpg -------------------------------------------------------------------------------- /docs/Images/86cecc4bd139ddaf1a5daf9991f39945.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/86cecc4bd139ddaf1a5daf9991f39945.jpg -------------------------------------------------------------------------------- /docs/Images/89747cee31bc672bfbbb6891a9099a25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/89747cee31bc672bfbbb6891a9099a25.jpg -------------------------------------------------------------------------------- /docs/Images/8b4bb6b0ec5bb337fdb00c31efcc1645.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/8b4bb6b0ec5bb337fdb00c31efcc1645.jpg -------------------------------------------------------------------------------- /docs/Images/8bfa073b3f3753285055c1e3ef689826.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/8bfa073b3f3753285055c1e3ef689826.jpg -------------------------------------------------------------------------------- /docs/Images/8c5ec1a0132f7c85fd96eda9d9929d15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/8c5ec1a0132f7c85fd96eda9d9929d15.jpg -------------------------------------------------------------------------------- /docs/Images/8cb61a943f3d34f94596e77065410cd3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/8cb61a943f3d34f94596e77065410cd3.jpg -------------------------------------------------------------------------------- /docs/Images/910abba27da60798441e98902cce64ca.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/910abba27da60798441e98902cce64ca.jpg -------------------------------------------------------------------------------- /docs/Images/92cc2e7821d464cfbaaf651a360cd413.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/92cc2e7821d464cfbaaf651a360cd413.jpg -------------------------------------------------------------------------------- /docs/Images/934b688727805b37f2404f7497c52027.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/934b688727805b37f2404f7497c52027.jpg -------------------------------------------------------------------------------- /docs/Images/953f4a408c97594449de5ca84c294719.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/953f4a408c97594449de5ca84c294719.jpg -------------------------------------------------------------------------------- /docs/Images/96fd8d34602a08c09a19f5b2c5c19380.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/96fd8d34602a08c09a19f5b2c5c19380.jpg -------------------------------------------------------------------------------- /docs/Images/99dbcae75bd96499dce3b3671032a106.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/99dbcae75bd96499dce3b3671032a106.jpg -------------------------------------------------------------------------------- /docs/Images/9ea1d0111a40bd865c651712f276bc31.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/9ea1d0111a40bd865c651712f276bc31.jpg -------------------------------------------------------------------------------- /docs/Images/a538227535079e1fa1e906af90af28eb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/a538227535079e1fa1e906af90af28eb.jpg -------------------------------------------------------------------------------- /docs/Images/aa68e0e8f4d58caa31e5542dabe4ddc2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/aa68e0e8f4d58caa31e5542dabe4ddc2.jpg -------------------------------------------------------------------------------- /docs/Images/ab3d4c917ad3461f18759719a288afa5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/ab3d4c917ad3461f18759719a288afa5.jpg -------------------------------------------------------------------------------- /docs/Images/b1aad2b60635723f14976fb5cb9ca372.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/b1aad2b60635723f14976fb5cb9ca372.jpg -------------------------------------------------------------------------------- /docs/Images/b2af1426c6cd2403c8b938eb557a99d1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/b2af1426c6cd2403c8b938eb557a99d1.jpg -------------------------------------------------------------------------------- /docs/Images/b502c97e1f935240559d38b397805b32.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/b502c97e1f935240559d38b397805b32.jpg -------------------------------------------------------------------------------- /docs/Images/bc7e6aa002dd5ced295ba1de2ebbbf61.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/bc7e6aa002dd5ced295ba1de2ebbbf61.jpg -------------------------------------------------------------------------------- /docs/Images/bcf758e8278f3295df58c6eace05152c.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/bcf758e8278f3295df58c6eace05152c.jpg -------------------------------------------------------------------------------- /docs/Images/be33958d0b44c88caac0dcf4d4ec84c6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/be33958d0b44c88caac0dcf4d4ec84c6.jpg -------------------------------------------------------------------------------- /docs/Images/bf2a88150e1927f2e52d745ab6cae7ce.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/bf2a88150e1927f2e52d745ab6cae7ce.jpg -------------------------------------------------------------------------------- /docs/Images/bfd8f5fc51eb8848dfb986c7937ded23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/bfd8f5fc51eb8848dfb986c7937ded23.jpg -------------------------------------------------------------------------------- /docs/Images/c28c02e5c661caa578acaea0fa9e9dd2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/c28c02e5c661caa578acaea0fa9e9dd2.jpg -------------------------------------------------------------------------------- /docs/Images/c370689374c63baf915c9e44c4b270d4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/c370689374c63baf915c9e44c4b270d4.jpg -------------------------------------------------------------------------------- /docs/Images/ca21bcde8ab16a341929b7fb9ccb0a0e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/ca21bcde8ab16a341929b7fb9ccb0a0e.jpg -------------------------------------------------------------------------------- /docs/Images/ced4e829d6a662a2be20187f9d7b71b5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/ced4e829d6a662a2be20187f9d7b71b5.jpg -------------------------------------------------------------------------------- /docs/Images/cf5ffc116dbddb4a34c65925b0d558cb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/cf5ffc116dbddb4a34c65925b0d558cb.jpg -------------------------------------------------------------------------------- /docs/Images/d167c4075a237573a350e298a184d4fb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/d167c4075a237573a350e298a184d4fb.jpg -------------------------------------------------------------------------------- /docs/Images/d2c5cc51cd61a6915f24d0c52eaab9c5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/d2c5cc51cd61a6915f24d0c52eaab9c5.jpg -------------------------------------------------------------------------------- /docs/Images/d315c52900de61a078cd8391c1a1c604.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/d315c52900de61a078cd8391c1a1c604.jpg -------------------------------------------------------------------------------- /docs/Images/d3541d4caaf5c92d8ab496ccd7ee9a2d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/d3541d4caaf5c92d8ab496ccd7ee9a2d.jpg -------------------------------------------------------------------------------- /docs/Images/d41ca3c99b067df414f6ed0847a641ca.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/d41ca3c99b067df414f6ed0847a641ca.jpg -------------------------------------------------------------------------------- /docs/Images/d46d7efa5d57b31c68c4ddddd464d6c0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/d46d7efa5d57b31c68c4ddddd464d6c0.jpg -------------------------------------------------------------------------------- /docs/Images/d87676460c87d0516fb382b929c07302.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/d87676460c87d0516fb382b929c07302.jpg -------------------------------------------------------------------------------- /docs/Images/da1752497a2a17be12b2acb282918a7a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/da1752497a2a17be12b2acb282918a7a.jpg -------------------------------------------------------------------------------- /docs/Images/da516572f97daebe1be746abd7bd2268.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/da516572f97daebe1be746abd7bd2268.jpg -------------------------------------------------------------------------------- /docs/Images/daf7c1761ffc1edbb39e6ca11863854f.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/daf7c1761ffc1edbb39e6ca11863854f.jpg -------------------------------------------------------------------------------- /docs/Images/de0715649664a49a5ab2e2b61ae2675a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/de0715649664a49a5ab2e2b61ae2675a.jpg -------------------------------------------------------------------------------- /docs/Images/df98e5a4903ccc7253cc7cc6ebda4fea.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/df98e5a4903ccc7253cc7cc6ebda4fea.jpg -------------------------------------------------------------------------------- /docs/Images/e04c36ac970436161b45be660ea3a7d2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/e04c36ac970436161b45be660ea3a7d2.jpg -------------------------------------------------------------------------------- /docs/Images/e104303155c3fbb0742ea67a0560ab7f.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/e104303155c3fbb0742ea67a0560ab7f.jpg -------------------------------------------------------------------------------- /docs/Images/e112e308d5c3454875146f40e4b48f3f.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/e112e308d5c3454875146f40e4b48f3f.jpg -------------------------------------------------------------------------------- /docs/Images/e24d03f1dec3f8a75e8042579446a47e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/e24d03f1dec3f8a75e8042579446a47e.jpg -------------------------------------------------------------------------------- /docs/Images/e33fb540f11c5ea9a07441be8a407d43.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/e33fb540f11c5ea9a07441be8a407d43.jpg -------------------------------------------------------------------------------- /docs/Images/e372da3dc801bc1211a47d2e82840b64.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/e372da3dc801bc1211a47d2e82840b64.jpg -------------------------------------------------------------------------------- /docs/Images/e591e60c490795add5183c998132ebc0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/e591e60c490795add5183c998132ebc0.jpg -------------------------------------------------------------------------------- /docs/Images/e5fb07e997b9718f18dbf677e3d6634d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/e5fb07e997b9718f18dbf677e3d6634d.jpg -------------------------------------------------------------------------------- /docs/Images/e685801a8cec4515b47e1bda95deb59d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/e685801a8cec4515b47e1bda95deb59d.jpg -------------------------------------------------------------------------------- /docs/Images/e941b64ed778967dd0170d25492e42df.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/e941b64ed778967dd0170d25492e42df.jpg -------------------------------------------------------------------------------- /docs/Images/e9d9a0887996a6bac6c52bb0bfaf9fdf.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/e9d9a0887996a6bac6c52bb0bfaf9fdf.jpg -------------------------------------------------------------------------------- /docs/Images/ea84debad296c6385399fb2252fc93f1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/ea84debad296c6385399fb2252fc93f1.jpg -------------------------------------------------------------------------------- /docs/Images/eb630c6034e9ed7274ef2e04b9694347.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/eb630c6034e9ed7274ef2e04b9694347.jpg -------------------------------------------------------------------------------- /docs/Images/edd1b5af9dcd26541183ce4d6a634e54.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/edd1b5af9dcd26541183ce4d6a634e54.jpg -------------------------------------------------------------------------------- /docs/Images/eeff7ed83be48bf40aeeb3bf9db5550e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/eeff7ed83be48bf40aeeb3bf9db5550e.jpg -------------------------------------------------------------------------------- /docs/Images/ef661b5a01845fe5440027afca461925.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/ef661b5a01845fe5440027afca461925.jpg -------------------------------------------------------------------------------- /docs/Images/f093aaace735b4961dbf9fa7d5c8ca37.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/f093aaace735b4961dbf9fa7d5c8ca37.jpg -------------------------------------------------------------------------------- /docs/Images/f202bb6a4c773430e3d1340de573d0e5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/f202bb6a4c773430e3d1340de573d0e5.jpg -------------------------------------------------------------------------------- /docs/Images/f3ad266a67457b4615141d6ba83e724e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/f3ad266a67457b4615141d6ba83e724e.jpg -------------------------------------------------------------------------------- /docs/Images/f4891d12ae20c39b685951ad3cddf1aa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/f4891d12ae20c39b685951ad3cddf1aa.jpg -------------------------------------------------------------------------------- /docs/Images/f9e1ba3246770e3ecb24f813f33f2075.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/f9e1ba3246770e3ecb24f813f33f2075.jpg -------------------------------------------------------------------------------- /docs/Images/fb1a02fe3607a0deb452086296fd6f69.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/fb1a02fe3607a0deb452086296fd6f69.jpg -------------------------------------------------------------------------------- /docs/Images/ff868af58b8c1843c38287717b137f7c.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/ff868af58b8c1843c38287717b137f7c.jpg -------------------------------------------------------------------------------- /docs/Images/ffa808c97c7034af1bc2806ed7224203.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/ffa808c97c7034af1bc2806ed7224203.jpg -------------------------------------------------------------------------------- /docs/Images/fff90c564d2625f739b442b23301906e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apachecn/nlp-py-2e-zh/2a65e14e495506684017a310961d186cf5d3e818/docs/Images/fff90c564d2625f739b442b23301906e.jpg -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
now loading...
21 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | git add -A 2 | git commit -am "$(date "+%Y-%m-%d %H:%M:%S")" 3 | git push --------------------------------------------------------------------------------