Hello can anybody  help me to build an interface

hello can you help me to build an interface that can work with this english to private talk converter code
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
public class Translate
public static void main(String [] args) throws IOException
if (args.length != 2)
System.err.println("usage: Translate wordmapfile textfile");
System.exit(1);
try
HashMap words = ReadHashMapFromFile(args[0]);
System.out.println(ProcessFile(words, args[1]));
catch (Exception e)
e.printStackTrace();
// static helper methods
* Reads a file into a HashMap. The file should contain lines of the format
* "key\tvalue\n"
* @returns a hashmap of the given file
@SuppressWarnings("unchecked")
private static HashMap ReadHashMapFromFile(String filename) throws FileNotFoundException, IOException
BufferedReader in = null;
HashMap map = null;
try
in = new BufferedReader(new FileReader(filename));
String line;
map = new HashMap();
while ((line = in.readLine()) != null)
String[] fields = line.split("\\t", 2);
if (fields.length != 2) continue; //just ignore "invalid" lines
map.put(fields[0], fields[1]);
finally
if(in!=null) in.close(); //may throw IOException
return(map); //returning a reference to local variable is safe in java (unlike C/C++)
* Process the given file
* @returns String contains the whole file.
private static String ProcessFile(Map words, String filename) throws FileNotFoundException, IOException
BufferedReader in = null;
StringBuffer out = null;
try
in = new BufferedReader(new FileReader(filename));
out = new StringBuffer();
String line = null;
while( (line=in.readLine()) != null )
out.append(SearchAndReplaceWordsInText(words, line)+"\n");
finally
if(in!=null) in.close(); //may throw IOException
return out.toString();
* Replaces all occurrences in text of each key in words with it's value.
* @returns String
private static String SearchAndReplaceWordsInText(Map words, String text)
Iterator it = words.keySet().iterator();
while( it.hasNext() )
String key = (String)it.next();
text = text.replaceAll("\\b"+key+"\\b", (String)words.get(key));
return text;
* @returns: s with the first letter capitalized
String capitalize(String s)
return s.substring(0,0).toUpperCase() + s.substring(1);
... here's the head of my pirate_words_map.txt
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'

hakimade wrote:
hello can you help me to build an interface that can work with this english to private talk converter codeYou might want to re-ask this question in such a way that it can be answered.
Also, when posting your code, please use code tags so that your code will retain its formatting and be readable. To do this, either use the "code" button at the top of the forum Message editor or place the tag [code] at the top of your block of code and the tag [/code] at the bottom, like so:
[code]
  // your code block goes here.
  // note the differences between the tag at the top vs the bottom.
[/code]or
{code}
  // your code block goes here.
  // note here that the tags are the same.
{code}Good luck.

