cool hit counter So there's this way of remembering words_Java version of remembering irregular verbs_blogger recommendation_Intefrankly

So there's this way of remembering words_Java version of remembering irregular verbs_blogger recommendation


Yesterday, while reading an English book on irregular verbs, I was suddenly inspired: I wanted to take such a simple way of remembering words, implement it in program code, and then, make it possible for the user to interact with it

This will make it easy for the user to memorize the irregular verb as they memorize it. Based on that, so I thought about it, drew diagrams, and rationalized my thoughts. Then it was time to get cracking.

Now basically formed, you can also meet with you.

Let's look at some screenshots first, so it's a little more straightforward

Project structure.

Effect map:

The user can enter the command.

"all" : output house have Information on the irregular verbs of

"pronunciation" : pronunciation of words, This command is a pronunciation switch, If you continuously enter, The effect, on the other hand be: open, shut, open, shut...

"exit" : Exit the system

other: If the user input is not in the library have, The system, in turn, will for Come up with some links want The vocabulary for users option, as if:"drea", conjunction with option of be "dream"

If the user input is in the library, as if:"dream", The system will output"dream" Details of the, This allows the user to easily interact with the system, And in this one

process to get the words down.

After seeing the results, I think we all basically understand what this applet does and how it works!

=================================================

Source Code

Description:

User input some commands in the console,then the system will receive the command

and process it, and display the result to user.

e.g:

ONE : When user input the command "all", then the system will display all irregular verbs.

TWO : When user input the command "pronunciation", then the system will change the status of the pronunciation.

THREE : When user input the a irregular verb, then the system will diplay the detial of the word.

=================================================

/IrregularVerbs/src/com/b510/irregularverbs/client/Client.java

  1 /**
  2  * 
  3  */
  4 package com.b510.irregularverbs.client;
  5 
  6 import java.util.Scanner;
  7 
  8 import com.b510.irregularverbs.utils.CommonUtil;
  9 import com.b510.irregularverbs.utils.IrregularVerbUtil;
 10 import com.b510.irregularverbs.utils.PrintUtil;
 11 
 12 /**
 13  * User input some commands in the console,then the system will receive<br> 
 14  * the command and process it, and display the result to user.<br>
 15  * for example: 
 16  * <li>all : show the all of the Irregular Verbs</li>
 17  * <li>pronunciation : the switch of the pronunciation.and the system default status<br>
 18  *     is not pronunciation.</li>
 19  * <li>The Irregular Verbs : user input the irregular verb,for example: "swim", "cost", "became".etc.</li>
 20  * @author Hongten
 21  * @created Feb 27, 2014
 22  */
 23 public class Client {
 24 
 25     private Scanner inputStreamScanner;
 26     private boolean controlFlag = false;
 27 
 28     public static void main(String[] args) {
 29         Client client = new Client();
 30         client.listenConsoleAndHandleContent();
 31     }
 32 
 33     public Client() {
 34         inputStreamScanner = new Scanner(System.in);
 35     }
 36 
 37     /**
 38      * Listen to the console and handle the content,what user inputed.
 39      */
 40     public void listenConsoleAndHandleContent() {
 41         PrintUtil.printInfo(CommonUtil.DESCRIPTION);
 42         try {
 43             while (!controlFlag && inputStreamScanner.hasNext()) {
 44                 processingConsoleInput();
 45             }
 46         } catch (Exception e) {
 47             e.printStackTrace();
 48         } finally {
 49             closeScanner();
 50         }
 51     }
 52 
 53     /**
 54      * The system receive the content, and process it.
 55      */
 56     private void processingConsoleInput() {
 57         String inputContent = inputStreamScanner.nextLine();
 58         if (!inputContent.isEmpty()) {
 59             if (pronounce(inputContent)) {
 60                 IrregularVerbUtil.reLoadVerbs();
 61             } else {
 62                 if (showAll(inputContent)) {
 63                     return;
 64                 }
 65                 controlFlag = exit(inputContent);
 66                 if (!controlFlag) {
 67                     notExit(inputContent);
 68                 }
 69             }
 70         }
 71     }
 72 
 73     /**
 74      * When user input the command "all"(ignore case),the system will handle the command "all",<br>
 75      * and display the all of the irregular verbs.
 76      * @param inputContent the command "all"(ignore case)
 77      * @return true, if user input the command "all"(ignore case);return false,if user input other command.
 78      */
 79     private boolean showAll(String inputContent) {
 80         if (CommonUtil.ALL.equalsIgnoreCase(inputContent)) {
 81             IrregularVerbUtil.showAll();
 82             return true;
 83         } else {
 84             return false;
 85         }
 86     }
 87 
 88     /**
 89      * When user input the command "pronunciation"(ignore case), the system will handle the command "pronunciation",<br>
 90      * and reload all of the irregular verbs. and display the message "After loading vocabulary!".
 91      * @param inputContent the command "pronunciation"(ignore case)
 92      * @return true, if user input the command "pronunciation"(ignore case);return false, if user input other command.
 93      */
 94     private boolean pronounce(String inputContent) {
 95         if (CommonUtil.PRONUNCIATION.equalsIgnoreCase(inputContent)) {
 96             IrregularVerbUtil.proFlag = !IrregularVerbUtil.proFlag;
 97             return true;
 98         } else {
 99             return false;
100         }
101     }
102 
103     private void notExit(String inputContent) {
104         IrregularVerbUtil verbsLib = IrregularVerbUtil.getInstance();
105         verbsLib.match(inputContent);
106     }
107 
108     private boolean exit(String inputContent) {
109         if (CommonUtil.EXIT.equalsIgnoreCase(inputContent)) {
110             controlFlag = true;
111             systemExit();
112         }
113         return controlFlag;
114     }
115 
116     private void systemExit() {
117         System.out.println(CommonUtil.EXIT_SYSTEM);
118         System.exit(0);
119     }
120 
121     private void closeScanner() {
122         inputStreamScanner.close();
123     }
124 }

