Name | headline-style JSON |
Version |
1.5.7
JSON |
| download |
home_page | https://github.com/vinodbaste/python_headline_style |
Summary | About This filter changes a given text to Title Caps, and attempts to be clever about SMALL words like a/an/the in the input. The list of SMALL words which are not capped comes from the New York Times Manual of Style, plus some others like 'vs' and 'v'. |
upload_time | 2023-01-21 12:28:11 |
maintainer | |
docs_url | None |
author | Vinod Baste |
requires_python | >=3.7 |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
This filter changes a given text to Title Caps, and attempts to be clever
about SMALL words like a/an/the in the input.
The list of "SMALL words" which are not capped comes from the New York
Times Manual of Style, plus some others like 'vs' and 'v'.
The filter employs some heuristics to guess abbreviations that don't need conversion.
>>> Example
... 'this is a text' is converted to 'This Is The Text'.
More examples and expected behavior for corner cases are available in the package test suite.
Issues, updates, pull requests, etc should be directed to github.
Installation
------------
The easiest method is to simply use pip:
(sudo) pip install headline_style
Usage
-----
headline_style provides only one function, simply:
>>> from headLineStyle import headLineStyle
>>> headLineStyle('a thing')
'A Thing'
A callback function may also be supplied, which will be called for every word:
>>> def abbreviations(word, **kwargs):
... if word.upper() in ('TCP', 'UDP'):
... return word.upper()
...
>>> headLineStyle.headLineStyle('a simple tcp and udp wrapper', callback=abbreviations)
'A Simple TCP and UDP Wrapper'
The callback function is supplied with an ``all_caps`` keyword argument, indicating
whether the entire line of text was entirely capitalized. Returning ``None`` from
the callback function will allow headLineStyle to process the word as normal.
Command Line Usage
------------------
headLineStyle also provides a command line utility ``headLineStyle``:
>>> $ headLineStyle make me a title
... Make Me a Title
... $ echo "Can pipe and/or whatever else" | headLineStyle
... Can Pipe and/or Whatever Else
... # Or read/write files:
... $ headLineStyle -f infile -o outfile
In addition, commonly used acronyms can be kept in a local file
at `~/.headLineStyle.txt`. This file contains one acronym per line.
The acronym will be maintained in the title as it is provided.
Once there is e.g. one line saying `TCP`, then it will be automatically
used when used from the command line.
>>> $ headLineStyle I LOVE TCP
>>> I Love TCP
Limitations
-----------
This is a best-effort library that uses regexes to try to do intelligent
things, but will have limitations. For example, it does not have the contextual
awareness to distinguish acronyms from words: us (we) versus US (United States).
The regexes and titlecasing rules were written for American English. While
there is basic support for Unicode characters, such that something like
"El NiƱo" will work, it is likely that accents or non-English phrases will
not be handled correctly.
If anyone has concrete solutions to improve these or other shortcomings of the
library, pull requests are very welcome!
# License
-----------
Copyright [2022] [Vinod Baste]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Raw data
{
"_id": null,
"home_page": "https://github.com/vinodbaste/python_headline_style",
"name": "headline-style",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "Vinod Baste",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/3c/5c/2576c3b4f7836e2946d3854c3a5870320be5caee5942e01fb3c9b5836fab/headline_style-1.5.7.tar.gz",
"platform": null,
"description": "\r\nThis filter changes a given text to Title Caps, and attempts to be clever\r\nabout SMALL words like a/an/the in the input.\r\nThe list of \"SMALL words\" which are not capped comes from the New York\r\nTimes Manual of Style, plus some others like 'vs' and 'v'.\r\n\r\nThe filter employs some heuristics to guess abbreviations that don't need conversion.\r\n\r\n>>> Example\r\n... 'this is a text' is converted to 'This Is The Text'.\r\n\r\nMore examples and expected behavior for corner cases are available in the package test suite.\r\n\r\nIssues, updates, pull requests, etc should be directed to github.\r\n\r\nInstallation\r\n------------\r\n\r\nThe easiest method is to simply use pip:\r\n\r\n (sudo) pip install headline_style\r\n\r\n\r\nUsage\r\n-----\r\n\r\nheadline_style provides only one function, simply:\r\n\r\n >>> from headLineStyle import headLineStyle\r\n >>> headLineStyle('a thing')\r\n 'A Thing'\r\n\r\nA callback function may also be supplied, which will be called for every word:\r\n\r\n >>> def abbreviations(word, **kwargs):\r\n ... if word.upper() in ('TCP', 'UDP'):\r\n ... return word.upper()\r\n ...\r\n >>> headLineStyle.headLineStyle('a simple tcp and udp wrapper', callback=abbreviations)\r\n 'A Simple TCP and UDP Wrapper'\r\n\r\nThe callback function is supplied with an ``all_caps`` keyword argument, indicating\r\nwhether the entire line of text was entirely capitalized. Returning ``None`` from\r\nthe callback function will allow headLineStyle to process the word as normal.\r\n\r\nCommand Line Usage\r\n------------------\r\nheadLineStyle also provides a command line utility ``headLineStyle``:\r\n\r\n >>> $ headLineStyle make me a title\r\n ... Make Me a Title\r\n ... $ echo \"Can pipe and/or whatever else\" | headLineStyle\r\n ... Can Pipe and/or Whatever Else\r\n ... # Or read/write files:\r\n ... $ headLineStyle -f infile -o outfile\r\n\r\nIn addition, commonly used acronyms can be kept in a local file\r\nat `~/.headLineStyle.txt`. This file contains one acronym per line.\r\nThe acronym will be maintained in the title as it is provided.\r\nOnce there is e.g. one line saying `TCP`, then it will be automatically\r\nused when used from the command line.\r\n\r\n >>> $ headLineStyle I LOVE TCP\r\n >>> I Love TCP\r\n\r\n\r\nLimitations\r\n-----------\r\n\r\nThis is a best-effort library that uses regexes to try to do intelligent\r\nthings, but will have limitations. For example, it does not have the contextual\r\nawareness to distinguish acronyms from words: us (we) versus US (United States).\r\n\r\nThe regexes and titlecasing rules were written for American English. While\r\nthere is basic support for Unicode characters, such that something like\r\n\"El Ni\u00f1o\" will work, it is likely that accents or non-English phrases will\r\nnot be handled correctly.\r\n\r\nIf anyone has concrete solutions to improve these or other shortcomings of the\r\nlibrary, pull requests are very welcome!\r\n\r\n# License\r\n-----------\r\nCopyright [2022] [Vinod Baste]\r\n\r\nLicensed under the Apache License, Version 2.0 (the \"License\");\r\nyou may not use this file except in compliance with the License.\r\nYou may obtain a copy of the License at\r\n\r\n http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nUnless required by applicable law or agreed to in writing, software\r\ndistributed under the License is distributed on an \"AS IS\" BASIS,\r\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\nSee the License for the specific language governing permissions and\r\nlimitations under the License.\r\n\r\n",
"bugtrack_url": null,
"license": "",
"summary": "About This filter changes a given text to Title Caps, and attempts to be clever about SMALL words like a/an/the in the input. The list of SMALL words which are not capped comes from the New York Times Manual of Style, plus some others like 'vs' and 'v'.",
"version": "1.5.7",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a05dbe160839d4910039880e4e025c3dd57f62c8b2375b38e85dbaf9e8699e9e",
"md5": "809d46553c0afeed37426675fb8c905a",
"sha256": "b956323b1c6cb6e294988c1aaeb468861a4a9e5075d71f07e3fef567143fca29"
},
"downloads": -1,
"filename": "headline_style-1.5.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "809d46553c0afeed37426675fb8c905a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 11499,
"upload_time": "2023-01-21T12:28:09",
"upload_time_iso_8601": "2023-01-21T12:28:09.478208Z",
"url": "https://files.pythonhosted.org/packages/a0/5d/be160839d4910039880e4e025c3dd57f62c8b2375b38e85dbaf9e8699e9e/headline_style-1.5.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3c5c2576c3b4f7836e2946d3854c3a5870320be5caee5942e01fb3c9b5836fab",
"md5": "399ebc56d31c200a1e90e778004e0507",
"sha256": "e5dd292315204ac7570503455f2cae0df93f12916a7551fbfe8a567b95e3a5ab"
},
"downloads": -1,
"filename": "headline_style-1.5.7.tar.gz",
"has_sig": false,
"md5_digest": "399ebc56d31c200a1e90e778004e0507",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 18100,
"upload_time": "2023-01-21T12:28:11",
"upload_time_iso_8601": "2023-01-21T12:28:11.444818Z",
"url": "https://files.pythonhosted.org/packages/3c/5c/2576c3b4f7836e2946d3854c3a5870320be5caee5942e01fb3c9b5836fab/headline_style-1.5.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-21 12:28:11",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "vinodbaste",
"github_project": "python_headline_style",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "headline-style"
}