Most viewed recipes tagged "word"http://code.activestate.com/recipes/tags/word/views/2013-12-24T23:03:43-08:00ActiveState Code RecipesPluralize word -- convert singular word to its plural form (Python) 2011-07-06T21:37:19-07:00Ben Hoythttp://code.activestate.com/recipes/users/4170919/http://code.activestate.com/recipes/577781-pluralize-word-convert-singular-word-to-its-plural/ <p style="color: grey"> Python recipe 577781 by <a href="/recipes/users/4170919/">Ben Hoyt</a> (<a href="/recipes/tags/plural/">plural</a>, <a href="/recipes/tags/pluralize/">pluralize</a>, <a href="/recipes/tags/singular/">singular</a>, <a href="/recipes/tags/word/">word</a>). </p> <p>The pluralize() function returns the plural form of the given lowercase singular word (English only). Based on ActiveState recipe <a href="http://code.activestate.com/recipes/413172/" rel="nofollow">http://code.activestate.com/recipes/413172/</a></p> Convert Microsoft Word files to PDF with DOCXtoPDF (Python) 2013-12-24T23:03:43-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/578795-convert-microsoft-word-files-to-pdf-with-docxtopdf/ <p style="color: grey"> Python recipe 578795 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/docx/">docx</a>, <a href="/recipes/tags/microsoft/">microsoft</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/word/">word</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>). </p> <p>Yhis recipe shows how to convert Microsoft Word .DOCX files to PDF format, using the python-docx library and my xtopdf toolkit for PDF creation.</p> <p>Note: The recipe has some limitations. E.g. fonts, tables, etc. from the input DOCX file are not preserved in the output PDF file.</p> Self-contained TWL06 Dictionary Module (515 KB) (Python) 2011-08-10T20:32:03-07:00Michael Foglemanhttp://code.activestate.com/recipes/users/4171845/http://code.activestate.com/recipes/577835-self-contained-twl06-dictionary-module-515-kb/ <p style="color: grey"> Python recipe 577835 by <a href="/recipes/users/4171845/">Michael Fogleman</a> (<a href="/recipes/tags/dawg/">dawg</a>, <a href="/recipes/tags/dictionary/">dictionary</a>, <a href="/recipes/tags/scrabble/">scrabble</a>, <a href="/recipes/tags/trie/">trie</a>, <a href="/recipes/tags/twl06/">twl06</a>, <a href="/recipes/tags/word/">word</a>). Revision 4. </p> <p>A convenient, self-contained, 515 KB Scrabble dictionary module, ideal for use in word games.</p> <p>Functionality:</p> <ul> <li>Check if a word is in the dictionary.</li> <li>Enumerate all words in the dictionary.</li> <li>Determine what letters may appear after a given prefix.</li> <li>Determine what words can be formed by anagramming a set of letters.</li> </ul> <p>Sample usage:</p> <pre class="prettyprint"><code>&gt;&gt;&gt; import twl &gt;&gt;&gt; twl.check('dog') True &gt;&gt;&gt; twl.check('dgo') False &gt;&gt;&gt; words = set(twl.iterator()) &gt;&gt;&gt; len(words) 178691 &gt;&gt;&gt; twl.children('dude') ['$', 'd', 'e', 's'] &gt;&gt;&gt; list(twl.anagram('top')) ['op', 'opt', 'pot', 'to', 'top'] </code></pre> Scrambled word solving game (Python) 2009-12-03T19:48:56-08:00me mehttp://code.activestate.com/recipes/users/4172371/http://code.activestate.com/recipes/576963-scrambled-word-solving-game/ <p style="color: grey"> Python recipe 576963 by <a href="/recipes/users/4172371/">me me</a> (<a href="/recipes/tags/anagram/">anagram</a>, <a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/word/">word</a>). Revision 4. </p> <p>Solve scrambled words. This game is made by a newbie to python so...</p> Converts doc files into text files on Windows platform (Python) 2012-05-08T06:39:43-07:00Shao-chuan Wanghttp://code.activestate.com/recipes/users/4168519/http://code.activestate.com/recipes/578121-converts-doc-files-into-text-files-on-windows-plat/ <p style="color: grey"> Python recipe 578121 by <a href="/recipes/users/4168519/">Shao-chuan Wang</a> (<a href="/recipes/tags/conversion/">conversion</a>, <a href="/recipes/tags/pythoncom/">pythoncom</a>, <a href="/recipes/tags/word/">word</a>). </p> <p><strong>READ BEFORE YOU USE THE CODE</strong></p> <p><strong>Requirements</strong></p> <ol> <li>Windows platform</li> <li>Python 2.7</li> <li>pywin32, <a href="http://sourceforge.net/projects/pywin32/" rel="nofollow">http://sourceforge.net/projects/pywin32/</a></li> <li>Word application installed on running machine</li> </ol> Word Wrap for Proportional Fonts (Python) 2011-11-11T21:29:21-08:00Michael Foglemanhttp://code.activestate.com/recipes/users/4171845/http://code.activestate.com/recipes/577946-word-wrap-for-proportional-fonts/ <p style="color: grey"> Python recipe 577946 by <a href="/recipes/users/4171845/">Michael Fogleman</a> (<a href="/recipes/tags/fixed/">fixed</a>, <a href="/recipes/tags/font/">font</a>, <a href="/recipes/tags/proportional/">proportional</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/text/">text</a>, <a href="/recipes/tags/word/">word</a>, <a href="/recipes/tags/word_wrap/">word_wrap</a>, <a href="/recipes/tags/wrap/">wrap</a>). </p> <p>Word wrap function / algorithm for wrapping text using proportional (versus fixed-width) fonts.</p> <p><code>text</code>: a string of text to wrap <code>width</code>: the width in pixels to wrap to <code>extent_func</code>: a function that returns a (w, h) tuple given any string, to specify the size (text extent) of the string when rendered. the algorithm only uses the width.</p> <p>Returns a list of strings, one for each line after wrapping.</p> Komodo Python Macro - select the current word under the cursor (Python) 2010-01-14T12:30:45-08:00Todd Whitemanhttp://code.activestate.com/recipes/users/2666241/http://code.activestate.com/recipes/577006-komodo-python-macro-select-the-current-word-under-/ <p style="color: grey"> Python recipe 577006 by <a href="/recipes/users/2666241/">Todd Whiteman</a> (<a href="/recipes/tags/cursor/">cursor</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/toddw/">toddw</a>, <a href="/recipes/tags/word/">word</a>). Revision 6. </p> <p>A <a href="http://www.activestate.com/komodo">Komodo</a> Python macro that can be used to select the current word under the cursor position.</p> <p>JavaScript version here: <a href="http://code.activestate.com/recipes/577007/">Recipe 577007</a>.</p> Minimalistic Word Wrap using Regex (Python) 2012-06-07T14:31:44-07:00Alfehttp://code.activestate.com/recipes/users/4182236/http://code.activestate.com/recipes/578162-minimalistic-word-wrap-using-regex/ <p style="color: grey"> Python recipe 578162 by <a href="/recipes/users/4182236/">Alfe</a> (<a href="/recipes/tags/minimalistic/">minimalistic</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/regex/">regex</a>, <a href="/recipes/tags/word/">word</a>, <a href="/recipes/tags/wrap/">wrap</a>). </p> <p>I know there is the module textwrap and other recipes like <a href="http://code.activestate.com/recipes/148061-one-liner-word-wrap-function/" rel="nofollow">http://code.activestate.com/recipes/148061-one-liner-word-wrap-function/</a></p> <p>But in some constellations my recipe for a very simple word wrap might come in handy nevertheless.</p> Textual diffs between word files (Python) 2010-02-16T08:58:07-08:00Joseph Reaglehttp://code.activestate.com/recipes/users/4171494/http://code.activestate.com/recipes/577055-textual-diffs-between-word-files/ <p style="color: grey"> Python recipe 577055 by <a href="/recipes/users/4171494/">Joseph Reagle</a> (<a href="/recipes/tags/diff/">diff</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/word/">word</a>). </p> <p>Diff two directories of Word documents, providing extra context as well, using antiword and dwdiff.</p> Komodo JS Macro - select the current word under the cursor (JavaScript) 2010-01-14T12:30:17-08:00Todd Whitemanhttp://code.activestate.com/recipes/users/2666241/http://code.activestate.com/recipes/577007-komodo-js-macro-select-the-current-word-under-the-/ <p style="color: grey"> JavaScript recipe 577007 by <a href="/recipes/users/2666241/">Todd Whiteman</a> (<a href="/recipes/tags/cursor/">cursor</a>, <a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/toddw/">toddw</a>, <a href="/recipes/tags/word/">word</a>). </p> <p>A <a href="http://www.activestate.com/komodo">Komodo</a> JavaScript macro that can be used to select the current word under the cursor position.</p> <p>Python version here: <a href="http://code.activestate.com/recipes/577006/">Recipe 577006</a>. </p> Komodo JS Macro: Real auto word-wrap (JavaScript) 2012-04-10T17:38:13-07:00Furlohttp://code.activestate.com/recipes/users/4180513/http://code.activestate.com/recipes/578099-komodo-js-macro-real-auto-word-wrap/ <p style="color: grey"> JavaScript recipe 578099 by <a href="/recipes/users/4180513/">Furlo</a> (<a href="/recipes/tags/auto/">auto</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/word/">word</a>, <a href="/recipes/tags/wrap/">wrap</a>). </p> <p>This script will add real auto-wrap functionality to Komodo, ie. it will wrap text after reaching column 80 just in the same way as you would by pressing &lt;Enter&gt;.</p> <p>You can bind a keyboard shortcut to macro, or trigger it on Komodo startup, or both. Either way, repeated pressing of binded shortcut (or running the macro) will switch it off and on again.</p> <p>In fact, script only adds event listener, which fires a function (after each keypress), that checks if cursor position is not in column higher that 79 and, if needed, calls Komodo built-in function "Reflow paragraph" to reflow the paragraph.</p> <p>This recipe was not created by me from scratch. I have just read David Brewer's feature request at <a href="http://code.activestate.com/lists/komodo-discuss/4965/">komodo-discuss</a>, used <a href="http://www.openkomodo.com/blogs/troyt/revenge-auto-wrap-type-type-type-ding">troyt's original code</a> for autowrap and tweaked/simplified it a little.</p>