/IrregularVerbs/src/com/b510/irregularverbs/lib/VocabularyLib.java

  1 /**
  2  * 
  3  */
  4 package com.b510.irregularverbs.lib;
  5 
  6 import java.util.HashMap;
  7 import java.util.Iterator;
  8 import java.util.List;
  9 import java.util.Map;
 10 
 11 import com.b510.irregularverbs.utils.CommonUtil;
 12 import com.b510.irregularverbs.utils.IrregularVerbUtil;
 13 import com.b510.irregularverbs.vo.IrregularVerbsVO;
 14 
 15 /**
 16  * Library for the irregular verbs.
 17  * @author Hongten
 18  * @created Feb 28, 2014
 19  */
 20 public class VocabularyLib {
 21     
 22     /**
 23      * Load all of the irregular verbs.<br>
 24      * There have FOUR types of the irregular verbs : "AAA", "ABA", "ABB", "ABC".<br>
 25      * so,there are FOUR methods to load all irregular verbs.
 26      * @return all of the irregular verbs.
 27      */
 28     public static List<IrregularVerbsVO> getVocabularyLib() {
 29         formatAAA();
 30         formatABA();
 31         formatABB();
 32         formatABC();
 33         return IrregularVerbUtil.verbs;
 34     }
 35     
 36     /**
 37      * The "AAA" format for irregular verbs.
 38      * 
 39      * @return
 40      */
 41     private static List<IrregularVerbsVO> formatAAA() {
 42         Map<String, String> aaaTypemap = libAAA();
 43         Iterator<String> it = aaaTypemap.keySet().iterator();
 44         while (it.hasNext()) {
 45             handleAAA(aaaTypemap, it);
 46         }
 47         return IrregularVerbUtil.verbs;
 48     }
 49 
 50     /**
 51      * @param aaaTypemap
 52      * @param it
 53      */
 54     private static void handleAAA(Map<String, String> aaaTypemap, Iterator<String> it) {
 55         String key = it.next();
 56         if (IrregularVerbUtil.proFlag) {
 57             IrregularVerbUtil.verbs.add(new IrregularVerbsVO(key, key, key, aaaTypemap.get(key)));
 58         } else {
 59             IrregularVerbUtil.verbs.add(new IrregularVerbsVO(key, key, key, aaaTypemap.get(key)));
 60         }
 61     }
 62 
 63     /**
 64      * The "ABA" format for irregular verbs
 65      * 
 66      * @return
 67      */
 68     private static List<IrregularVerbsVO> formatABA() {
 69         Map<String, String> abaTypemap = libABA();
 70         Iterator<String> it = abaTypemap.keySet().iterator();
 71         while (it.hasNext()) {
 72             handleABA(abaTypemap, it);
 73         }
 74         return IrregularVerbUtil.verbs;
 75     }
 76 
 77     /**
 78      * @param abaTypemap
 79      * @param it
 80      */
 81     private static void handleABA(Map<String, String> abaTypemap, Iterator<String> it) {
 82         String key = it.next();
 83         String[] keys = key.split(CommonUtil.COMMA);
 84         if (IrregularVerbUtil.proFlag) {
 85             IrregularVerbUtil.verbs.add(new IrregularVerbsVO(keys[0] + CommonUtil.COMMA + keys[1], keys[2] + CommonUtil.COMMA + keys[3], keys[0] + CommonUtil.COMMA + keys[1], abaTypemap
 86                     .get(key)));
 87         } else {
 88             IrregularVerbUtil.verbs.add(new IrregularVerbsVO(keys[0], keys[1], keys[0], abaTypemap.get(key)));
 89         }
 90     }
 91 
 92     /**
 93      * The "ABB" format for irregular verbs
 94      * 
 95      * @return
 96      */
 97     private static List<IrregularVerbsVO> formatABB() {
 98         Map<String, String> abbTypemap = libABB();
 99         Iterator<String> it = abbTypemap.keySet().iterator();
100         while (it.hasNext()) {
101             handleABB(abbTypemap, it);
102         }
103         return IrregularVerbUtil.verbs;
104     }
105 
106     /**
107      * @param abbTypemap
108      * @param it
109      */
110     private static void handleABB(Map<String, String> abbTypemap, Iterator<String> it) {
111         String key = it.next();
112         String[] keys = key.split(CommonUtil.COMMA);
113         if (IrregularVerbUtil.proFlag) {
114             IrregularVerbUtil.verbs.add(new IrregularVerbsVO(keys[0] + CommonUtil.COMMA + keys[1], keys[2] + CommonUtil.COMMA + keys[3], keys[2] + CommonUtil.COMMA + keys[3],
115                     abbTypemap.get(key)));
116         } else {
117             IrregularVerbUtil.verbs.add(new IrregularVerbsVO(keys[0], keys[1], keys[1], abbTypemap.get(key)));
118         }
119     }
120 
121     /**
122      * The "ABC" format for irregular verbs
123      * 
124      * @return
125      */
126     private static List<IrregularVerbsVO> formatABC() {
127         Map<String, String> abaTypemap = libABC();
128         Iterator<String> it = abaTypemap.keySet().iterator();
129         while (it.hasNext()) {
130             handleABC(abaTypemap, it);
131         }
132         return IrregularVerbUtil.verbs;
133     }
134 
135     /**
136      * @param abaTypemap
137      * @param it
138      */
139     private static void handleABC(Map<String, String> abaTypemap, Iterator<String> it) {
140         String key = it.next();
141         String[] keys = key.split(CommonUtil.COMMA);
142         if (IrregularVerbUtil.proFlag) {
143             IrregularVerbUtil.verbs.add(new IrregularVerbsVO(keys[0] + CommonUtil.COMMA + keys[1], keys[2] + CommonUtil.COMMA + keys[3], keys[4] + CommonUtil.COMMA + keys[5], abaTypemap
144                     .get(key)));
145         } else {
146             IrregularVerbUtil.verbs.add(new IrregularVerbsVO(keys[0], keys[1], keys[2], abaTypemap.get(key)));
147         }
148     }
149     
150     //============================================
151     // Library for all of the irregular verbs
152     //============================================
153     /**
154      * Library for "AAA" type.
155      * @return
156      */
157     private static Map<String, String> libAAA() {
158         Map<String, String> aaaTypemap = new HashMap<String, String>();
159         aaaTypemap.put(IrregularVerbUtil.proFlag ? "cost,[kɔst]" : "cost", " expense");
160         aaaTypemap.put(IrregularVerbUtil.proFlag ? "cut,[kʌt]" : "cut", " cut, cut");
161         aaaTypemap.put(IrregularVerbUtil.proFlag ? "hurt,[hə:t]" : "hurt", " injure");
162         aaaTypemap.put(IrregularVerbUtil.proFlag ? "hit,[hit]" : "hit", " fight, bump into");
163         aaaTypemap.put(IrregularVerbUtil.proFlag ? "let,[let]" : "let", " permit");
164         aaaTypemap.put(IrregularVerbUtil.proFlag ? "put,[put]" : "put", " put down");
165         aaaTypemap.put(IrregularVerbUtil.proFlag ? "read,[ri:d]" : "read", " read");
166         aaaTypemap.put(IrregularVerbUtil.proFlag ? "set,[set]" : "set", " arrangements, resettlement");
167         aaaTypemap.put(IrregularVerbUtil.proFlag ? "spread,[spred]" : "spread", " be in full swing, propagate, smear");
168         aaaTypemap.put(IrregularVerbUtil.proFlag ? "spit,[spit]" : "spit", " spit");
169         aaaTypemap.put(IrregularVerbUtil.proFlag ? "shut,[ʃʌt]" : "shut", " close (a door),  shut, close down");
170         return aaaTypemap;
171     }
172     
173     /**
174      * Library for "ABA" type.
175      * @return
176      */
177     private static Map<String, String> libABA() {
178         Map<String, String> abaTypemap = new HashMap<String, String>();
179         abaTypemap.put(IrregularVerbUtil.proFlag ? "become,[bi'kʌm],became,[bi'keim]" : "become,became", " change");
180         abaTypemap.put(IrregularVerbUtil.proFlag ? "come,[kʌm],came,[keim]" : "come,came", " come round");
181         abaTypemap.put(IrregularVerbUtil.proFlag ? "run,[rʌn],ran,[ræn]" : "run,ran", " (of a gas or liquid) leak or evaporate");
182         return abaTypemap;
183     }
184     
185     /**
186      * Library for "ABB" type.
187      * @return
188      */
189     private static Map<String, String> libABB() {
190         Map<String, String> abbTypemap = new HashMap<String, String>();
191         abbTypemap.put(IrregularVerbUtil.proFlag ? "burn,[bə:n],burnt,[bə:nt]" : "burn,burnt", " ignite");
192         abbTypemap.put(IrregularVerbUtil.proFlag ? "deal,[di:l],dealt,[delt]" : "deal,dealt", " settle (a dispute)");
193         abbTypemap.put(IrregularVerbUtil.proFlag ? "dream,[dri:m],dreamed,[dremt]" : "dream,dreamed", " dreaming");
194         abbTypemap.put(IrregularVerbUtil.proFlag ? "dream,[dri:m],dreamt,[dremt]" : "dream,dreamt", " dreaming");
195         abbTypemap.put(IrregularVerbUtil.proFlag ? "hear,[hiə],heard,[hə:d]" : "hear,heard", " hear");
196         abbTypemap.put(IrregularVerbUtil.proFlag ? "hang,['hæŋ],hanged,[]" : "hang,hanged", " hanged, suspension (cable car)");
197         abbTypemap.put(IrregularVerbUtil.proFlag ? "hang,['hæŋ],hung,[hʌŋ]" : "hang,hung", " hanged, suspension (cable car)");
198         abbTypemap.put(IrregularVerbUtil.proFlag ? "learn,[lə:n],learned,[]" : "learn,learned", " do");
199         abbTypemap.put(IrregularVerbUtil.proFlag ? "learn,[lə:n],learnt,[lə:nt]" : "learn,learnt", " do");
200         abbTypemap.put(IrregularVerbUtil.proFlag ? "light,['lait],lit,[lit]" : "light,lit", " set on fire,  illuminate");
201         abbTypemap.put(IrregularVerbUtil.proFlag ? "light,['lait],lighted,[]" : "light,lighted", " set on fire,  illuminate");
202         abbTypemap.put(IrregularVerbUtil.proFlag ? "mean,[mi:n],meant,[ment]" : "mean,meant", " meaning");
203         abbTypemap.put(IrregularVerbUtil.proFlag ? "prove,[pru:v],proved,[]" : "prove,proved", " certificate,  confirm (sth to be true), tests");
204         abbTypemap.put(IrregularVerbUtil.proFlag ? "shine,[ʃain],shone,[ʃəun]" : "shine,shone", " illuminate, luminate");
205         abbTypemap.put(IrregularVerbUtil.proFlag ? "shine,[ʃain],shined,[]" : "shine,shined", " illuminate, luminate");
206         abbTypemap.put(IrregularVerbUtil.proFlag ? "show,[ʃəu],showed,[]" : "show,showed", " showcase,  for... watch");
207         abbTypemap.put(IrregularVerbUtil.proFlag ? "smell,[smel],smelled,[]" : "smell,smelled", " famous,  smell");
208         abbTypemap.put(IrregularVerbUtil.proFlag ? "smell,[smel],smelt,[smelt]" : "smell,smelt", " famous,  smell");
209         abbTypemap.put(IrregularVerbUtil.proFlag ? "speed,[spi:d],sped,[sped]" : "speed,sped", " acceleration");
210         abbTypemap.put(IrregularVerbUtil.proFlag ? "speed,[spi:d],speeded,[]" : "speed,speeded", " acceleration");
211         abbTypemap.put(IrregularVerbUtil.proFlag ? "spell,[spel],spelled,[]" : "spell,spelled", " transliterate");
212         abbTypemap.put(IrregularVerbUtil.proFlag ? "spell,[spel],spelt,[spelt]" : "spell,spelt", " transliterate");
213         abbTypemap.put(IrregularVerbUtil.proFlag ? "wake,[weik],waked,[]" : "wake,waked", " wake up, wake sb. up,  fire");
214         abbTypemap.put(IrregularVerbUtil.proFlag ? "wake,[weik],woke,[wəuk]" : "wake,woken", " wake up, wake sb. up,  fire");
215         abbTypemap.put(IrregularVerbUtil.proFlag ? "build,[bild],built,[bilt]" : "build,built", " construct");
216         abbTypemap.put(IrregularVerbUtil.proFlag ? "lend,[lend],lent,[lent]" : "lend,lent", " lend to sb");
217         abbTypemap.put(IrregularVerbUtil.proFlag ? "rebuild,[ri:'bild],rebuilt,[ri:'bilt]" : "rebuild,rebuilt", " rebuild,  rebuild");
218         abbTypemap.put(IrregularVerbUtil.proFlag ? "send,[send],sent,[sent]" : "send,sent", " give (as a present)");
219         abbTypemap.put(IrregularVerbUtil.proFlag ? "spend,[spend],spent,[spent]" : "spend,spent", " expense");
220         abbTypemap.put(IrregularVerbUtil.proFlag ? "bring,[briŋ],brought,[brɔ:t]" : "bring,brought", " bring about");
221         abbTypemap.put(IrregularVerbUtil.proFlag ? "buy,[bai],bought,[bɔ:t]" : "buy,bought", " purchase");
222         abbTypemap.put(IrregularVerbUtil.proFlag ? "fight,[fait],fought,[fɔ:t]" : "fight,fought", " scuffle");
223         abbTypemap.put(IrregularVerbUtil.proFlag ? "think,[θiŋk],thought,[θɔ:t]    " : "think,though", " reflect on, want");
224         abbTypemap.put(IrregularVerbUtil.proFlag ? "catch,[kætʃ],caught,[kɔ:t]" : "catch,caught", " capture, grab");
225         abbTypemap.put(IrregularVerbUtil.proFlag ? "teach,[ti:tʃ],taught,[tɔ:t]" : "teach,taught", " religion");
226         abbTypemap.put(IrregularVerbUtil.proFlag ? "dig,[diɡ],dug,[dʌɡ]" : "dig,dug", " dig( earth),  excavate( holes、 ditch)");
227         abbTypemap.put(IrregularVerbUtil.proFlag ? "feed,[fi:d],fed,[fed]" : "feed,fed", " feed (an animal, baby, invalid etc)");
228         abbTypemap.put(IrregularVerbUtil.proFlag ? "find,[faind],found,[]" : "find,found", " find that, find");
229         abbTypemap.put(IrregularVerbUtil.proFlag ? "get,[ɡet],got,[ɡɔt]" : "get,got", " get");
230         abbTypemap.put(IrregularVerbUtil.proFlag ? "hold,[həuld],held,[held]" : "hold,held", " own, hold, backing");
231         abbTypemap.put(IrregularVerbUtil.proFlag ? "lead,[li:d],led,[led]" : "lead,led", " lead (around),  conduct,  leading");
232         abbTypemap.put(IrregularVerbUtil.proFlag ? "meet,[mi:t],met,[met]" : "meet,met", " meet");
233         abbTypemap.put(IrregularVerbUtil.proFlag ? "sit,[sit],sat,[sæt]" : "sit,sat", " sit");
234         abbTypemap.put(IrregularVerbUtil.proFlag ? "shoot,[ʃu:t],shot,[ʃɔt]" : "shoot,shot", " shot");
235         abbTypemap.put(IrregularVerbUtil.proFlag ? "spit,[spit],spit,[]" : "spit,spit", " spit");
236         abbTypemap.put(IrregularVerbUtil.proFlag ? "spit,[spit],spat,[spæt]" : "spit,spat", " spit");
237         abbTypemap.put(IrregularVerbUtil.proFlag ? "stick,[stik],stuck,[stʌk]" : "stick,stuck", " plug in (an electronic device),  spike,  stick");
238         abbTypemap.put(IrregularVerbUtil.proFlag ? "win,[win],won,[wʌn]" : "win,won", " profit");
239         abbTypemap.put(IrregularVerbUtil.proFlag ? "feel,['fi:l],felt,[felt]" : "feel,felt", " have the feeling that");
240         abbTypemap.put(IrregularVerbUtil.proFlag ? "keep,[ki:p],kept,[kept]" : "keep,kept", " maintain");
241         abbTypemap.put(IrregularVerbUtil.proFlag ? "leave,[li:v],left,[left]" : "leave,left", " leave");
242         abbTypemap.put(IrregularVerbUtil.proFlag ? "sleep,[sli:p],slept,[slept]" : "sleep,slept", " sleep on");
243         abbTypemap.put(IrregularVerbUtil.proFlag ? "sweep,[swi:p],swept,[swept]" : "sweep,swept", " broom");
244         abbTypemap.put(IrregularVerbUtil.proFlag ? "lay,[lei],laid,[leid]" : "lay,laid", " lay eggs,  place");
245         abbTypemap.put(IrregularVerbUtil.proFlag ? "pay,[pei],paid,[peid]" : "pay,paid", " hand over to");
246         abbTypemap.put(IrregularVerbUtil.proFlag ? "say,[sei],said,[sed]" : "say,said", " talk");
247         abbTypemap.put(IrregularVerbUtil.proFlag ? "stand,[stænd],stood,[stud]" : "stand,stood", " stand");
248         abbTypemap.put(IrregularVerbUtil.proFlag ? "understand,[],understood,[ʌndə'stænd]" : "understand,understood", " understand");
249         abbTypemap.put(IrregularVerbUtil.proFlag ? "lose,[lu:z],lost,[lɔst]" : "lose,lost", " lost");
250         abbTypemap.put(IrregularVerbUtil.proFlag ? "have,[həv],had,[hæd]" : "have,had", " have");
251         abbTypemap.put(IrregularVerbUtil.proFlag ? "make,[meik],made,[meid]" : "make,made", " manufactures");
252         abbTypemap.put(IrregularVerbUtil.proFlag ? "sell,[sel],sold,[səuld]" : "sell,sold", " betray");
253         abbTypemap.put(IrregularVerbUtil.proFlag ? "tell,[tel],told,[təuld]" : "tell,told", " let know");
254         abbTypemap.put(IrregularVerbUtil.proFlag ? "retell,[ri:'tel],retold,[ri:'təuld]" : "retell,retold", " re-tell, repeatable, retell");
255         return abbTypemap;
256     }
257     
258     
259 
260     /**
261      * Library for "ABC" type.
262      * @return
263      */
264     private static Map<String, String> libABC() {
265         Map<String, String> abaTypemap = new HashMap<String, String>();
266         abaTypemap.put(IrregularVerbUtil.proFlag ? "blow,[bləu],blew,[blu:],blown,[]" : "blow,blew,blown", " blow");
267         abaTypemap.put(IrregularVerbUtil.proFlag ? "drive,[draiv],drove,[drəuv],driven,[drivən]" : "drive,drove,driven", " drive");
268         abaTypemap.put(IrregularVerbUtil.proFlag ? "draw,[drɔ:],drew,[dru:],drawn,[drɔ:n]" : "draw,drew,drawn", " paint");
269         abaTypemap.put(IrregularVerbUtil.proFlag ? "eat,[i:t],ate,[eit],eaten,['i:tən]" : "eat,ate,eaten", " eat");
270         abaTypemap.put(IrregularVerbUtil.proFlag ? "fall,[fɔ:l],Fell,[fel],fallen,['fɔ:lən]" : "fall,fell,fallen", " drop");
271         abaTypemap.put(IrregularVerbUtil.proFlag ? "give,[ɡiv],gave,[ɡeiv],given,['ɡivən]" : "give,gave,given", " for");
272         abaTypemap.put(IrregularVerbUtil.proFlag ? "get,[ɡet],got,[ɡɔt],gotten,['ɡɔtən]" : "get,got,gotten", " get");
273         abaTypemap.put(IrregularVerbUtil.proFlag ? "show,[ʃəu],showed,[],shown,['ʃəun]" : "show,showed,shown", " showcase,  for... watch");
274         abaTypemap.put(IrregularVerbUtil.proFlag ? "fall,[fɔ:l],Fell,[fel],fallen,['fɔ:lən]" : "prove,proved,proven", " certificate,  confirm (sth to be true), tests");
275         abaTypemap.put(IrregularVerbUtil.proFlag ? "give,[ɡiv],gave,[ɡeiv],given,['ɡivən]" : "beat,beat,beaten", " be defeated");
276         abaTypemap.put(IrregularVerbUtil.proFlag ? "grow,[ɡrəu],grew,[ɡru:],grown,[ɡrəun]" : "grow,grew,grown", " grow");
277         abaTypemap.put(IrregularVerbUtil.proFlag ? "forgive,[fə'ɡiv],forgot,[fə'ɡɔt],forgiven,[]" : "forgive,forgot,forgiven", " forgave,  forgiveness");
278         abaTypemap.put(IrregularVerbUtil.proFlag ? "know,[nəu],knew,[nju: nu:],known,[]" : "know,knew,known", " know");
279         abaTypemap.put(IrregularVerbUtil.proFlag ? "mistake,[mi'steik],mistook,[mi'stuk],mistooken,[]" : "mistake,mistook,mistooken", " get sth wrong;  misunderstandings,");
280         abaTypemap.put(IrregularVerbUtil.proFlag ? "overeat,['əuvə'i:t],overate,[əuvə'reit],overeaten,[]" : "overeat,overate,overeaten", "( enable) overdose");
281         abaTypemap.put(IrregularVerbUtil.proFlag ? "take,[teik],took,[tuk],taken,['teikn]" : "take,took,taken", " take");
282         abaTypemap.put(IrregularVerbUtil.proFlag ? "throw,[θrəu],threw,[θru:],thrown,[θrəun]" : "throw,threw,thrown", " flip, throw away");
283         abaTypemap.put(IrregularVerbUtil.proFlag ? "ride,[raid],rode,[rəud],ridden,['ridən]" : "ride,rode,ridden", " mounted soldier");
284         abaTypemap.put(IrregularVerbUtil.proFlag ? "see,[si:],saw,[sɔ:],seen,[si:n]" : "see,saw,seen", " catch sight of");
285         abaTypemap.put(IrregularVerbUtil.proFlag ? "write,[rait],wrote,[rəut],written,['ritən]" : "write,wrote,writen", " write");
286         abaTypemap.put(IrregularVerbUtil.proFlag ? "break,[breik],broke,[brəuk],broken,['brəukən]" : "break,broke,broken", " shatter");
287         abaTypemap.put(IrregularVerbUtil.proFlag ? "choose,[tʃu:z],chose,[tʃəuz],chosen,['tʃəuzən]" : "choose,chose,chosen", " option");
288         abaTypemap.put(IrregularVerbUtil.proFlag ? "hide,[haid],hid,[hid],hidden,['hidən]" : "hide,hid,hidden", " private");
289         abaTypemap.put(IrregularVerbUtil.proFlag ? "forget,[fə'ɡet],forgot,[fə'ɡɔt],forgotten,[fə'ɡɔtn]" : "forget,forgot,forgotten", " forget");
290         abaTypemap.put(IrregularVerbUtil.proFlag ? "freeze,[fri:z],froze,[frəuz],frozen,['frəuzn]" : "freeze,froze,frozen", " frozen, icing, feel the cold");
291         abaTypemap.put(IrregularVerbUtil.proFlag ? "speak,[spi:k],spoke,[spəuk],spoken,['spəukən]" : "speak,spoke,spoken", " talk");
292         abaTypemap.put(IrregularVerbUtil.proFlag ? "steal,[sti:l],stole,[],stolen,['stəulən]" : "steal,stole,stolen", " steal");
293         abaTypemap.put(IrregularVerbUtil.proFlag ? "begin,[bi'ɡin],began,[bi'ɡæn],begun,[bi'ɡʌn]" : "begin,began,gegun", " Begin");
294         abaTypemap.put(IrregularVerbUtil.proFlag ? "drink,[driŋk],drank,[dræŋk],drunk,[drʌŋk]" : "drink,drank,drunk", " drink");
295         abaTypemap.put(IrregularVerbUtil.proFlag ? "sing,[siŋ],sang,[sæŋ],sung,[sʌŋ]" : "sing,sang,sung", " sing");
296         abaTypemap.put(IrregularVerbUtil.proFlag ? "sink,[siŋk],sank,[sæŋk],sunk,[sʌŋk]" : "sink,sank,sunk", " sink,  sunk");
297         abaTypemap.put(IrregularVerbUtil.proFlag ? "swim,[swim],swam,[swæm],swum,[swʌm]" : "swim,swam,swum", " swim");
298         abaTypemap.put(IrregularVerbUtil.proFlag ? "ring,[riŋ],rang,[ræŋ],rung,[rʌŋ]" : "ring,rang,rung", " Call");
299         abaTypemap.put(IrregularVerbUtil.proFlag ? "be,[],was,[],been,[]" : "be,was,been", " be");
300         abaTypemap.put(IrregularVerbUtil.proFlag ? "be,[],was,[],been,[]" : "be,were,been", " be");
301         abaTypemap.put(IrregularVerbUtil.proFlag ? "bear,[bεə],bore,[bɔ:],born,[]" : "bear,bore,born", " burden,  endure");
302         abaTypemap.put(IrregularVerbUtil.proFlag ? "bear,[bεə],bore,[bɔ:],born,[bɔ:n]" : "bear,bore,borne", " burden,  endure");
303         abaTypemap.put(IrregularVerbUtil.proFlag ? "do,[du:],did,[did],done,[dʌn]" : "do,did,done", " act as");
304         abaTypemap.put(IrregularVerbUtil.proFlag ? "fly,[flai],flew,[flu:],flown,[fləun]" : "fly,flew,flown", " flying");
305         abaTypemap.put(IrregularVerbUtil.proFlag ? "go,[ɡəu],went,[went],gone,[ɡɔn]" : "go,went,gone", " go to (a place)");
306         abaTypemap.put(IrregularVerbUtil.proFlag ? "lie,[lai],lay,[lei],lain,[lein]" : "lie,lay,lain", " lie down");
307         abaTypemap.put(IrregularVerbUtil.proFlag ? "wear,[wεə],wore,[wɔ:],worn,[wɔ:n]" : "wear,wore,worn", " wear");
308         return abaTypemap;
309     }
310 }

