From 44168c4d4de6c895b02012321d6937fd46357d9f Mon Sep 17 00:00:00 2001 From: Riccardo Belli <61554895+belliriccardo@users.noreply.github.com> Date: Sun, 15 May 2022 17:35:53 +0200 Subject: [PATCH 1/7] Substitute words from separate file, new additions --- BLABBER.csv | 235 ++++++++++++++++++++++++++++++++++++++++++++++++++++ CHANGES.rst | 6 ++ arrr.py | 49 ++--------- 3 files changed, 247 insertions(+), 43 deletions(-) create mode 100644 BLABBER.csv diff --git a/BLABBER.csv b/BLABBER.csv new file mode 100644 index 0000000..1ca1454 --- /dev/null +++ b/BLABBER.csv @@ -0,0 +1,235 @@ +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,cart +cease,avast +ceasefire,parley +cleaning,scrubbin' +community,crew +conference,parley +conspiracy,mutiny +conspirator,mutineer +crazy,daft +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 +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 +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 +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 +many,lots of +math,maths +mathematic,maths +mathematics,maths +meeting,parley with rum and cap'n +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 +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 +pub,fleabag inn +quickly,smartly +rarr,arr +ration,hardtack +rations,grub +rawr,arr +rifle,musket +sea,briney deep +seen,spied +semi-related,half-related +she's,she be +shipbiscuit,hardtack +shit,shite +shortsword,cutlass +sir,matey +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/CHANGES.rst b/CHANGES.rst index 4c4c1e3..3402db4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,12 @@ Release History =============== +1.1.0 +===== + +* Words be now in a separate csv file fer convenience. +* Lots of shiny new additions, go check 'em out ye scurvy dog! + 1.0.3 ===== diff --git a/arrr.py b/arrr.py index 404b9ae..b087efb 100755 --- a/arrr.py +++ b/arrr.py @@ -24,6 +24,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ import argparse as arrrgparse # Geddit..? ;-) +from csv import reader as HELMSMAN # He be the only lad aboard who can read! import random import sys @@ -37,52 +38,14 @@ #: 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] #: A list of Pirate phrases to randomly insert before or after sentences. From 067ea98d0a8be61218a863ca70665b6df1613958 Mon Sep 17 00:00:00 2001 From: Riccardo Belli <61554895+belliriccardo@users.noreply.github.com> Date: Sun, 15 May 2022 23:53:12 +0200 Subject: [PATCH 2/7] Add csv file in module --- MANIFEST.in | 1 + setup.py | 1 + 2 files changed, 2 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index b756c83..d3a6ea6 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,4 @@ include CHANGES.rst include README.rst include LICENSE +include BLABBER.csv \ No newline at end of file diff --git a/setup.py b/setup.py index f9c5ad0..73d3536 100644 --- a/setup.py +++ b/setup.py @@ -31,5 +31,6 @@ "Topic :: Communications", "Topic :: Software Development :: Internationalization", ], + include_package_data=True, entry_points={"console_scripts": ["pirate=arrr:main"],}, ) From 0466edd9f3717ffe94f9feafa310edc3219e8327 Mon Sep 17 00:00:00 2001 From: Riccardo Belli <61554895+belliriccardo@users.noreply.github.com> Date: Mon, 16 May 2022 10:04:55 +0200 Subject: [PATCH 3/7] Add csv file in module --- CHANGES.rst | 1 + arrr.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 3402db4..2bec593 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,7 @@ Release History ===== * Words be now in a separate csv file fer convenience. +* Arrr.py will now get angry if you call it without any arguments. Hornswogglers 'are not welcome me lad. * Lots of shiny new additions, go check 'em out ye scurvy dog! 1.0.3 diff --git a/arrr.py b/arrr.py index b087efb..6dae03c 100755 --- a/arrr.py +++ b/arrr.py @@ -124,7 +124,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__": main(sys.argv[1:]) From 3950f1d5e2ce6475c04282daab5cdbc286900429 Mon Sep 17 00:00:00 2001 From: Riccardo Belli <61554895+belliriccardo@users.noreply.github.com> Date: Mon, 16 May 2022 10:46:54 +0200 Subject: [PATCH 4/7] New words + Arrr misbehaviour with no arrrguments --- BLABBER.csv | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/BLABBER.csv b/BLABBER.csv index 1ca1454..98295b5 100644 --- a/BLABBER.csv +++ b/BLABBER.csv @@ -1,3 +1,7 @@ +abandoned,marooned +abandoning,marooning +adventurer,buccaneer +adventurers,buccaneers agreed,yay alcohol,rum am,be @@ -35,7 +39,8 @@ buddys,mateys bullet,musketball bye,be off then captain,cap'n -car,cart +car,vessel +carpenter,shipwright cease,avast ceasefire,parley cleaning,scrubbin' @@ -44,6 +49,7 @@ conference,parley conspiracy,mutiny conspirator,mutineer crazy,daft +crippled,maimed damn,damn to the depths darling,beauty deceived,hornswoggled @@ -108,6 +114,7 @@ hey,'ay hi,ahoy him,'im hiya,ahoy-arr +hold,hould i'm,i be idiot,scallywag inebriated,three sheets to the wind @@ -130,11 +137,13 @@ lmfao,i have lost me booty laughin' so hard lol,yo ho ho loudmouth,gobshite lover,lubber +man,seaman many,lots of math,maths mathematic,maths mathematics,maths meeting,parley with rum and cap'n +men,seamen miserable,wretched misinformed,hornswoggled misinformer,hornswoggler an' lyin' type @@ -148,6 +157,7 @@ mrs,mistress mrs.,mistress ms,miss ms.,miss +must,shall my,me myself,meself navy,royal navy @@ -175,12 +185,16 @@ 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 From 253ee54b0c061f6945b79c715500c81eb666e8c3 Mon Sep 17 00:00:00 2001 From: Riccardo Belli <61554895+belliriccardo@users.noreply.github.com> Date: Mon, 16 May 2022 11:06:47 +0200 Subject: [PATCH 5/7] New words --- BLABBER.csv | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/BLABBER.csv b/BLABBER.csv index 98295b5..a5172cd 100644 --- a/BLABBER.csv +++ b/BLABBER.csv @@ -70,6 +70,7 @@ dumb,foolish dupe,hornswoggle duped,hornswoggled duper,hornswoggler +email,pigeon message enemies,filthy dogs enemy,foe ever,e'er @@ -115,6 +116,7 @@ hi,ahoy him,'im hiya,ahoy-arr hold,hould +home,tortuga i'm,i be idiot,scallywag inebriated,three sheets to the wind @@ -131,6 +133,7 @@ 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 @@ -138,7 +141,7 @@ lol,yo ho ho loudmouth,gobshite lover,lubber man,seaman -many,lots of +many,plenty'o math,maths mathematic,maths mathematics,maths @@ -204,6 +207,7 @@ shipbiscuit,hardtack shit,shite shortsword,cutlass sir,matey +something,summat sometimes,oftentimes song,shanty steal,plunder From 1d0ac9014ec52890b44bd7b46ac54e68129b6ecc Mon Sep 17 00:00:00 2001 From: Riccardo Belli <61554895+belliriccardo@users.noreply.github.com> Date: Mon, 16 May 2022 14:12:54 +0200 Subject: [PATCH 6/7] Make it such that words that end with punctuation get translated correctly. Example: Before: "How are you?" -> "How be you?" Now: "How are you?" -> "How be ye?" Also don't de-capitalize words in the main dict so that names don't get lowercase'd (Ex. "Jack" -> "jack" inside a string of text no longer happens) --- CHANGES.rst | 1 + arrr.py | 35 ++++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 2bec593..c44fd2f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,7 @@ Release History * Words be now in a separate csv file fer convenience. * Arrr.py 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/arrr.py b/arrr.py index 6dae03c..0a7a22c 100755 --- a/arrr.py +++ b/arrr.py @@ -24,11 +24,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ import argparse as arrrgparse # Geddit..? ;-) -from csv import reader as HELMSMAN # He be the only lad aboard who can read! +from csv import reader as HELMSMAN # He be the only lad aboard who can read! import random import sys - #: The help text to be shown when requested. _HELP_TEXT = """ Take English words and turn them into something Pirate-ish. @@ -36,18 +35,15 @@ Documentation here: https://arrr.readthedocs.io/en/latest/ """ - #: MAJOR, MINOR, RELEASE, STATUS [alpha, beta, final], VERSION _VERSION = (1, 1, 0) - #: Defines English to Pirate-ish word substitutions. _PIRATE_WORDS = dict() with open('BLABBER.csv') as NONSENSE: for GIBBERISH in HELMSMAN(NONSENSE, delimiter=','): _PIRATE_WORDS[GIBBERISH[0]] = GIBBERISH[1] - #: A list of Pirate phrases to randomly insert before or after sentences. _PIRATE_PHRASES = [ "batten down the hatches!", @@ -81,22 +77,30 @@ 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) @@ -129,5 +133,6 @@ def main(arrrgv=None): "Ye filthy bilge rat, don't try to fool me! I will gut yer insides!" ) + if __name__ == "__main__": main(sys.argv[1:]) From a5832844817cebea78f4f29906803bdb18ba6a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Wed, 21 Dec 2022 10:32:43 -0500 Subject: [PATCH 7/7] turn module into package, fix packaging --- CHANGES.rst | 2 +- MANIFEST.in | 1 - Makefile | 2 +- arrr.py => arrr/__init__.py | 20 ++++++++++---------- BLABBER.csv => arrr/blabber.csv | 0 setup.py | 8 +++----- 6 files changed, 15 insertions(+), 18 deletions(-) rename arrr.py => arrr/__init__.py (94%) mode change 100755 => 100644 rename BLABBER.csv => arrr/blabber.csv (100%) diff --git a/CHANGES.rst b/CHANGES.rst index c44fd2f..37d0de5 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,7 @@ Release History ===== * Words be now in a separate csv file fer convenience. -* Arrr.py will now get angry if you call it without any arguments. Hornswogglers 'are not welcome me lad. +* 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! diff --git a/MANIFEST.in b/MANIFEST.in index d3a6ea6..b756c83 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,3 @@ include CHANGES.rst include README.rst include LICENSE -include BLABBER.csv \ No newline at end of file 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 94% rename from arrr.py rename to arrr/__init__.py index 0a7a22c..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..? ;-) -from csv import reader as HELMSMAN # He be the only lad aboard who can read! -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 = """ @@ -40,9 +38,11 @@ #: Defines English to Pirate-ish word substitutions. _PIRATE_WORDS = dict() -with open('BLABBER.csv') as NONSENSE: - for GIBBERISH in HELMSMAN(NONSENSE, delimiter=','): - _PIRATE_WORDS[GIBBERISH[0]] = GIBBERISH[1] +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 = [ @@ -105,7 +105,7 @@ def translate(english): def main(arrrgv=None): - """ + """ Entry point for the command line tool 'pirate'. Will print help text if the optional first argument is "help". Otherwise, diff --git a/BLABBER.csv b/arrr/blabber.csv similarity index 100% rename from BLABBER.csv rename to arrr/blabber.csv diff --git a/setup.py b/setup.py index 73d3536..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,6 +30,5 @@ "Topic :: Communications", "Topic :: Software Development :: Internationalization", ], - include_package_data=True, - entry_points={"console_scripts": ["pirate=arrr:main"],}, + entry_points={"console_scripts": ["pirate=arrr:main"]}, )