diff --git a/CHANGES.rst b/CHANGES.rst index 4c4c1e3..37d0de5 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,14 @@ Release History =============== +1.1.0 +===== + +* Words be now in a separate csv file fer convenience. +* Arrr will now get angry if you call it without any arguments. Hornswogglers 'are not welcome me lad. +* Correct treatment of punctuation and capitalization. +* Lots of shiny new additions, go check 'em out ye scurvy dog! + 1.0.3 ===== diff --git a/Makefile b/Makefile index 85e7c9c..1241224 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ clean: tidy: clean @echo "\nTidying code with black..." - black -l 79 arrr.py + black -l 79 arrr docs: clean $(MAKE) -C docs html diff --git a/arrr.py b/arrr/__init__.py old mode 100755 new mode 100644 similarity index 69% rename from arrr.py rename to arrr/__init__.py index 404b9ae..a8cc7b3 --- a/arrr.py +++ b/arrr/__init__.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python - -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 """ A module for turning plain English into Pirate speak. Arrr. @@ -23,10 +21,10 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -import argparse as arrrgparse # Geddit..? ;-) -import random import sys - +import random +import argparse as arrrgparse # Geddit..? ;-) +from csv import reader as helmsman # He be the only lad aboard who can read! #: The help text to be shown when requested. _HELP_TEXT = """ @@ -35,55 +33,16 @@ Documentation here: https://arrr.readthedocs.io/en/latest/ """ - #: MAJOR, MINOR, RELEASE, STATUS [alpha, beta, final], VERSION -_VERSION = (1, 0, 3) - +_VERSION = (1, 1, 0) #: Defines English to Pirate-ish word substitutions. -_PIRATE_WORDS = { - "hello": "ahoy", - "hi": "arrr", - "my": "me", - "friend": "m'hearty", - "boy": "laddy", - "girl": "lassie", - "sir": "matey", - "miss": "proud beauty", - "stranger": "scurvy dog", - "boss": "foul blaggart", - "where": "whar", - "is": "be", - "the": "th'", - "you": "ye", - "old": "barnacle covered", - "happy": "grog-filled", - "nearby": "broadside", - "bathroom": "head", - "kitchen": "galley", - "pub": "fleabag inn", - "stop": "avast", - "yes": "aye", - "no": "nay", - "yay": "yo-ho-ho", - "money": "doubloons", - "treasure": "booty", - "strong": "heave-ho", - "take": "pillage", - "drink": "grog", - "idiot": "scallywag", - "sea": "briney deep", - "vote": "mutiny", - "song": "shanty", - "drunk": "three sheets to the wind", - "lol": "yo ho ho", - "talk": "parley", - "fail": "scupper", - "quickly": "smartly", - "captain": "cap'n", - "meeting": "parley with rum and cap'n", -} +_PIRATE_WORDS = dict() +with open('BLABBER.csv') as nonsense: + for gibberish in helmsman(nonsense, delimiter=','): + _PIRATE_WORDS[gibberish[0]] = gibberish[1] +del nonsense, gibberish #: A list of Pirate phrases to randomly insert before or after sentences. _PIRATE_PHRASES = [ @@ -118,27 +77,35 @@ def translate(english): """ Take some English text and return a Pirate-ish version thereof. """ - # Normalise a list of words (remove whitespace and make lowercase) - words = [w.lower() for w in english.split()] + # Put text inside a list of words + words = [w for w in english.split()] + + result = list() # Substitute some English words with Pirate equivalents. - result = [_PIRATE_WORDS.get(word, word) for word in words] # Capitalize words that begin a sentence and potentially insert a pirate # phrase with a chance of 1 in 5. capitalize = True - for i, word in enumerate(result): - if capitalize: - result[i] = word.capitalize() - capitalize = False - if word.endswith((".", "!", "?", ":",)): - # It's a word that ends with a sentence ending character. + for i, word in enumerate(words): + c = '' + if word[-1] in [".", "!", "?", ":"]: + c = word[-1] + word = word[:-1] + + res = _PIRATE_WORDS.get(word.lower(), word) + result.append((res.capitalize() if capitalize else res) + c) + + if c != '': capitalize = True if random.randint(0, 5) == 0: - result.insert(i + 1, random.choice(_PIRATE_PHRASES)) + result.append(random.choice(_PIRATE_PHRASES).capitalize()) + else: + capitalize = False + return " ".join(result) def main(arrrgv=None): - """ + """ Entry point for the command line tool 'pirate'. Will print help text if the optional first argument is "help". Otherwise, @@ -161,6 +128,10 @@ def main(arrrgv=None): "Summat went awry, me lovely! Arrr..." ) sys.exit(1) + else: + print( + "Ye filthy bilge rat, don't try to fool me! I will gut yer insides!" + ) if __name__ == "__main__": diff --git a/arrr/blabber.csv b/arrr/blabber.csv new file mode 100644 index 0000000..a5172cd --- /dev/null +++ b/arrr/blabber.csv @@ -0,0 +1,253 @@ +abandoned,marooned +abandoning,marooning +adventurer,buccaneer +adventurers,buccaneers +agreed,yay +alcohol,rum +am,be +america,the new world +and,an' +animal,bilge rat +animals,bilge rats +apartment,deck +apartments,decks +are,be +argh,arrr +armistice,parley +asap,snap to it +attention,avast +band,crew +bank,hold +bar-maid,wench +barmaid,wench +bartender,barkeep +bathroom,head +bedtime,lights out +behold,avast +binocular,spyglass +binoculars,spyglass +biscuit,hardtack +boss,foul blaggart +boy,laddy +boys,lads +bread,hardtack +bro,bucko +bud,mate +buddies,mateys +buddy,matey +buddys,mateys +bullet,musketball +bye,be off then +captain,cap'n +car,vessel +carpenter,shipwright +cease,avast +ceasefire,parley +cleaning,scrubbin' +community,crew +conference,parley +conspiracy,mutiny +conspirator,mutineer +crazy,daft +crippled,maimed +damn,damn to the depths +darling,beauty +deceived,hornswoggled +deposit,hold +despicable,vile +didn't,did nay +dinosaur,reptile +dinosaurs,reptiles +dirty,filthy +disease,scurvy +drink,grog +driver,helmsman +drunk,three sheets to the wind +dude,mate +dudes,mates +dudette,princess +dumb,foolish +dupe,hornswoggle +duped,hornswoggled +duper,hornswoggler +email,pigeon message +enemies,filthy dogs +enemy,foe +ever,e'er +eye,me good eye +eyeglasses,specs +eyepatch,me bad eye +fail,scupper +fat,blubber +food,grub +for,fer +forever,fore'er +friend,m'hearty +friend,mate +friends,mates +funny,jolly +galleon,man-o'-war +girl,lassie +girls,lasses +glasses,specs +gonna,fixin' to +good,jolly +gossip,mutiny +gossiper,mutineer +great,jolly +group,crew +gun,blunderbuss +gunpowder,shot +guy,scurvy dog +guys,scurvy dogs +ha,harr +hack,hornswoggle +hacked,hornswoggled +hacker,hornswoggler +haha,harharr +halt,avast +handgun,handcannon +happy,grog-filled +have,'ave +hello,ahoy +here,'ere +hey,'ay +hi,ahoy +him,'im +hiya,ahoy-arr +hold,hould +home,tortuga +i'm,i be +idiot,scallywag +inebriated,three sheets to the wind +intoxicated,three sheets to the wind +is,be +it's,it be +jail,brig +journey,voyage +juke,hornswoggle +juked,hornswoggled +juker,hornswoggler +kitchen,galley +knife,dagger +landlover,landlubber +lately,as o' late +leave,set sail +lift,hoist +liquid,grog +lmao,i have lost me booty laughin' so hard +lmfao,i have lost me booty laughin' so hard +lol,yo ho ho +loudmouth,gobshite +lover,lubber +man,seaman +many,plenty'o +math,maths +mathematic,maths +mathematics,maths +meeting,parley with rum and cap'n +men,seamen +miserable,wretched +misinformed,hornswoggled +misinformer,hornswoggler an' lyin' type +miss,proud beauty +mister,master +money,doubloons +monster,foul beast +mr,master +mr.,master +mrs,mistress +mrs.,mistress +ms,miss +ms.,miss +must,shall +my,me +myself,meself +navy,royal navy +nearby,broadside +negotiate,parley +negotiation,parley +never,ne'er +new,shiny new +no,nay +of,o' +oh no,shiver me timbers +old,barnacle covered +organs,guts +over,o'er +pal,mate +pals,mates +par,parley +parsley,parley +parsnip,parley +phew,ye near gave me a fright laddie +pickpocket,pilfer +pirate,gentlemen o' fortune +pirates,gentlemen o' fortune +pirating,treasure hunting +plane,boat +president,governor +prison,brig +promise,solemn oath +promises,solemn oaths +pub,fleabag inn +quickly,smartly +rarr,arr +ration,hardtack +rations,grub +rawr,arr +repair,mend +repaired,mended +rifle,musket +sea,briney deep +seen,spied +semi-related,half-related +she's,she be +shipbiscuit,hardtack +shit,shite +shortsword,cutlass +sir,matey +something,summat +sometimes,oftentimes +song,shanty +steal,plunder +stop,avast +stranger,scurvy dog +strong,heave-ho +sup,what be the matter +take,pillage +taking,grabbin' +talk,parley +talking,blabberin' +telescope,spyglass +that's,that be +that,that there +the,th' +them,'em +they're,they be +this,this here +those,them +translating,translatin' +translator,device o' translation +treasure,booty +tricked,hornswoggled +up here,up on deck +up,to the sky +vote,mutiny +was,been +we're,we be +welcome,ye be welcome +were,was +where,whar +whole,'ole +will be,be +wtf,blimey +wth,blimey +ya,yarr +yay,yo-ho-ho +yeah,yarr +yes,aye +you're,ye be +you,ye +your,yer +yourself,yerself \ No newline at end of file diff --git a/setup.py b/setup.py index f9c5ad0..4ee6b84 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 from setuptools import setup from arrr import get_version @@ -17,8 +16,8 @@ author="Nicholas H.Tollervey", author_email="ntoll@ntoll.org", url="https://github.com/ntoll/arrr", - py_modules=["arrr",], - license="MIT", + packages=["arrr"], + include_package_data=True, classifiers=[ "Development Status :: 5 - Production/Stable", "Environment :: Console", @@ -31,5 +30,5 @@ "Topic :: Communications", "Topic :: Software Development :: Internationalization", ], - entry_points={"console_scripts": ["pirate=arrr:main"],}, + entry_points={"console_scripts": ["pirate=arrr:main"]}, )