/IrregularVerbs/src/com/b510/irregularverbs/utils/CommonUtil.java

 1 /**
 2  * 
 3  */
 4 package com.b510.irregularverbs.utils;
 5 
 6 /**
 7  * @author Hongten
 8  * @created Feb 27, 2014
 9  */
10 public class CommonUtil {
11 
12     //Commands
13     public static final String EXIT = "exit";
14     public static final String PRONUNCIATION = "pronunciation";
15     public static final String ALL = "all";
16     //Description
17     public static final String DESCRIPTION = "Please input a Irregular Verb or Command:
[e.g: 'came', 'all', 'pronunciation', 'exit']";
18     public static final String EXIT_SYSTEM = "exited system.";
19     public static final String LOADIGN_VERBS = "After loading vocabulary!";
20     
21     public static final String NO_MATCHED = "No matched!";
22     public static final String ADVICE = "You may want to search the follow word(s):";
23     public static final String SPEND = "Spend >> [";
24     public static final String SPEND_END = "]ms";
25 
26     public static final int STR_SIZE = 25;
27     public static final String COMMA = ",";
28     public static final String EMPTY = "";
29     public static final String BLANK = " ";
30 
31     public static final String LINE_ONE = "=====================";
32     public static final String LINE_TWO = LINE_ONE + LINE_ONE;
33     public static final String LINE_THREE = LINE_TWO+ "
";
34 }

