I need this javascript translated into java basically. any help?

basically i need to write a program in java that translates english sentence into pirate talk..yeah yeah i know its not original but here is what i need done but its in javascript and i need it written in java:
  <script LANGUAGE="JavaScript">
    PHRASES = [["hello", "ahoy"], ["hi", "yo-ho-ho"], ["pardon me", "avast"],
               ["excuse me", "arrr"], ["yes", "aye"],
               ["my", "me"], ["friend", "me bucko"], ["sir", "matey"],
               ["madam", "proud beauty"], ["miss", "comely wench"],
               ["stranger", "scurvy dog"], ["officer", "foul blaggart"],
               ["where", "whar"], ["is", "be"], ["are", "be"], ["am", "be"],
               ["the", "th'"], ["you", "ye"], ["your", "yer"],
               ["tell", "be tellin'"], ["know", "be knowin'"],
               ["how far", "how many leagues"], ["old", "barnacle-covered"],
               ["attractive", "comely"], ["happy", "grog-filled"], ["quickly", "smartly"],
               ["nearby", "broadside"], ["restroom", "head"], ["restaurant", "galley"],
               ["hotel", "fleabag inn"], ["pub", "Skull & Scuppers"], ["mall", "market"],
               ["bank", "buried treasure"], ["die", "visit Davey Jones' Locker"],
               ["died", "visited Davey Jones' Locker"], ["kill", "keel-haul"],
               ["killed", "keel-hauled"], ["sleep", "take a caulk"],
               ["stupid", "addled"], ["after", "aft"], ["stop", "belay"],
               ["nonsense", "bilge"], ["officer", "bosun"], ["ocean", "briny deep"],
               ["song", "shanty"], ["money", "doubloons"], ["food", "grub"],
               ["nose", "prow"], ["leave", "weigh anchor"], ["cheat", "hornswaggle"],
               ["forward", "fore"], ["child", "sprog"], ["children", "sprogs"],
               ["sailor", "swab"], ["lean", "careen"], ["find", "come across"],
               ["mother", "dear ol' mum, bless her black soul"],
               ["drink", "barrel o' rum"], ["of", "o'"]
    function Capitalize(str)
    // Returns: a copy of str with the first letter capitalized
        return str.charAt(0).toUpperCase() + str.substring(1);
    function Translate(text)
    // Returns: a copy of text with English phrases replaced by piratey equivalemts
        for (var i = 0; i < PHRASES.length; i++) {
            var toReplace = new RegExp("\\b"+PHRASES[0]+"\\b", "i");
var index = text.search(toReplace);
while (index != -1) {
if (text.charAt(index) >= "A" && text.charAt(index) <= "Z") {
text = text.replace(toReplace, Capitalize(PHRASES[i][1]));
else {
text = text.replace(toReplace, PHRASES[i][1]);
index = text.search(toReplace);
return text;
</script>
does anyone have any input on how i should go about this? im decent in java but nothing special. thanks

how do you get the word from the map?
basically if i understand overall goal: im going to
loop through the text given to me and check to see if
any of the words match my hashmap...if it does then i
replace the word with my word in hashmap and output
the new result. correct
>
if thats correct, well then atleast i understand it.
i think i could come up with loop to search but i
have no idea how to compare each word with my map and
then replace if necessary
String replacementWord = map.get(word);
if (replacementWord != null) {
   // Word was found and should be replaced with replacementWord
}Kaj

Similar Messages

  • After upgrading to Maverick, my computer will not upgrade from 10.6.8 to 10.9.5 My editing software will not run on my current version and I need this for my job! Please any help would be SO greatly appreciated!

    Computer won't upgrade to 10.9.5 after Mavericks update.

    This is all a little confusing now...let's stop and get the basics down so Chris and I are on the same sheet of paper:
    What MacBook Pro do you have and how much memory and how much free space on the hard drive?
    From the apple left side of the menu bar, About This Mac, More Info, System Report, Hardware and what does it show for Model Identifier?
    You currently have Mac OS X 10.6.8 installed, downloaded 10.9.x from the Mac App Store?  If so there should be an Installer for Mac OS X in the Finder, Applications folder if it has not yet installed.  Exactly what does it give as the name for the installer and how big is it, should be a little larger than 5 GB.

  • How to transform this pascal code into java code!

    I want to transform this pascal code into java code . Please tel me how to do it because I really don't know how to do it!
    Thanks!
    {CALCULATE HOHN-LONDON FACTORS}
    var kk:tab4;
    PROCEDURE INTENS(var kk:tab4);
    begin
    for n:=0 to nr+2 do
    begin
    kk^[1,n]:=sqrt(lup*lup*yg*(yg-4)+4*sqr(n+1)) +lup*(yg-2);
    kk^[2,n]:= sqrt(lup*lup*yg*(yg-4)+4*sqr(n+1))-lup*(yg-2);
    kk^[3,n]:=0.5*(kk^[1,n]*kk^[1,n]+4*(sqr(n+1)-lup*lup));
    kk^[4,n]:= 0.5*(kk^[2,n]*kk^[2,n]+4*(sqr(n+1)-lup*lup));
    kk^[5,n]:= sqrt(ldown*ldown*yd*(yd-4)+4*sqr(n+1)) +ldown*(yd-2);
    end;
    end;
    BEGIN
    new (kk);
    intens(kk);
    writeln(f2,' ','N ','V','branch ','H-L');
    for n:=1 to np do
    begin
    fp1[n,v]:=(n-ldown)*(n+ldown+1)*sqr(kk^[2,n-1]*kk^[6,n]+4*(n+ldown)*(n-ldown+1));
    fp1[n,v]:=fp1[n,v]/(4*(n+0.5)*kk^[4,n-1]*kk^[8,n]) ;
    writeln(f2,' ',n,' ',v,' fp1 ',fp1[n,v]:10:2);
    end;
    for n:=1 to nq do
    begin
    fq1[n,v]:=sqr(kk^[2,n]*kk^[6,n]*(ldown+0.5)+4*(n-ldown+1)*(n+ldown+1)*(ldown-0.5)) ;
    fq1[n,v]:=fq1[n,v]/(2*(n+0.5)*kk^[4,n]*kk^[8,n]*(n+1.5));
    fq1[n,v]:=fq1[n,v]*(n+1);
    writeln(f2,' ',n,' ',v,' fq1 ',fq1[n,v]:10:2);
    end;
    for n:=1 to nr do
    begin
    fr1[n,v]:=sqr(kk^[2,n+1]*kk^[6,n]+4*(n-ldown+2)*(n+ldown+1));
    fr1[n,v]:=fr1[n,v]/(4*kk^[4,n+1]*kk^[8,n]*(n+1.5));
    fr1[n,v]:=fr1[n,v]*(n-ldown+1)*(n+ldown+2) ;
    writeln(f2,' ',n,' ',v,' fr1 ',fr1[n,v]:10:2);
    end;

    Basically it looks like this:
    public class KK{
         private your_type[][] kk = new your_type[length][length];
         private void intens(your_type[] kk){
              for(int n= 0; n<nr+2; n++){
                   kk[1][n] = Math.sqrt(lup*lup*yg*(yg-4)+4*Math.pow((n+1), 2)) +lup*(yg-2);
                   kk[2][n] = Math.sqrt(lup*lup*yg*(yg-4)+4*Math.pow((n+1), 2))-lup*(yg-2);
                   kk[3][n] = 0.5*(kk[1][n]*kk[1][n]+4*(Math.pow((n+1), 2)-lup*lup));
                   kk[4][n] = 0.5*(kk[2][n]*kk[2][n]+4*(Math.pow((n+1), 2)-lup*lup));
                   kk[5][n] = Math.sqrt(ldown*ldown*yd*(yd-4)+4*Math.pow((n+1), 2)) +ldown*(yd-2);
         public static void main(String args[]){
              KK k = new KK();
              k.intens(kk);
              System.out.println(f2  + ' ' + 'N ' + 'V' + 'branch ' + 'H-L');
              for(int n=1; n < np; n++){
                   fp1[n][v] = (n-ldown)*(n+ldown+1)*Math.pow((kk[2][n-1]*kk[6][n]+4*(n+ldown)*(n-ldown+1)), 2);
                   fp1[n][v] = fp1[n][v]/(4*(n+0.5)*kk[4][n-1]*kk[8][n]) ;
                   System.out.println(f2 + ' ' + n + ' ' + v + ' fp1 ' + fp1[n][v]:10:2);
              for(int n=1; n< nq;n++){
                   fq1[n][v] = Math.pow((kk[2][n]*kk[6][n]*(ldown+0.5)+4*(n-ldown+1)*(n+ldown+1)*(ldown-0.5)), 2);
                   fq1[n][v] = fq1[n][v]/(2*(n+0.5)*kk[4][n]*kk[8][n]*(n+1.5));
                   fq1[n][v] = fq1[n][v]*(n+1);
                   System.out.println(f2 + ' ' + n + ' ' + v + ' fq1 ' + fq1[n][v]:10:2);
              for(int n=1; n < nr; n++){
                   fr1[n][v] = Math.pow((kk[2][n+1]*kk[6][n]+4*(n-ldown+2)*(n+ldown+1)), 2);
                   fr1[n][v] = fr1[n][v]/(4*kk[4][n+1]*kk[8][n]*(n+1.5));
                   fr1[n][v] = fr1[n][v]*(n-ldown+1)*(n+ldown+2) ;
                   System.out.println(f2 + ' ' + n + ' ' + v + ' fr1 ' + fr1[n][v]:10:2); //fr1[n][v]:10:2 --> Here you must use the BigDecimal class
    }I'm not very sure because my pascal knowledge is extremely "dated".
    What about the converter I told you about?

  • Sender Idoc needs to be translated into 4 text files

    Hi,
    Could you please guide me how can i achieve this.
    Within XI this Idoc message needs to be translated into 4 text files:
    Could you pls. confirm as...can i use MultiMapping or shall i go for BPM?
    Thanks & Regards,
    Y.Raj.

    Should also work in your case:
    1. Create your mapping program that will map the information from the source file
    into the destination idoc. This has to be a 1:N split. Just make sure that the destination message type and message interface are are of occurrence N.
    2. Also, you will have 2 destination interfaces and 2 interface mapping, one for the IDOC and one for the mail.
    Now, there are a few essential steps in your configuration,
    1. In the receiver determination, specify the 2 receiver systems, one for your IDOC and the other for your MAIL.
    2. Now, you will have a condition window. Just type the condition on the basis of which the receiver has to be determined for the mail and the idoc business system. Just remember that the condition can be specified only for the source message.
    3. In the Interface Determination, you have an option called RB CLASSIC and RB SPLIT. To do a 1:N split, you will have to do a RB_SPLIT.
    You can even use xslt mapping to split source message type into multiple target messages types.for more information on the same check this link:
    http://help.sap.com/saphelp_erp2005/helpdata/en/83/2200cb50d345c793336d9a1683163e/frameset.htm

  • I need to be able to print or export some photos from iPhoto with the date the photos were taken.  Need this for a legal case.  Any suggestions?

    I need to be able to print or export some photos from iPhoto with the date the photos were taken.  Need this for a legal case.  Any suggestions?

    The date they were taken us in the EXIF data and is included in the export
    However it is trivial to modify it so I doubt that it would hold water in court
    LN

  • No IP address, everytime I'm close to my mums mac running off the same wifi, it's giving me this error. I can trouble shoot for about 3 mins and fix it, but it just keeps happening and I need a permanent fix for it. Any help?

    No IP address, everytime I'm close to my mums mac running off the same wifi, it's giving me this error. I can trouble shoot for about 3 mins and fix it, but it just keeps happening and I need a permanent fix for it. Any help?

    this is what you need to do to exclude everything apart from desktop.
    on time machine preferences, click on Options
    click plus sign, on the new window, click macintosh HD
    do a Control + A then deselect users then click okay
    go to options again, plus sign, go to users, control +A then deselect your user account
    go to options again, plus sign, go to your user account, control + A, deselect desktop
    start the back up.

  • Just bought Lightroom 6 through B&H Photo Video online and now Adobe says it is "unable to validate this serial number for Lightroom".  Any help for me here folks?

    Just bought Lightroom 6 through B&H Photo Video online and now Adobe says it is "unable to validate this serial number for Lightroom".  Any help for me here folks?

    If you want to buy the product Lightroom 6.0 from the Adobe Website, then please visit here-
    http://www.adobe.com/products/catalog/software._sl_id-contentfilter_sl_catalog_sl_software _sl_mostpopular.html
    And scroll down to the bottom and spot the Lightroom 6.0 to buy the standalone application.
    You can buy the application as an upgrade or full product (second red box in the screen shot shows the previous version of the software you own and needed to be selected if you are buying the upgrade Lightroom 6.0 ) in case you have the previous version ( Lightroom 1.0, 2.0, 3.0, 4.0, 5.0 ) serial number registered or noted somewhere.
    Here is the screenshot which might help you in buying the product correctly,
    You can visualize the first red box where you need to select on the drop down to make the purchase as an upgrade product or the full version of the application.
    If you have the qualifying product ( Lightroom 1.0, 2.0, 3.0, 4.0, 5.0 ), then it would cost you just $79 else $149 in case of full installer.
    Try, it might help you get over the plight of buying the product.
    Thank you so much.

  • My problem is on my Windows PC.  I am getting the error message, "The procedure entry point sqlite_3_wal_checkpoint could not be located in the dynamic link library SQLite3.dll.  I am told this is related to iTunes.  Any help?

    I use both a Mac and a PC.  My problem is on my Windows 7 PC.  I am getting the error message, "The procedure entry point sqlite_3_wal_checkpoint could not be located in the dynamic link library SQLite3.dll.  I am told this is related to iTunes.  Any help out there?  Thanks

    With Windows Explorer, navigate to your C:\Program Files\Common Files\Apple\Apple Application Support folder.
    Copy the SQLite3.dll that you should find there, navigate to the nearby Mobile Device Support folder, and Paste it in there also.
    Restart the programme all should be well
    In case that your OS is (64 bit)
    1. Open windows explorer, go to location C:\Program Files (x86)\Common Files\Apple\Apple Application Support
    2. Copy file "SQLite3.dll"
    3. Now paste it in the folder  C:\Program Files (x86)\Common Files\Apple\Mobile Device Support
    4. Restart the programme, it should not display that message, it should be clear.
    Good Luck

  • I want remove some dark spots on a hand and color it flesh color.  I'm very new to Lightroom, can anyone help me with this?  Thanks in advance for any help!

    I want remove some dark spots on a hand and color it flesh color.  I'm very new to Lightroom, can anyone help me with this?  Thanks in advance for any help!

    Have you tried the Spot Removal tool (press Q key)?
    New to Lightroom? Go here: Getting Started with Lightroom CC - YouTube
    Spot removal: Lightroom CC - Removing Dust Spots and Imperfections - YouTube

  • HT5622 hi,my name is kutan.since i updated ios7 on my ipad;internet got very slow,i can not open facetime no more,i can not download or update anything from apple store! so this is just redicilous! please any help?

    hi,my name is kutan.since i updated ios7 on my ipad;internet got very slow,i can not open facetime no more,i can not download or update anything from apple store! so this is just redicilous! please any help?

    It is hardly Apple's fault that Epson can't/won't update their driver, but at least Epson suggest that you use the Gutenprint driver, which in any case is far better that what Epson offer.
    You can get it here:
    http://gimp-print.sourceforge.net/
    You can download the latest version from here:
    http://sourceforge.net/projects/gimp-print/
    Have you downloaded the recent Apple update to Epson drivers?
    http://support.apple.com/kb/DL1398

  • Hey I have a problem. I want to change my rescue email address as somehow apple has the wrong one but I don't know my security questions - but you need one to change the other. Any help?

    hey I have a problem. I want to change my rescue email address as somehow apple has the wrong one but I don't know my security questions - but you need one to change the other. Any help?

    You can get your Security Questions reset by contacting iTunes Support at either of the two links below. Select the best options for your issue, or provide specific information. Let them know you are contacting them concerning Forgotten Security Questions. They will get back to you via your primary email address, usually within 24 hours. Once your Security Questions have been reset, you will be able to go in and reset your Rescue email address on your account:
    http://www.apple.com/support/itunes/ww/
    or by email:
    http://www.apple.com/emea/support/itunes/contact.html
    Cheers,
    GB

  • My apple ID is not recognised when I try to sign into the cloud, any help?

    My apple ID is not recognised when I try to sign into the cloud, any help?

    You can't sign into iCloud using your Apple ID on a PC, you have to sign in with an existing iCloud ID.  You have to first create your iCloud account on an iOS device or Mac.  Then you can sign in with the ID on your PC.

  • How to convert Property files into Java Objects.. help needed asap....

    Hi..
    I am currently working on Internationalization. I have created property files for the textual content and using PropertyResourceBundles. Now I want to use ListResourceBundles. So what I want to know is..
    How to convert Property files into Java Objects.. I think Orielly(in their book on Internationalization) has given an utitlity for doing this. But I did not get a chance to look into that. If anyone has come across this same issue, can you please help me and send the code sample on how to do this..
    TIA,
    CK

    Hi Mlk...
    Thanks for all your help and suggestions. I am currently working on a Utility Class that has to convert a properties file into an Object[][].
    This will be used in ListResourceBundle.
    wtfamidoing<i>[0] = currentKey ;
    wtfamidoing<i>[1] = currentValue ;I am getting a compilation error at these lines..(Syntax error)
    If you can help me.. I really appreciate that..
    TIA,
    CK

  • Converting flash into java script - please help!

    Our site uses a lot of flash text and flash images, I have
    been told by a friend of a friend that i need to change the way
    flash is embedded into java script - i only know the basics of web
    design and this is me hitting brick wall!
    Maybe someone could help point me in the right direction -
    simply! thank you in advance!!!!!!!!!!!!!!!!!!!!!!!!!!

    which version of dw do you have?
    for background info, google EOLAS activeX lawsuit
    Alan
    Adobe Community Expert, dreamweaver
    http://www.adobe.com/communities/experts/

  • My voice entered texts are being translated into Spanish...Help!

    Starting this morning, my voice entered text messages in iMessage are being translated into Spanish and I don't know how to stop it.
    Anyone?

    Solved...
    I selected a "stuck on Spanish" tag link after I posted and the answer was there.
    I must have selected the Globe icon next to the microphone and when I touch it once, it changes my keyboard to Spanish, if I touch it again, it changes into Chinese Trad.
    I held down the Globe icon and selected "English" and all is working again, but I don't like the proximity of the globe icon to the mic icon, as everytime I touch it by accident, my keyboard changes and my text gets translated into that language.....EEEEEK!
    I've been playing with lanuages and have added these foreign keyboards, I need to remove these keyboards now.

Maybe you are looking for