Similar Messages

  • Can anybody help me to build an interface that can work with this code

    please help me to build an interface that can work with this code
    import java.util.Map;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class Translate
    public static void main(String [] args) throws IOException
    if (args.length != 2)
    System.err.println("usage: Translate wordmapfile textfile");
    System.exit(1);
    try
    HashMap words = ReadHashMapFromFile(args[0]);
    System.out.println(ProcessFile(words, args[1]));
    catch (Exception e)
    e.printStackTrace();
    // static helper methods
    * Reads a file into a HashMap. The file should contain lines of the format
    * "key\tvalue\n"
    * @returns a hashmap of the given file
    @SuppressWarnings("unchecked")
    private static HashMap ReadHashMapFromFile(String filename) throws FileNotFoundException, IOException
    BufferedReader in = null;
    HashMap map = null;
    try
    in = new BufferedReader(new FileReader(filename));
    String line;
    map = new HashMap();
    while ((line = in.readLine()) != null)
    String[] fields = line.split("
    t", 2);
    if (fields.length != 2) continue; //just ignore "invalid" lines
    map.put(fields[0], fields[1]);
    finally
    if(in!=null) in.close(); //may throw IOException
    return(map); //returning a reference to local variable is safe in java (unlike C/C++)
    * Process the given file
    * @returns String contains the whole file.
    private static String ProcessFile(Map words, String filename) throws FileNotFoundException, IOException
    BufferedReader in = null;
    StringBuffer out = null;
    try
    in = new BufferedReader(new FileReader(filename));
    out = new StringBuffer();
    String line = null;
    while( (line=in.readLine()) != null )
    out.append(SearchAndReplaceWordsInText(words, line)+"\n");
    finally
    if(in!=null) in.close(); //may throw IOException
    return out.toString();
    * Replaces all occurrences in text of each key in words with it's value.
    * @returns String
    private static String SearchAndReplaceWordsInText(Map words, String text)
    Iterator it = words.keySet().iterator();
    while( it.hasNext() )
    String key = (String)it.next();
    text = text.replaceAll("\\b"key"
    b", (String)words.get(key));
    return text;
    * @returns: s with the first letter capitalized
    String capitalize(String s)
    return s.substring(0,0).toUpperCase() + s.substring(1);
    }... here's the head of my pirate_words_map.txt
    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
    where             whar
    is                    be
    are                  be
    am                  be
    the                  th'
    you                 ye
    your                yer
    tell                be tellin'

    please help me i don t know how to go about this.my teacher ask me to build an interface that work with the code .
    Here is the interface i just build
    import java.util.Map;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.awt.*;
    import javax.swing.*;
    public class boy extends JFrame
    JTextArea englishtxt;
    JLabel head,privatetxtwords;
    JButton translateengtoprivatewords;
    Container c1;
    public boy()
            super("HAKIMADE");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setBackground(Color.white);
            setLocationRelativeTo(null);
            c1 = getContentPane();
             head = new JLabel(" English to private talk Translator");
             englishtxt = new JTextArea("Type your text here", 10,50);
             translateengtoprivatewords = new JButton("Translate");
             privatetxtwords = new JLabel();
            JPanel headlabel = new JPanel();
            headlabel.setLayout(new FlowLayout(FlowLayout.CENTER));
            headlabel.add(head);
            JPanel englishtxtpanel = new JPanel();
            englishtxtpanel.setLayout(new FlowLayout(FlowLayout.CENTER,10,40));
            englishtxtpanel.add(englishtxt);
             JPanel panel1 = new JPanel();
             panel1.setLayout(new BorderLayout());
             panel1.add(headlabel,BorderLayout.NORTH);
             panel1.add(englishtxtpanel,BorderLayout.CENTER);
            JPanel translateengtoprivatewordspanel = new JPanel();
            translateengtoprivatewordspanel.setLayout(new FlowLayout(FlowLayout.CENTER,10,40));
            translateengtoprivatewordspanel.add(translateengtoprivatewords);
             JPanel panel2 = new JPanel();
             panel2.setLayout(new BorderLayout());
             panel2.add(translateengtoprivatewordspanel,BorderLayout.NORTH);
             panel2.add(privatetxtwords,BorderLayout.CENTER);
             JPanel mainpanel = new JPanel();
             mainpanel.setLayout(new BorderLayout());
             mainpanel.add(panel1,BorderLayout.NORTH);
             mainpanel.add(panel2,BorderLayout.CENTER);
             c1.add(panel1, BorderLayout.NORTH);
             c1.add(panel2);
    public static void main(final String args[])
            boy  mp = new boy();
             mp.setVisible(true);
    }..............here is the code,please make this interface work with the code
    public class Translate
    public static void main(String [] args) throws IOException
    if (args.length != 2)
    System.err.println("usage: Translate wordmapfile textfile");
    System.exit(1);
    try
    HashMap words = ReadHashMapFromFile(args[0]);
    System.out.println(ProcessFile(words, args[1]));
    catch (Exception e)
    e.printStackTrace();
    // static helper methods
    * Reads a file into a HashMap. The file should contain lines of the format
    * "key\tvalue\n"
    * @returns a hashmap of the given file
    @SuppressWarnings("unchecked")
    private static HashMap ReadHashMapFromFile(String filename) throws FileNotFoundException, IOException
    BufferedReader in = null;
    HashMap map = null;
    try
    in = new BufferedReader(new FileReader(filename));
    String line;
    map = new HashMap();
    while ((line = in.readLine()) != null)
    String[] fields = line.split("
    t", 2);
    if (fields.length != 2) continue; //just ignore "invalid" lines
    map.put(fields[0], fields[1]);
    finally
    if(in!=null) in.close(); //may throw IOException
    return(map); //returning a reference to local variable is safe in java (unlike C/C++)
    * Process the given file
    * @returns String contains the whole file.
    private static String ProcessFile(Map words, String filename) throws FileNotFoundException, IOException
    BufferedReader in = null;
    StringBuffer out = null;
    try
    in = new BufferedReader(new FileReader(filename));
    out = new StringBuffer();
    String line = null;
    while( (line=in.readLine()) != null )
    out.append(SearchAndReplaceWordsInText(words, line)+"\n");
    finally
    if(in!=null) in.close(); //may throw IOException
    return out.toString();
    * Replaces all occurrences in text of each key in words with it's value.
    * @returns String
    private static String SearchAndReplaceWordsInText(Map words, String text)
    Iterator it = words.keySet().iterator();
    while( it.hasNext() )
    String key = (String)it.next();
    text = text.replaceAll("\\b"key"
    b", (String)words.get(key));
    return text;
    * @returns: s with the first letter capitalized
    String capitalize(String s)
    return s.substring(0,0).toUpperCase() + s.substring(1);
    }... here's the head of my pirate_words_map.txt
    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
    where             whar
    is                    be
    are                  be
    am                  be
    the                  th'
    you                 ye
    your                yer
    tell                be tellin'

  • Hello, since I actualized my Mac with Maverick it doesn't recognize any  external hard disk ,... only the one to make copy on the time machine. Can anybody help me? thank you!!!!

    hello, since I actualized my Mac with Maverick it doesn't recognize any  external hard disk ,... only the one to make copy on the time machine. Can anybody help me? thank you!!!!

    Hello Laurabcn,
    Thank you for using Apple Support Communities.
    For more information, take a look at:
    USB and FireWire Quick Assist
    http://support.apple.com/kb/ht1151
    Have a nice day,
    Mario

  • Hello friends, my itunes has stopped working. and the problem report stated the following: Fault Module Name:     KERNELBASE.dll   Fault Module Version:     6.1.7601.17514.................. please can anybody help me?hello friends, my itunes has stopped w

    Hello everybody> my itunes has stopped working and the problem report stated the following:
    Problem signature:
      Problem Event Name:    APPCRASH
      Application Name:    iTunes.exe
      Application Version:    10.5.3.3
      Application Timestamp:    4f14cc3d
      Fault Module Name:    KERNELBASE.dll
      Fault Module Version:    6.1.7601.17514
      Fault Module Timestamp:    4ce7b8f0
      Exception Code:    80000003
      Exception Offset:    0003381b
      OS Version:    6.1.7601.2.1.0.256.1
      Locale ID:    1033
      Additional Information 1:    0a9e
      Additional Information 2:    0a9e372d3b4ad19135b953a78882e789
      Additional Information 3:    0a9e
      Additional Information 4:    0a9e372d3b4ad19135b953a78882e789
    can anybody help me?

    Are you seeing a similar message when launching QuickTime Player?
    What security software is installed on the computer? Have you tried testing in an admin account or after uninstalling tthe security software?
    Use one of the following articles to guide you through removing iTunes and the related QuickTime files.
    Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP
    Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7

  • Hello, just wondering how i can fix my itunes when i keep getting these msges, MSVCR80.dll was not found and error 7 (windows error 126). can anybody help. cheers.

    hello, just wondering how i can fix my itunes when i keep getting these msges, MSVCR80.dll was not found and error 7 (windows error 126). can anybody help. cheers.

    See Troubleshooting issues with iTunes for Windows updates.
    tt2

  • Hello. I am having trouble using Mobileme with microsoft oulook 2010. .The error Mobileme has stopped working . Can anybody help. ??Thanks

    Hello
    I am having trouble using Microsoft Outlook 2010. When starting Microsoft Outlook displays the error message Mobileme has stopped working. Can anybody help.
    Thanks

    Well yes, of course you are having trouble using MobileMe because MobileMe no longer exists and has not existed for the last 2 years at least.
    MobileMe has been replaced by iCloud, so you will never be able to use MobileMe because it does not exist.
    Also, I would suggest that you look more closely before you post, because you have posted this in an iPhone forum and this question has nothing to do with iPhones.  You would get more help if you posted in the correct forum.

  • Hi all! I was updating the software on i pad to ios6, update was interrupted(apple update server is unavailable...). iTunes Diagnostics shows that "secure link to I tunes store failed". I use Windows 7 Home Premium 64 bit. Can anybody help please?

    Hi all! I was updating the software on i pad to ios6, update was interrupted(apple update server is unavailable...). iTunes Diagnostics shows that "secure link to I tunes store failed". I use Windows 7 Home Premium 64 bit. Can anybody help please?
    The following was done so far:
    1. Windows Firewall - new rule created for itunes.
    2. iTunes - latest version installed.
    3. LAN setting : automatic detection of proxy is enabled;
    4. iTunes diagnostics shows:
    Microsoft Windows 7 x64 Home Premium Edition (Build 7600)
    TOSHIBA Satellite L655
    iTunes 11.0.2.26
    QuickTime 7.7.3
    FairPlay 2.3.31
    Apple Application Support 2.3.3
    iPod Updater Library 10.0d2
    CD Driver 2.2.3.0
    CD Driver DLL 2.1.3.1
    Apple Mobile Device 6.1.0.13
    Apple Mobile Device Driver 1.64.0.0
    Bonjour 3.0.0.10 (333.10)
    Gracenote SDK 1.9.6.502
    Gracenote MusicID 1.9.6.115
    Gracenote Submit 1.9.6.143
    Gracenote DSP 1.9.6.45
    iTunes Serial Number 003FB880034B7720
    Current user is not an administrator.
    The current local date and time is 2013-04-23 11:01:14.
    iTunes is not running in safe mode.
    WebKit accelerated compositing is enabled.
    HDCP is supported.
    Core Media is supported.
    Video Display Information
    Intel Corporation, Intel(R) HD Graphics
    **** External Plug-ins Information ****
    No external plug-ins installed.
    iPodService 11.0.2.26 (x64) is currently running.
    iTunesHelper 11.0.2.26 is currently running.
    Apple Mobile Device service 3.3.0.0 is currently running.
    **** Network Connectivity Tests ****
    Network Adapter Information
    Adapter Name:          {1CB5BBC2-8124-4664-899A-CE0A4683E3B4}
    Description:          Realtek RTL8188CE Wireless LAN 802.11n PCI-E NIC
    IP Address:          0.0.0.0
    Subnet Mask:          0.0.0.0
    Default Gateway:          0.0.0.0
    DHCP Enabled:          Yes
    DHCP Server:
    Lease Obtained:          Thu Jan 01 08:00:00 1970
    Lease Expires:          Thu Jan 01 08:00:00 1970
    DNS Servers:
    Adapter Name:          {8140112A-43D0-41D6-8B36-BE146C811173}
    Description:          Atheros AR8152/8158 PCI-E Fast Ethernet Controller (NDIS 6.20)
    IP Address:          10.5.7.196
    Subnet Mask:          255.255.0.0
    Default Gateway:          10.5.0.1
    DHCP Enabled:          Yes
    DHCP Server:          172.18.255.2
    Lease Obtained:          Tue Apr 23 10:14:40 2013
    Lease Expires:          Tue Apr 23 22:14:40 2013
    DNS Servers:          121.97.59.7
                        121.97.59.2
                        121.97.59.3
    Active Connection:          LAN Connection
    Connected:          Yes
    Online:                    Yes
    Using Modem:          No
    Using LAN:          Yes
    Using Proxy:          No
    Firewall Information
    Windows Firewall is on.
    iTunes is NOT enabled in Windows Firewall.
    Connection attempt to Apple web site was successful.
    Connection attempt to browsing iTunes Store was unsuccessful.
    The network connection timed out.
    Connection attempt to purchasing from iTunes Store was successful.
    Connection attempt to iPhone activation server was successful.
    Connection attempt to firmware update server was unsuccessful.
    The network connection timed out.
    Connection attempt to Gracenote server was successful.
    The network connection timed out.
    Last successful iTunes Store access was 2013-03-22 10:05:31.
    @@@. iTunes IS ENABLED THROUGH THE FIREWALL , even though diagnostics says "NOT enabled"

    hours after the first post i somehow got this to work. dont know how, but i do tried the dns clear cache, the clear host file, oh and i did the check automatically detech dns AND THEN se-check it again before i got this to work.

  • I recently upgraded to mac os x lion. But now my broadband pen doesn't work. I'm portuguese and i use the vodafone network. Can anybody help me?

    Hello.
    My name is Margarido and i'm portuguese. I use a mobile operator named zon to access the web using a broadband pen modem.
    This operator uses the vodafone technical support (network) and since i upgraded to the Mac OS X Lion, the pen modem doesn´t work.
    Can anybody help me?
    I eared that Mac OS X Lion doesn´t support pen modems yet. Is this true?
    Thank you.

    Your best bet is to call the Vodafone technical support helpline. Since each manufacturer writes custom software for each OS. They might be working on new drivers...

  • My iMessage is not working, can anybody help?

    My iMessage has not been working since last Thursday. i have tried all 'resets' and it still is not working. can anybody help? is anybody having the same problem?

    Hello, hollieaj. 
    Thank you for visiting Apple Support Communities.
    I would recommend going through the troubleshooting steps in the article below.
    iOS: Troubleshooting Messages
    http://support.apple.com/kb/ts2755
    Cheers,
    Jason H.

  • I can't sign into iTunes on this pc so I can authorize it. I wan't to do this so I can transfer purchased iTunes music on my iPad mini to this pc. When I try to do this the response I get is just to try again later. Can anybody help me with this?

    I can't seem to sign into iTunes on this pc so that I can authorize it. I want to do this so I can transfer purchased iTunes music on my iPad mini to this pc. The response I keep getting is to try again later but its been days so I don't think that is the problem. I know I am using the correct user name and password so I don't know what's wrong. Can anybody help me with this?

    Hello
    It seems as though your account has been hacked.
    please contact Skype customer service and change your password.
    TIME ZONE - US EASTERN. LOCATION - PHILADELPHIA, PA, USA.
    I recommend that you always run the latest Skype version: Windows & Mac
    If my advice helped to fix your issue please mark it as a solution to help others.
    Please note that I generally don't respond to unsolicited Private Messages. Thank you.

  • I've just downloaded a sd movie from iTunes with my ipad but the movie will only play for 13s then a msg comes up saying "could not load video! I've paid for it and downloaded the whole thing ! Can anybody help me pls?

    I've just downloaded a sd movie from iTunes with my ipad but the movie will only play for 13s then a msg comes up saying "could not load video! I've paid for it and downloaded the whole thing ! Can anybody help me pls?

    Hello Lcw2610,
    I would recommend deleting the affected movie from your iPad, and redownloading the movie.
    How to delete content you've downloaded from the iTunes Store, App Store, iBooks Store, or Mac App Store
    http://support.apple.com/kb/HT5772
    Download past purchases
    http://support.apple.com/kb/HT2519
    If the issue persists, please do report the issue to the folks in our iTunes Store.
    To report an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase, follow these steps:
    Find the email receipt for your purchase.
    Click Report a Problem under the app that is having the issue.
    When prompted, enter the Apple ID and password you used to purchase the item, then click Report a Problem.
    Click Report a Problem next to the item you are having an issue with.
    From the Choose Problem dropdown menu, choose the appropriate issue.
    Follow the onscreen instructions and—if prompted—type a description of the problem into the text field.
    Click Submit to have your issue reviewed.
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase
    http://support.apple.com/kb/HT1933
    Cheers,
    Allen

  • About three days ago my ipod said i needed to sync and so i did . when i did it stop working and the wifi is grey out and says no wifi . Ive tried rebooting it , reseting , restarting but nothing seems to work . Can anybody help me ? Please !

    About three days ago my ipod said i needed to sync and so i did . when i did it stop working and the wifi is grey out and says no wifi . Ive tried rebooting it , reseting , restarting but nothing seems to work . Can anybody help me ? Please !

    Hello Philly,
    I believe that when you reset your ipod(command given from the computer, right?)  touch WHILE the ipod was updating, It cleared the system in the middle of writing files, thus corrupting(equivalent of cutting of in the middle of a sentence) the basic running system.
    I suggest you go to an apple store and ask for a technical diagonosis in person. they may offer to help if the problem is fixable. If your ipod is still under warrenty, i would guess it would be free/low cost.
    ~Remember, I am just giving an educated guess on limited information

  • I urgently need a contact email for the sales team can anybody help me with this

    I urgently need a contact email for the sales team regarding an outstanding query, can anybody help me with this please? Thanks in advance.

    Hello 
    Welcome to the EE Community! I'm afraid there isn't an e-mail you can contact the EE Mobile Sales team on, but here's how you can get in touch with them:
    If you're on Twitter, you can tweet them @EE, however If you'd prefer to talk to someone, you can dial:
    150 from your EE mobile phone
    If you're ringing from another phone, it's 01707 315000
    For handy text codes & more, check out this page: http://ee.co.uk/help/get-in-touch Cheers,
    Titanium
    Was my post helpful? Please take 2 seconds to hit the 'Kudos' button below

  • I want to create a page of Avery sticky labels. Can anybody help please?

    I want to create a page of Avery sticky labels. Can anybody help please?
    Can somebody help with the above heading please?

    Hello Klaus 1
    I'm very new to iMac having switch for a PC and Word.  I cant see label download for Mac. I may be doing this all wrong. Do I use "Pages" to print from? Is there an Avery label option? I can't see one but I'm being so new to Mac I'm not getting around too easily yet.
    Thanks,
    Andy

  • Hi, can anybody help my to find those new programs which was showing on the homepage: i message dictation a o

    Hello?
    Can anybody help me use lion?
    i dont find those new programs from the homepage i message and others.

    If your system is only 4 months old than you already had Lion.  Contact support and tell them you thought it was Mountain Lion and ask for a refund.
    http://www.apple.com/support/mac/app-store/contact.html?form=account&topic=Mac%2 0App%20Store%20Account%20and%20Billing

Maybe you are looking for

  • Attachment Types in Forms

    We have an Attachment Type in F&P . Is there a way to control the list of Attachment types? Where is this setting done? Also can this be controlled based on forms? For example Separation I need 3 attachment and Personal Data another set of attachment

  • How to refer the unlimited key length JCE jar files.

    Hi All, The JDK 1.4.2_10 contains the local_policy.jar and US_export_policy.jar that do not permit an unlimited Key length( 64 bit). - So I downloaded the unlimited ( Java(TM) Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files

  • EPUB Split Document -- minor bug

    Hi, Let's say you've selected some text. You create a new paragraph style based on the formatting of that text. You click the "Split Document" checkbox in the para style definitions dialog. Then you click okay to go ahead and create the style. If you

  • Change of sim

    I have put a CoverMore Global sim card in my Blackberry Torch and it will not connect to the internet. OK if I switch on WiFi but not through Optus the provider.

  • Hi. the email application has been removed from my ipad. I don't have back up so how can I get it back?

    Hi. the email application has been removed from my ipad. I don't have back up so how can I get it back?