/IrregularVerbs/src/com/b510/irregularverbs/utils/IrregularVerbUtil.java

  1 /**
  2  * 
  3  */
  4 package com.b510.irregularverbs.utils;
  5 
  6 import java.util.ArrayList;
  7 import java.util.List;
  8 
  9 import com.b510.irregularverbs.lib.VocabularyLib;
 10 import com.b510.irregularverbs.vo.IrregularVerbsVO;
 11 
 12 /**
 13  * The tool for the Irregular Verbs. Providing load and reload methods to get all irregular verbs.<br>
 14  * it also provide the match method to handle the content, which user input in the console.<br>
 15  * and display the result of matching.
 16  * @author Hongten
 17  * @created Feb 27, 2014
 18  */
 19 public class IrregularVerbUtil {
 20 
 21     private static IrregularVerbUtil irregularVerbs = new IrregularVerbUtil();
 22     public static List<IrregularVerbsVO> verbs = new ArrayList<IrregularVerbsVO>();
 23     // The switch of the pronunciation
 24     public static boolean proFlag = false;
 25 
 26     /**
 27      * Load all of the irregular verbs.<br>
 28      * @return all of the irregular verbs.
 29      */
 30     public static List<IrregularVerbsVO> loadIrregularVerbsVOs() {
 31         return VocabularyLib.getVocabularyLib();
 32     }
 33 
 34     private IrregularVerbUtil() {
 35     }
 36 
 37     public static IrregularVerbUtil getInstance() {
 38         if (verbs.size() <= 0) {
 39             loadIrregularVerbsVOs();
 40         }
 41         return irregularVerbs;
 42     }
 43 
 44     /**
 45      * Reload all of the irregular verbs.
 46      */
 47     public static void reLoadVerbs() {
 48         verbs = null;
 49         verbs = new ArrayList<IrregularVerbsVO>();
 50         loadIrregularVerbsVOs();
 51         PrintUtil.printInfo(CommonUtil.LOADIGN_VERBS);
 52         PrintUtil.printInfo(CommonUtil.LINE_THREE);
 53     }
 54 
 55     /**
 56      * Processing the input content,and display the result for matching.
 57      * @param input input content.
 58      */
 59     public void match(String input) {
 60         long startTime = System.currentTimeMillis();
 61         List<IrregularVerbsVO> temp = new ArrayList<IrregularVerbsVO>();
 62         List<IrregularVerbsVO> mayBeVOs = new ArrayList<IrregularVerbsVO>();
 63         for (IrregularVerbsVO vo : verbs) {
 64             handleMatchWord(input, temp, vo);
 65             // match same word(s)
 66             input = input.toLowerCase();
 67             if (vo.getPrototype().startsWith(input) || vo.getPostTense().startsWith(input) || vo.getPostParticiple().startsWith(input)) {
 68                 mayBeVOs.add(vo);
 69             }
 70         }
 71         PrintUtil.printInfo(CommonUtil.LINE_TWO);
 72         matchResult(temp, mayBeVOs);
 73         long endTime = System.currentTimeMillis();
 74         PrintUtil.printInfo(CommonUtil.SPEND + (endTime - startTime) + CommonUtil.SPEND_END);
 75         PrintUtil.printInfo(CommonUtil.LINE_THREE);
 76     }
 77 
 78     /**
 79      * There have two results for matching.<br>
 80      * <li>First : matched, then display the result of matched.</li>
 81      * <li>Second : not matched, then display the related irregular verb(s)</li>
 82      * @param matchedList
 83      * @param relatedList
 84      */
 85     private void matchResult(List<IrregularVerbsVO> matchedList, List<IrregularVerbsVO> relatedList) {
 86         if (matchedList.size() > 0) {
 87             loopMatchResult(matchedList);
 88         } else {
 89             PrintUtil.printInfo(CommonUtil.NO_MATCHED);
 90             if (relatedList.size() > 0) {
 91                 PrintUtil.printInfo(CommonUtil.LINE_ONE);
 92                 PrintUtil.printInfo(CommonUtil.ADVICE);
 93                 loopMatchResult(relatedList);
 94             }
 95         }
 96     }
 97 
 98     /**
 99      * Display the match result
100      * @param list
101      */
102     private static void loopMatchResult(List<IrregularVerbsVO> list) {
103         for (IrregularVerbsVO vo : list) {
104             PrintUtil.printInfo(addBlank(vo.getPrototype().replace(CommonUtil.COMMA, CommonUtil.EMPTY))
105                     + addBlank(vo.getPostTense().replace(CommonUtil.COMMA, CommonUtil.EMPTY))
106                     + addBlank(vo.getPostParticiple().replace(CommonUtil.COMMA, CommonUtil.EMPTY)) + vo.getMean());
107         }
108     }
109 
110     /**
111      * @param input
112      * @param temp
113      * @param vo
114      */
115     private void handleMatchWord(String input, List<IrregularVerbsVO> temp, IrregularVerbsVO vo) {
116         if (proFlag) {
117             if (input.equalsIgnoreCase(vo.getPrototype().split(CommonUtil.COMMA)[0]) || input.equalsIgnoreCase(vo.getPostTense().split(CommonUtil.COMMA)[0])
118                     || input.equalsIgnoreCase(vo.getPostParticiple().split(CommonUtil.COMMA)[0])) {
119                 temp.add(vo);
120             }
121         } else {
122             if (input.equalsIgnoreCase(vo.getPrototype()) || input.equalsIgnoreCase(vo.getPostTense()) || input.equalsIgnoreCase(vo.getPostParticiple())) {
123                 temp.add(vo);
124             }
125         }
126     }
127 
128     /**
129      * Show all of the irregular verbs.
130      */
131     public static void showAll() {
132         if (verbs.size() <= 0) {
133             loadIrregularVerbsVOs();
134         }
135         long startTime = System.currentTimeMillis();
136         PrintUtil.printInfo(CommonUtil.LINE_TWO);
137         loopMatchResult(verbs);
138         long endTime = System.currentTimeMillis();
139         PrintUtil.printInfo(CommonUtil.SPEND + (endTime - startTime) + CommonUtil.SPEND_END);
140         PrintUtil.printInfo(CommonUtil.LINE_THREE);
141     }
142 
143     /**
144      * Add the blank
145      * @param str
146      * @return
147      */
148     private static String addBlank(String str) {
149         int blank = CommonUtil.STR_SIZE - str.getBytes().length;
150         for (int i = 0; i < blank; i++) {
151             str += CommonUtil.BLANK;
152         }
153         return str.toString();
154     }
155 }

