Home
> Everything Else > It be that time o’ year again – 19th September, International Talk Like A Pirate Day
It be that time o’ year again – 19th September, International Talk Like A Pirate Day
Well ye scurvy land-lubbers, it’s that day again – t’ infamous Parlay Like A Pirate day.
Tho’ its origins be clouded in mystery (well, unless you visit the website anyway) It’s become a globally celebrated phenomenon.
So much so that I be inclined t’ see how fast I could code up one o’ my infamous VBScript classes t’ help yonder less able translate their words.
Here it be in its full glory – yonder incredible, 17minute VBScript pirate speak class.
https://sites.google.com/site/ctogonewild/Home/intersting-files/Piratespeak.vbs.zip
1 : ' Piratespeak translator 2 : ' Simon Hunt, International Speak Like A Pirate Day 19th Sep 2016 3 : ' www.ctogonewild.com 4 : 5 : Dim Pirate: Set Pirate = New clsPirate 6 : 7 : If Not WScript.Arguments.count=0 Then 8 : WScript.Echo Pirate.PirateSpeak(WScript.Arguments(0)) 9 : Else 10 : 'MsgBox Pirate.PirateSpeak(InputBox("Enter English ye scurvy dog!")) ' uncomment for Interactive version. 11 : Pirate.about 12 : End If 13 : 14 : Class clsPirate 15 : 16 : Public Version 17 : Private dicPirate,deliniators 18 : 19 : Private Sub Class_Initialize 20 : version = "1.00" 21 : Set dicPirate = CreateObject("scripting.dictionary") 22 : dicPirate.CompareMode = vbTextCompare 23 : deliniators = ",.:!.;" 24 : BuildDB 25 : End Sub 26 : 27 : Public Function PirateSpeak(ByVal str) 28 : Dim line,words,tDelin,tArr,tstr,i,newword 29 : ' split str into an array of lines 30 : str = Split(str,vbCrLf) 31 : 32 : For Each line In str 33 : words = Split(line," ") 34 : For Each word In words 35 : 36 : If word <>"" Then 37 : If InStr(deliniators,Right(word,1))>0 Then 38 : tDelin = Right(word,1) 39 : word = Left(word,Len(word)-1) 40 : Else 41 : tDelin = "" 42 : End If 43 : 44 : If dicPirate.Exists(word) Then 45 : tArr = Split(dicPirate(word),"|") 46 : If UBound(tArr)> 0 Then 47 : i = Int((UBound(tArr)+1)*Rnd) 48 : Else 49 : i = 0 50 : End If 51 : newword = tArr(i) 52 : Else ' not in dictionary 53 : 54 : ' generic rule to convert ing to ' 55 : If Right(word,3)="ing" Then 56 : newword = Left(word,Len(word)-1) & "'" 57 : Else 58 : newword = word 59 : End If 60 : End If 61 : 62 : ' fix capitalization if a real word 63 : If word <>"" Then 64 : If Asc(Left(word,1))>=Asc("A") And Asc(Left(word,1))<=Asc("Z") Then 65 : ' capital letter 66 : newword = UCase(Left(newword,1)) & Mid(newword,2) 67 : End If 68 : End If 69 : tstr = tstr & " " & newword & tdelin 70 : End If 71 : Next ' word 72 : PirateSpeak = PirateSpeak & Mid(tstr,2) & vbCrLf 73 : tstr = "" 74 : Next ' line 75 : ' trim last vbcrlf 76 : PirateSpeak = Left(PirateSpeak,Len(PirateSpeak)-2) 77 : End Function 78 : 79 : Private Sub BuildDB 80 : ' creates the dictionary of pirate translation 81 : Dim str,arr,word,eng,pir 82 : 83 : str = "" & _ 84 : "Hello|ahoy|avast,this|'tis,of|'o,the|th',the|ye,the|yonder|thar,is|be," &_ 85 : "for|fer,men|scallywags|scurvey deckhands,to|t'," &_ 86 : "comes|hails,friends|crew,your|ye,you|ye,right|starboard,left|port," &_ 87 : "woman|wench|lass,girl|lass,boy|cabin boy,person|landlubber," &_ 88 : "friend|mate,beer|grog,yes|yaar|eye,you're|yer," &_ 89 : "and|'n,hi|yo-ho-ho,stranger|scurvy dog,where|whar"&_ 90 : "crazy|addled,afraid|afeared,high|aloft,stop|avast,weight|ballast,"&_ 91 : "stop|belay,money|booty|bounty,frend|bucko,room|cabin,rope|cable,"&_ 92 : "eggs|cackle fruit,captain|cap'n,"&_ 93 : "barrel|cask,chart|map,bed|cot,sword|cutlass,eyes|deadlights,floor|deck,"&_ 94 : "coin|doubloon,"&_ 95 : "luck|fair winds,whip|flog,forward|fore,behind|aft,rum|grog,food|grub,"&_ 96 : "call|hail,bed|hammock,"&_ 97 : "creman|hands,toilet|head,dance|hornpipe,cheat|hornswaggle,sailor|jack tar,"&_ 98 : "boy|lad,rope|line,friends|me heartys,america|new world,steal|plunder,"&_ 99 : "disease|pox,odd|rum,song|shanty,neat|shipshape,"&_ 100 : "quickly|smartly,telescope|spyglass,clean|swab,riches|swag,clean|titivate,"&_ 101 : "talk|parlay,sir|matey,mother|ol' mum# bless her black soul,ocean|brimy deep" 102 : 103 : arr = Split(str,",") 104 : For Each word In arr 105 : If word <>"" Then 106 : eng = Left(word,InStr(word,"|")-1) 107 : pir = Mid(word,InStr(word,"|")+1) 108 : pir = Replace(pir,"#",",") 109 : 110 : If dicPirate.Exists(eng) Then 111 : dicPirate(eng) = dicPirate(eng) & "|" & pir 112 : Else 113 : dicPirate.Add eng,pir 114 : End If 115 : End If 116 : Next ' word 117 : 118 : End Sub 119 : 120 : Public Sub about 121 : Dim str 122 : str = "Pirate Translator by Simon Hunt ctogonewild.com||" &_ 123 : "Use from a command line with your desired translation as a parameter|" &_ 124 : "For example ||cscript piratespeak ""A lovely Day For friends To journey On the Ocean.|Now no stealing any food."".||Output: " &_ 125 : PirateSpeak("A lovely Day For friends To journey On the Ocean."&vbCrLf&"Now no stealing any food.") 126 : 127 : WScript.Echo Replace(str,"|",vbCrLf) 128 : End Sub 129 : 130 : Public Sub Test 131 : ' simple test harness 132 : Dim i 133 : For i = 0 To 10 134 : WScript.Echo piratespeak("Hello, sir! I'm glad you're now my friend; you're no longer a stranger.") 135 : Next 136 : End Sub 137 : 138 : End Class 139 :
Categories: Everything Else
Pirate
Comments (0)
Trackbacks (0)
Leave a comment
Trackback
Comments