/IrregularVerbs/src/com/b510/irregularverbs/utils/PrintUtil.java

 1 /**
 2  * 
 3  */
 4 package com.b510.irregularverbs.utils;
 5 
 6 /**
 7  * @author Hongten
 8  * @created 2014-2-27
 9  */
10 public class PrintUtil {
11 
12     public static void printInfo(String info) {
13         System.out.println(info);
14     }
15 
16     public static void printInfo(StringBuffer info) {
17         System.out.println(info);
18     }
19 
20     public static void printInfo(char info) {
21         System.out.println(info);
22     }
23 }

/IrregularVerbs/src/com/b510/irregularverbs/vo/IrregularVerbsVO.java

 1 /**
 2  * 
 3  */
 4 package com.b510.irregularverbs.vo;
 5 
 6 /**
 7  * @author Hongten
 8  * @created Feb 27, 2014
 9  */
10 public class IrregularVerbsVO {
11 
12     private String prototype;
13     private String postTense;
14     private String postParticiple;
15     private String mean;
16 
17     public IrregularVerbsVO(String prototype, String postTense, String postParticiple, String mean) {
18         super();
19         this.prototype = prototype;
20         this.postTense = postTense;
21         this.postParticiple = postParticiple;
22         this.mean = mean;
23     }
24 
25     public String getPrototype() {
26         return prototype;
27     }
28 
29     public void setPrototype(String prototype) {
30         this.prototype = prototype;
31     }
32 
33     public String getPostTense() {
34         return postTense;
35     }
36 
37     public void setPostTense(String postTense) {
38         this.postTense = postTense;
39     }
40 
41     public String getPostParticiple() {
42         return postParticiple;
43     }
44 
45     public void setPostParticiple(String postParticiple) {
46         this.postParticiple = postParticiple;
47     }
48 
49     public String getMean() {
50         return mean;
51     }
52 
53     public void setMean(String mean) {
54         this.mean = mean;
55     }
56 
57 }

Download Source Code :http://files.cnblogs.com/hongten/IrregularVerbs.zip


Recommended>>
1、Dreamweaver 2018 Software Installation Tutorial
2、Dubai to become a city on the blockchain by 2020 What else is the worlds best impossible for you Im going to mine
3、Which programming language can I learn to make more money The only way to make more money is to keep learning
4、Beijings first selfdriving test road lands in Yizhuang
5、Sichuan Intangible Cultural Heritage Center held an expert seminar on the construction plan of Digital Protection Platform for Intangible Cultural Heritage in Sichuan Province

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号