From 6f008ea9a50aa89fb7afb6d044a50cbe4e74bef8 Mon Sep 17 00:00:00 2001 From: bricktsre Date: Wed, 23 Oct 2019 23:57:57 -0400 Subject: [PATCH 01/11] Made setup methods and variables --- VoiceDVR.class | Bin 0 -> 3537 bytes VoiceDVR.java | 107 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 VoiceDVR.class create mode 100644 VoiceDVR.java diff --git a/VoiceDVR.class b/VoiceDVR.class new file mode 100644 index 0000000000000000000000000000000000000000..c8fc088fa1880c86fdf2983ddca1e6d77625e3c5 GIT binary patch literal 3537 zcma);*;8D{6~@12mfMU534tY9`=FIY5(p%L0AtXOgb)G@Lf$kC7Z?c`G7PqrRoVAM z*_=45vMR}wok~GfRF(2m9`fWr!LNCW{{UB<@0=cb#uBA+QKzSW-F;8@?f$;L{QH0Z z_$PpN{564Y+^9qsCK4=eO6^6dy(G1lrS?jIR|DJ%kWL_h$pk8qNx))CiZFp|n3md1 zfZ0l9aogff0&|!Tu#mtOSPIkm%AV%?pWw43MC zcS7Bc(zb6cCe;I8+jkk{nnogpBNHwbvblu-zfIzI_`Sh? z-U@{A9vE8JNBR50m&a{=)hh##zQW z#(4%`&Rk^hY17ZR%(%iBU|eMkGOjU(7}psij8Vo53~sC$XWU>+Fm5uAGg=vKj1!EL zj8lwuMhD|GqlMC5I|GC2(gs|cyd7p}?y@HDZyojVd&D48uW~7BjprlB&?RlPr8ajg z+G=I<#AgQ2)EDoaa`iA{dTQ!1tGZQnHSqOfnYr8&A1+_u-K9b}&j)!k`TLG58RDH) z;OfKlJTD@5${%kw2o`0~+yWEV_xJ0olwPywCT7+PucP=vy4>QD%I=f3MLyYtI(|#K z`O%3oD03J*&sqg~S@u1~6u<93$9`JC^95!wqGp!;?7M&nvjBStqHK%7WZz5 znR!RJRag9nYvxW=^ff)gmWfDY6D>l<*4#@&oSj4p5w|pJqOCWJX_`6o+DAo zzsGY_d9UY~a>{dDxz2N-yw9^$-tRdQll%ufN0kqHjwv7V99KToA>dY`2ams^z#+f=&eYhuc8HKDtdVtxT|A?a_5K9%RgR}f6X>; z0DZlh?ZRpR$2)}80FHMGs{tJE5>^8^-Yu*KaJ)xY4d8gMuo}Q|N>~lxxK3CN;CP>~ z8o=>>VKso`1Hx(m#|MSg0FDm{s{tGz7FGi|t`}AVICkq712}Gw{)hPaG=FLQQO#fCW5Q|xH@;a|4d7V&)c}ry-a6 searchTerms; + ArrayList output; + HashMap pointToString; + HashMap stringToPoint; + + public VoiceDVR(String filename){ + getTerms(filename, searchTerms); + makePointToString(pointToString); + makeStringToPoint(stringToPoint); + } + + private void getTerms(String filename, ArrayList terms){ + try { + BufferedReader br = new BufferedReader(new FileReader(new File(filename))); + String line; + while ((line = br.readLine()) != null) { + terms.add(line); + } + br.close(); + }catch(Exception e) { + System.out.println("Exception occured reading the file\n"); + } + } + + private void makePointToString(HashMap pts){ + pts.put(new Point(0,0), "A"); + pts.put(new Point(1,0), "B"); + pts.put(new Point(2,0), "C"); + pts.put(new Point(3,0), "D"); + pts.put(new Point(4,0), "E"); + pts.put(new Point(5,0), "R"); + pts.put(new Point(0,1), "G"); + pts.put(new Point(1,1), "H"); + pts.put(new Point(2,1), "I"); + pts.put(new Point(3,1), "J"); + pts.put(new Point(4,1), "K"); + pts.put(new Point(5,1), "L"); + pts.put(new Point(0,2), "M"); + pts.put(new Point(1,2), "N"); + pts.put(new Point(2,2), "O"); + pts.put(new Point(3,2), "P"); + pts.put(new Point(4,2), "Q"); + pts.put(new Point(5,2), "R"); + pts.put(new Point(0,3), "S"); + pts.put(new Point(1,3), "T"); + pts.put(new Point(2,3), "U"); + pts.put(new Point(3,3), "V"); + pts.put(new Point(4,3), "W"); + pts.put(new Point(5,3), "X"); + pts.put(new Point(0,4), "Y"); + pts.put(new Point(1,4), "Z"); + pts.put(new Point(2,4), "1"); + pts.put(new Point(3,4), "2"); + pts.put(new Point(4,4), "3"); + pts.put(new Point(5,4), "4"); + pts.put(new Point(0,5), "5"); + pts.put(new Point(1,5), "6"); + pts.put(new Point(2,5), "7"); + pts.put(new Point(3,5), "8"); + pts.put(new Point(4,5), "9"); + pts.put(new Point(5,5), "0"); + } + + private void makeStringToPoint(HashMap stp){ + stp.put("A", new Point(0,0)); + stp.put("B", new Point(1,0)); + stp.put("C", new Point(2,0)); + stp.put("D", new Point(3,0)); + stp.put("E", new Point(4,0)); + stp.put("R", new Point(5,0)); + stp.put("G", new Point(0,1)); + stp.put("H", new Point(1,1)); + stp.put("I", new Point(2,1)); + stp.put("J", new Point(3,1)); + stp.put("K", new Point(4,1)); + stp.put("L", new Point(5,1)); + stp.put("M", new Point(0,2)); + stp.put("N", new Point(1,2)); + stp.put("O", new Point(2,2)); + stp.put("P", new Point(3,2)); + stp.put("Q", new Point(4,2)); + stp.put("R", new Point(5,2)); + stp.put("S", new Point(0,3)); + stp.put("T", new Point(1,3)); + stp.put("U", new Point(2,3)); + stp.put("V", new Point(3,3)); + stp.put("W", new Point(4,3)); + stp.put("X", new Point(5,3)); + stp.put("Y", new Point(0,4)); + stp.put("X", new Point(1,4)); + stp.put("1", new Point(2,4)); + stp.put("2", new Point(3,4)); + stp.put("3", new Point(4,4)); + stp.put("4", new Point(5,4)); + stp.put("5", new Point(0,5)); + stp.put("6", new Point(1,5)); + stp.put("7", new Point(2,5)); + stp.put("8", new Point(3,5)); + stp.put("9", new Point(4,5)); + stp.put("0", new Point(5,5)); + } +} From 1b1ff19f99d07d6e206e5f95177c9fd9f4990fd7 Mon Sep 17 00:00:00 2001 From: bricktsre Date: Thu, 24 Oct 2019 12:40:48 -0400 Subject: [PATCH 02/11] Finished functionality --- .VoiceDVR.java.swp | Bin 0 -> 20480 bytes Driver.class | Bin 0 -> 353 bytes Driver.java | 6 ++ VoiceDVR.class | Bin 3537 -> 4667 bytes VoiceDVR.java | 173 ++++++++++++++++++++++++--------------------- output | 2 + test | 2 + 7 files changed, 103 insertions(+), 80 deletions(-) create mode 100644 .VoiceDVR.java.swp create mode 100644 Driver.class create mode 100644 Driver.java create mode 100644 output create mode 100644 test diff --git a/.VoiceDVR.java.swp b/.VoiceDVR.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..55ab8aca40083e318f5a51920c4dcb3223fe3408 GIT binary patch literal 20480 zcmeI2Uu+vm9mnTL3;5s;R5)?`Ice%3Wlc7Y?Zh-~nvygrZQ7)5{x*doyxFW1_Z+Xa zUN;FH`u&LI{vfLIS?OnO!Gi zdz1DkAk?w+k>mN!%>Mk{`HeF>GoP9r9p`3+(gHFt+G9i&VVd zi|TcaPjwv`${yXT?w6@z_lRp(mz|Pd>Ap~!vOUKsopaXaUCUeOo^=bhGcr4wylP#u z_UcJ%+5zpr136Ij^Id&Uu%1j>q=W-}?B{^?|HJkFA3wm@Z^6&NPr=LJDtH=v1pM_$ z#(o8EgO|Ze;8|dU4}$~X?h}k{fji)P;2U5LOoIt<5gY~|13!5`W8VgO&<&mfe@9He z2x5B?@1x)l_~qk_eG_87aRdk0S4Z9FJl{E8H|EH&<+lP z1K^+UVeBn%3zWf85C>0!x8Kd!AHZASb?_Q^1$+m54b;F@a0N_&eqe$)cm~A4?+-He z8}KIhG58U<18N`#1_1{QY~!KJCfEQqkOPB&0|vJ7&}9>BfEvhwLBIh6+jyw62{u3t zmaD!|a#r|7w@~tp91nB-jM7t59};@mD_paDhhK9G3w+sn))6^4?G7(lo^i&iER9>` zaKnbNs4T;%?PP9#hIvVa!J5A)gO$yFW&s%aq$gezM~D zW3Fxa1-C>wFS-_q9+Mp;t%U_6-X51_qN~_C+KWzNv4uiDzuMI$`-~}VCWAJyb*ETy zuG2+>`kkE=7GAqAF&0)YFiCG+h=*OT%WXt(wg>Hba4IHnmpq zo#iAPOk&KG{9?(7i<@_h$9X3YZ)MVVr+ny(VLMT$F4K7M%M_qt@4myfTk;E~sw3}H zI?r4-!A7F{{Q znswWvq@7<$QV)(Hv-d0}62}Y2*}fGp5OMqC^{YKlg9oZCr<(H?SjF(dMp?@3E{9Tm7^dKf)6s!c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#uBA+QKzSW-F;8@?f$;L{QH0Z z_$PpN{564Y+^9qsCK4=eO6^6dy(G1lrS?jIR|DJ%kWL_h$pk8qNx))CiZFp|n3md1 zfZ0l9aogff0&|!Tu#mtOSPIkm%AV%?pWw43MC zcS7Bc(zb6cCe;I8+jkk{nnogpBNHwbvblu-zfIzI_`Sh? z-U@{A9vE8JNBR50m&a{=)hh##zQW z#(4%`&Rk^hY17ZR%(%iBU|eMkGOjU(7}psij8Vo53~sC$XWU>+Fm5uAGg=vKj1!EL zj8lwuMhD|GqlMC5I|GC2(gs|cyd7p}?y@HDZyojVd&D48uW~7BjprlB&?RlPr8ajg z+G=I<#AgQ2)EDoaa`iA{dTQ!1tGZQnHSqOfnYr8&A1+_u-K9b}&j)!k`TLG58RDH) z;OfKlJTD@5${%kw2o`0~+yWEV_xJ0olwPywCT7+PucP=vy4>QD%I=f3MLyYtI(|#K z`O%3oD03J*&sqg~S@u1~6u<93$9`JC^95!wqGp!;?7M&nvjBStqHK%7WZz5 znR!RJRag9nYvxW=^ff)gmWfDY6D>l<*4#@&oSj4p5w|pJqOCWJX_`6o+DAo zzsGY_d9UY~a>{dDxz2N-yw9^$-tRdQll%ufN0kqHjwv7V99KToA>dY`2ams^z#+f=&eYhuc8HKDtdVtxT|A?a_5K9%RgR}f6X>; z0DZlh?ZRpR$2)}80FHMGs{tJE5>^8^-Yu*KaJ)xY4d8gMuo}Q|N>~lxxK3CN;CP>~ z8o=>>VKso`1Hx(m#|MSg0FDm{s{tGz7FGi|t`}AVICkq712}Gw{)hPaG=FLQQO#fCW5Q|xH@;a|4d7V&)c}ry-a6 searchTerms; - ArrayList output; - HashMap pointToString; - HashMap stringToPoint; + private ArrayList searchTerms = new ArrayList(); + private HashMap charToPoint = new HashMap(); public VoiceDVR(String filename){ getTerms(filename, searchTerms); - makePointToString(pointToString); - makeStringToPoint(stringToPoint); + makeCharToPoint(charToPoint); } private void getTerms(String filename, ArrayList terms){ @@ -27,81 +24,97 @@ private void getTerms(String filename, ArrayList terms){ } } - private void makePointToString(HashMap pts){ - pts.put(new Point(0,0), "A"); - pts.put(new Point(1,0), "B"); - pts.put(new Point(2,0), "C"); - pts.put(new Point(3,0), "D"); - pts.put(new Point(4,0), "E"); - pts.put(new Point(5,0), "R"); - pts.put(new Point(0,1), "G"); - pts.put(new Point(1,1), "H"); - pts.put(new Point(2,1), "I"); - pts.put(new Point(3,1), "J"); - pts.put(new Point(4,1), "K"); - pts.put(new Point(5,1), "L"); - pts.put(new Point(0,2), "M"); - pts.put(new Point(1,2), "N"); - pts.put(new Point(2,2), "O"); - pts.put(new Point(3,2), "P"); - pts.put(new Point(4,2), "Q"); - pts.put(new Point(5,2), "R"); - pts.put(new Point(0,3), "S"); - pts.put(new Point(1,3), "T"); - pts.put(new Point(2,3), "U"); - pts.put(new Point(3,3), "V"); - pts.put(new Point(4,3), "W"); - pts.put(new Point(5,3), "X"); - pts.put(new Point(0,4), "Y"); - pts.put(new Point(1,4), "Z"); - pts.put(new Point(2,4), "1"); - pts.put(new Point(3,4), "2"); - pts.put(new Point(4,4), "3"); - pts.put(new Point(5,4), "4"); - pts.put(new Point(0,5), "5"); - pts.put(new Point(1,5), "6"); - pts.put(new Point(2,5), "7"); - pts.put(new Point(3,5), "8"); - pts.put(new Point(4,5), "9"); - pts.put(new Point(5,5), "0"); + public void Translate(String OutputFilename){ + try{ + BufferedWriter bw = new BufferedWriter(new FileWriter(new File(OutputFilename)));; + for( String s: searchTerms){ + ArrayList output = translateLine(s, charToPoint); + StringJoiner outputJoiner = new StringJoiner(","); + for(String x: output) + outputJoiner.add(x); + bw.write(outputJoiner.toString() + "\n"); + } + bw.close(); + }catch( Exception e) { + System.out.println(e); + } + } + + private ArrayList translateLine(String term, HashMap ctp){ + Point pointAt = new Point(0,0); + char charAt = 'A'; + ArrayList output = new ArrayList(); + for(int i = 0; i < term.length(); i++){ + char c = Character.toUpperCase(term.charAt(i)); + if(c == ' '){ + output.add("S"); + charAt = c; + continue; + } + Point newPoint = ctp.get(c); + int diffx =(int)(newPoint.getX() - pointAt.getX()); + int diffy =(int)(newPoint.getY() - pointAt.getY()); + while( diffy != 0){ + if( diffy < 0){ + output.add("U"); + diffy++; + }else{ + output.add("D"); + diffy--; + } + } + while( diffx != 0){ + if( diffx < 0){ + output.add("L"); + diffx++; + }else{ + output.add("R"); + diffx--; + } + } + output.add("#"); + pointAt.setLocation(newPoint); + charAt = c; + } + return output; } - private void makeStringToPoint(HashMap stp){ - stp.put("A", new Point(0,0)); - stp.put("B", new Point(1,0)); - stp.put("C", new Point(2,0)); - stp.put("D", new Point(3,0)); - stp.put("E", new Point(4,0)); - stp.put("R", new Point(5,0)); - stp.put("G", new Point(0,1)); - stp.put("H", new Point(1,1)); - stp.put("I", new Point(2,1)); - stp.put("J", new Point(3,1)); - stp.put("K", new Point(4,1)); - stp.put("L", new Point(5,1)); - stp.put("M", new Point(0,2)); - stp.put("N", new Point(1,2)); - stp.put("O", new Point(2,2)); - stp.put("P", new Point(3,2)); - stp.put("Q", new Point(4,2)); - stp.put("R", new Point(5,2)); - stp.put("S", new Point(0,3)); - stp.put("T", new Point(1,3)); - stp.put("U", new Point(2,3)); - stp.put("V", new Point(3,3)); - stp.put("W", new Point(4,3)); - stp.put("X", new Point(5,3)); - stp.put("Y", new Point(0,4)); - stp.put("X", new Point(1,4)); - stp.put("1", new Point(2,4)); - stp.put("2", new Point(3,4)); - stp.put("3", new Point(4,4)); - stp.put("4", new Point(5,4)); - stp.put("5", new Point(0,5)); - stp.put("6", new Point(1,5)); - stp.put("7", new Point(2,5)); - stp.put("8", new Point(3,5)); - stp.put("9", new Point(4,5)); - stp.put("0", new Point(5,5)); + private void makeCharToPoint(HashMap ctp){ + ctp.put('A', new Point(0,0)); + ctp.put('B', new Point(1,0)); + ctp.put('C', new Point(2,0)); + ctp.put('D', new Point(3,0)); + ctp.put('E', new Point(4,0)); + ctp.put('R', new Point(5,0)); + ctp.put('G', new Point(0,1)); + ctp.put('H', new Point(1,1)); + ctp.put('I', new Point(2,1)); + ctp.put('J', new Point(3,1)); + ctp.put('K', new Point(4,1)); + ctp.put('L', new Point(5,1)); + ctp.put('M', new Point(0,2)); + ctp.put('N', new Point(1,2)); + ctp.put('O', new Point(2,2)); + ctp.put('P', new Point(3,2)); + ctp.put('Q', new Point(4,2)); + ctp.put('R', new Point(5,2)); + ctp.put('S', new Point(0,3)); + ctp.put('T', new Point(1,3)); + ctp.put('U', new Point(2,3)); + ctp.put('V', new Point(3,3)); + ctp.put('W', new Point(4,3)); + ctp.put('X', new Point(5,3)); + ctp.put('Y', new Point(0,4)); + ctp.put('X', new Point(1,4)); + ctp.put('1', new Point(2,4)); + ctp.put('2', new Point(3,4)); + ctp.put('3', new Point(4,4)); + ctp.put('4', new Point(5,4)); + ctp.put('5', new Point(0,5)); + ctp.put('6', new Point(1,5)); + ctp.put('7', new Point(2,5)); + ctp.put('8', new Point(3,5)); + ctp.put('9', new Point(4,5)); + ctp.put('0', new Point(5,5)); } } diff --git a/output b/output new file mode 100644 index 0000000..e2f1e8e --- /dev/null +++ b/output @@ -0,0 +1,2 @@ +D,R,R,#,D,D,L,#,S,U,U,U,R,#,D,D,R,R,R,#,L,L,L,#,D,R,R,#,U,U,U,L,# +D,R,R,#,D,D,L,#,S,U,U,U,R,#,D,D,R,R,R,#,L,L,L,#,D,R,R,#,U,U,U,L,# diff --git a/test b/test new file mode 100644 index 0000000..e9012f9 --- /dev/null +++ b/test @@ -0,0 +1,2 @@ +IT Crowd +IT Crowd From 4b5ea74fd3e3d239e0f3f32d9a0396801d48c2ae Mon Sep 17 00:00:00 2001 From: bricktsre Date: Thu, 24 Oct 2019 13:03:11 -0400 Subject: [PATCH 03/11] Added comments --- .VoiceDVR.java.swp | Bin 20480 -> 20480 bytes VoiceDVR.java | 44 +++++++++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/.VoiceDVR.java.swp b/.VoiceDVR.java.swp index 55ab8aca40083e318f5a51920c4dcb3223fe3408..f72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zrCF074_c6Nk!{qmXRq7wVI?Mz3q~|fo5x~`dXFx{RQV$1ER)I?TG|ggeA_qNx+8Z{ zG$Sf-jSd05+L-EKR;a zi<@*uok(A5El>dlPMzT7551}{pww{Bqe7Dx0_+^MfFxhl4KaSQ-u`|=ItYg#_jX|#kF#wg0>Px~gehr7BH7_WtGzkg^)EQ&jwS#A delta 917 zcmaLVO-K}B7{KvoYNf`HcGbeP#IX!_a$2{dFqdi|DL48OB8-$)-BtX+m1P&b$j+rh zmm*%MphH^-o-CH>(8(6+kWo<-BAvE6M?{|xME?IFuH0(McRclLO{y}`pjm1s$DrF4aQzjV%S0Z- zo5o|KIs0Xu$V=pL2Xh$30M^5Yr3#UUn8#gQLpM&N3#ZVCIy@>DnZY1hu>n6>@!87C zH#kR8h3BQRMsAjhq)Od+W4G?lq>Xga7#to;^o(yYBPwRq=m|3-x;{P7r@onu*x}<+ zCkUzUrnO4Eu%(t;djDi-GBun|1e2NcL?(SSIXs?7sZZvv5^sj?MaFWZ|D6!(i^qdg z%ZupxAW24rm;GmW)9U^`Os_sG8Of*({riutTrULGLp$e)&ZT z$iYDjHVg=gbh>~X9K>M5fS^cs3&_Di3^oi1igdbwT)7+;had(U1_VV4Dj)|3G1%A- zuh=$h#1D#J!hLrk{6JTo?e>bjD$-u>-fN%nRY_l5WQybt@8#^$Qk8Z?*4xtonD|W1 z3%H64n80~-;TSA@rEc%9nuWqNl8EC34q^|&s6`1rvf^7TqJTVRal2fa searchTerms = new ArrayList(); private HashMap charToPoint = new HashMap(); + // Costructor function, sets up hashmap and reads in searchTerms public VoiceDVR(String filename){ getTerms(filename, searchTerms); makeCharToPoint(charToPoint); } + // Reads searchterms line by line from the provided file and puts them into a List + // param filename name of the file to read from + // param terms List to fill with parsed terms private void getTerms(String filename, ArrayList terms){ try { BufferedReader br = new BufferedReader(new FileReader(new File(filename))); @@ -24,15 +28,17 @@ private void getTerms(String filename, ArrayList terms){ } } + // Translates all provided terms and writes them to a file + // param OutputFilename name of file to write out to public void Translate(String OutputFilename){ try{ BufferedWriter bw = new BufferedWriter(new FileWriter(new File(OutputFilename)));; for( String s: searchTerms){ - ArrayList output = translateLine(s, charToPoint); + ArrayList output = translateLine(s, charToPoint); // Get translation for string s StringJoiner outputJoiner = new StringJoiner(","); for(String x: output) - outputJoiner.add(x); - bw.write(outputJoiner.toString() + "\n"); + outputJoiner.add(x); // Add each individual string for comma delimination + bw.write(outputJoiner.toString() + "\n"); // Write out to file } bw.close(); }catch( Exception e) { @@ -40,30 +46,32 @@ public void Translate(String OutputFilename){ } } + // Translate an individual string to the DVR moves needed to make it + // param term string to translate + // param ctp hashtable to use in translation + // return ArrayList list of strings forming the necessary DVR moves private ArrayList translateLine(String term, HashMap ctp){ - Point pointAt = new Point(0,0); - char charAt = 'A'; + Point pointAt = new Point(0,0); // Always start at 0,0 which is A ArrayList output = new ArrayList(); for(int i = 0; i < term.length(); i++){ - char c = Character.toUpperCase(term.charAt(i)); - if(c == ' '){ + char c = Character.toUpperCase(term.charAt(i)); // Grab next character making sure it is uppercase + if(c == ' '){ // If it is a space add to output and skip to next loop iteration output.add("S"); - charAt = c; continue; } - Point newPoint = ctp.get(c); - int diffx =(int)(newPoint.getX() - pointAt.getX()); + Point newPoint = ctp.get(c); // Point location of char c + int diffx =(int)(newPoint.getX() - pointAt.getX()); // Get the difference in x and y from last point to new point int diffy =(int)(newPoint.getY() - pointAt.getY()); - while( diffy != 0){ + while( diffy != 0){ // If y is zero then y-coordinate is already correct if( diffy < 0){ - output.add("U"); + output.add("U"); // If y is negative, "move" the cursor up and add U to the output diffy++; }else{ - output.add("D"); + output.add("D"); // If y is positive, "move" the cursor down and add D to the output diffy--; } } - while( diffx != 0){ + while( diffx != 0){ // Similar to above while loop except for x-coordinate if( diffx < 0){ output.add("L"); diffx++; @@ -72,13 +80,15 @@ private ArrayList translateLine(String term, HashMap c diffx--; } } - output.add("#"); - pointAt.setLocation(newPoint); - charAt = c; + output.add("#"); // At correct coordinates so select the character + pointAt.setLocation(newPoint); // Update where the cursor is at } return output; } + // Makes the hashtable used to find the points of every character + // Static initializer since the HashMap is the same every time + // param ctp the hashmap to fill private void makeCharToPoint(HashMap ctp){ ctp.put('A', new Point(0,0)); ctp.put('B', new Point(1,0)); From 26e45ee0019d62fdaebce23e91cc8fc1b0238158 Mon Sep 17 00:00:00 2001 From: bricktsre Date: Sun, 27 Oct 2019 16:53:37 -0400 Subject: [PATCH 04/11] Still working on tests --- .VoiceDVR.java.swp | Bin 20480 -> 16384 bytes VoiceDVR.java | 8 ++++---- VoiceDVRTestRunner.java | 12 ++++++++++++ VoiceDVRTests.java | 22 ++++++++++++++++++++++ test | 2 -- test1 | 1 + test2 | 2 ++ 7 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 VoiceDVRTestRunner.java create mode 100644 VoiceDVRTests.java delete mode 100644 test create mode 100644 test1 create mode 100644 test2 diff --git a/.VoiceDVR.java.swp b/.VoiceDVR.java.swp index f72a9227e80f97c4e96684bcdb24d09f72c5686d..1b160e0ea3fa769d852c04d6e667bb537bd10259 100644 GIT binary patch delta 634 zcmX}pO-LI-6u|K}NsKi{H-X|ugD`>@QG!YjR;27f#q=X6ZN(f4n@G@rA2g(;rAW4T z5WMMvcwF%yg+eW3?V%t-u{|ioi}xG~-UNHM_zzYe{B~z|-n^N8>-x%dmCp4{q@L>j zWRDOrk-z`GzMP0}$lJWgbTL1@y4mq%Xy38|QYIl#%_6d1Jk}f!UO!0t|9j44V%yg0 zj$YHDh9ob4D=rizT`!mS>P0>yg9kW^i0oh;!wBHAPUIY?_>OPbg~1$BXvOgz)?pk8 zT-1uJpbu@Z5W$bINE*#y&i|{1Ldf7TZ2Sqa8IJH1B{+D5LG&VlC<3_TqYdUzz$9Ma z8Dco0MV~N_G?HkIFt$*bFPXz9 zd#dJjZniMxeMonk3H4-Ynr=^J~m1+3RAE{U(2k_y- zfej5orIC5~aN)p)hM>~GJbbutU_(PtVZQ_TQAvo)z<~{oHdGIEFKSe1vEJ(+&}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 zF^U(k0gdpY3bXMmoxFh`a0;F1KpWHmzNO|0F5n{99mWyF(FPBkxUO;xmu;bdojBUy zffLuc*hLKE2;yji2TojP#xCMj)S(Qe_;3#QVBhRq(bf6CF3#4)?&XRzHTAduDY%Db z&C%r#{m(wnwEZudZn(W`&BgxE++J|Eys+JK#5v2z6uzlB>oEK3-Rj-quwEYO=p|po F@fQn-jGq7i diff --git a/VoiceDVR.java b/VoiceDVR.java index 6b1f18f..77b383c 100644 --- a/VoiceDVR.java +++ b/VoiceDVR.java @@ -30,11 +30,11 @@ private void getTerms(String filename, ArrayList terms){ // Translates all provided terms and writes them to a file // param OutputFilename name of file to write out to - public void Translate(String OutputFilename){ + private void Translate(String OutputFilename){ try{ BufferedWriter bw = new BufferedWriter(new FileWriter(new File(OutputFilename)));; for( String s: searchTerms){ - ArrayList output = translateLine(s, charToPoint); // Get translation for string s + ArrayList output = translateLine(s); // Get translation for string s StringJoiner outputJoiner = new StringJoiner(","); for(String x: output) outputJoiner.add(x); // Add each individual string for comma delimination @@ -50,7 +50,7 @@ public void Translate(String OutputFilename){ // param term string to translate // param ctp hashtable to use in translation // return ArrayList list of strings forming the necessary DVR moves - private ArrayList translateLine(String term, HashMap ctp){ + public ArrayList translateLine(String term){ Point pointAt = new Point(0,0); // Always start at 0,0 which is A ArrayList output = new ArrayList(); for(int i = 0; i < term.length(); i++){ @@ -59,7 +59,7 @@ private ArrayList translateLine(String term, HashMap c output.add("S"); continue; } - Point newPoint = ctp.get(c); // Point location of char c + Point newPoint = charToPoint.get(c); // Point location of char c int diffx =(int)(newPoint.getX() - pointAt.getX()); // Get the difference in x and y from last point to new point int diffy =(int)(newPoint.getY() - pointAt.getY()); while( diffy != 0){ // If y is zero then y-coordinate is already correct diff --git a/VoiceDVRTestRunner.java b/VoiceDVRTestRunner.java new file mode 100644 index 0000000..0a35b46 --- /dev/null +++ b/VoiceDVRTestRunner.java @@ -0,0 +1,12 @@ +import org.junit.runner.JUnitCore; +import org.junit.runner.Result; +import org.junit.runner.notification.Failure; + +public class VoiceDVRTestRunner { + public static void main(String[] args) { + Result result = JUnitCore.runClasses(VoiceDVRTest.class); + for (Failure failure : result.getFailures()) { + System.out.println(failure.toString()); + } + } +} diff --git a/VoiceDVRTests.java b/VoiceDVRTests.java new file mode 100644 index 0000000..9fde5e3 --- /dev/null +++ b/VoiceDVRTests.java @@ -0,0 +1,22 @@ +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; +import java.util.*; +import java.lang.reflect.*; + +public class VoiceDVRTests { + + @BeforeClass + public static void beforeClass() { + voicedvr = new VoiceDVR("test1"); + } + + // Testing is the string is only "a" + @Test + public void lookForA(){ + Method method = voicedvr.class.getDeclaredMethod("translate", String.class); + method.setAccessible(true); + List result = (List) method.invoke(voicedvr, "a"); + assertEquals(result[0],"#"); + assertEquals(1, result.size()); + } +} diff --git a/test b/test deleted file mode 100644 index e9012f9..0000000 --- a/test +++ /dev/null @@ -1,2 +0,0 @@ -IT Crowd -IT Crowd diff --git a/test1 b/test1 new file mode 100644 index 0000000..1cd1ef2 --- /dev/null +++ b/test1 @@ -0,0 +1 @@ +IT diff --git a/test2 b/test2 new file mode 100644 index 0000000..df4fe3c --- /dev/null +++ b/test2 @@ -0,0 +1,2 @@ +IT +IT From d92e32c08311d370e01b3258952bb1826ee43e46 Mon Sep 17 00:00:00 2001 From: Gregory Woodward Date: Sun, 27 Oct 2019 18:01:08 -0400 Subject: [PATCH 05/11] Delete Driver.class --- Driver.class | Bin 353 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Driver.class diff --git a/Driver.class b/Driver.class deleted file mode 100644 index f0acfe5965547eba60434aea1736405f49928787..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 353 zcmZvXK}*9x5QX0)Y0{>#t*xmi58h$~3-#bZ@nZ256l@8Ir%hbSmUIhi+W+Onf`UK5 zA0^J}p%?csGjI6bzTL0y_fG&9I1J&V8=x1$!M-j10D}Mr1pi8DRbLa_+n! z=w?dGyY;e=W+sY?H{MbxO&BIm*+Oi@s1kZUn$||?`K2|6)79FP@>W^6Juzw{&6y=5 z1ZWbP`AU^?l0R4-M;IdJ@IQ{w+ueCzEM!>|;^hCJ*31a~Qi)pP7!CfHJr2mmaBZ Date: Sun, 27 Oct 2019 18:01:17 -0400 Subject: [PATCH 06/11] Delete VoiceDVR.class --- VoiceDVR.class | Bin 4667 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 VoiceDVR.class diff --git a/VoiceDVR.class b/VoiceDVR.class deleted file mode 100644 index 971d154843bff59ea961e299d9b12b890826d206..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4667 zcma)AYjhP?75>hB&D_bPgg^)ZfwWM_3&Jx%0@M(ogeHNK7lD>C+ziPjH+RCllK@)V zYH6_#Tcuixq9E2r`%u7=P+}{-uvT45mp@(parw`+^rvfeVdHo1oO|a2DXWWh&&>H| zpZ)mu-sha~(I?kF0I(K+GSGld4P6ET=!~Ks-5T~72z!$rgUDVv?9=dwhDSB*H(=s1 z0|hu>z}DVZ!l3miENX*eRar!=H> zxCY8GEQb*}94)4cUzDpJmqV}A_azNa7^uXP2Ik`_Iegi`SMaos6Y}|t^!!;Va8eFm z)$yE;=XJcG<3$}`lh{jAmCObYOjyaj+IBY;Pxduz;<|!Zzm@86b~*8+D=;H(<#sFG z-)ap}rv6SeUt1G3STWa5HF$E?QMWduFJmCGA)bu8o9KDPogP$n351%QUOGLkC7!g~ zh6fMYsSfL4f{5N{yDI9cDc0sW{Pleu;K3dvpi0j6|#HuGcC_|?rwxnX(fMgE;3R+Xbsp>SuX#xlrNd`$~jI7 zHcs&&U+Z06;(DXq8BWFQZE=~{!Y(Hsv$u5ZUM6eVL=#?N=}l4BCN^NBz;yqU^2x;K z(P-j9Y&WqB4-3r7h{T=R&BKQd*(tksw{7*>DS_hb2WdJBn)#r#zeNt;l*6}7yo%E% zUc(s^-}W8L^v%{|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FDo@GY@9!(m``3`)H@<~#j160NBGJc`T0#mi(plxTIK zQ9M^uqFqJp7?xj0WxX!hTEQ||(f3kaR8CfMvXT>{#5jXRCB|7yr-D^d!3jf*PX3Ft z)!uA!bn@>dQ7IMmq}F8csFJGlW>Si4*2>vZXrBB7lKT<${~0?o$=izPBpXl5<}9qCk~JM*x7_60Cs-l@ zQCe79IEm>~%6-h{^tOwg42U;SFL%LCnOVm8PIXZudCz5V4C}kAi#97LB$MhvO$rM8 z&=v(nd}ynJG#}cnAl-)^R8TOKQ@>q7As=d1P}qldC@A7X4=G6Vp%w+{KGdq9U^r*7 zO+g_a+Nq$h5A9M=#D^YMkmf_V7=5T+Nd+T0iyaCI`B0~V!amfcpokB3D@gO9Jqpr& zs7FCTEoU(+74o4KN-FF_D-{&+p;Zdfd}y_TbRSxyprD?!Sf`+n53N;D*oW3BDB?rw z6{Pvlas}yG$UmK4mD?xUxkYwx!|P3B95Vwus}9cpQD=W%P>+h>I&YEI!15_!|=9-xy@aB?B|z z1eRbZP>&;lR-^(4kPf8b2A;)m;0#6rZ{w(HwcR{<+cP^z2R`J};MsG7o&7tWTE{ro KIX}+d7yb_}AE2)Q From 7593d9edc9bd3be9aba06058e169bdb5ffb9b244 Mon Sep 17 00:00:00 2001 From: Gregory Woodward Date: Sun, 27 Oct 2019 18:01:26 -0400 Subject: [PATCH 07/11] Delete output --- output | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 output diff --git a/output b/output deleted file mode 100644 index e2f1e8e..0000000 --- a/output +++ /dev/null @@ -1,2 +0,0 @@ -D,R,R,#,D,D,L,#,S,U,U,U,R,#,D,D,R,R,R,#,L,L,L,#,D,R,R,#,U,U,U,L,# -D,R,R,#,D,D,L,#,S,U,U,U,R,#,D,D,R,R,R,#,L,L,L,#,D,R,R,#,U,U,U,L,# From d4acbf4f630a07b1e7c96c672dfc991da685ae7e Mon Sep 17 00:00:00 2001 From: Gregory Woodward Date: Sun, 27 Oct 2019 19:17:13 -0400 Subject: [PATCH 08/11] Add files via upload --- VoiceDVR.java | 5 ++- VoiceDVRTestRunner.java | 2 +- VoiceDVRTests.java | 95 ++++++++++++++++++++++++++++++++++++----- 3 files changed, 89 insertions(+), 13 deletions(-) diff --git a/VoiceDVR.java b/VoiceDVR.java index 77b383c..9f29b51 100644 --- a/VoiceDVR.java +++ b/VoiceDVR.java @@ -1,4 +1,5 @@ import java.util.*; + import java.awt.*; import java.io.*; @@ -30,7 +31,7 @@ private void getTerms(String filename, ArrayList terms){ // Translates all provided terms and writes them to a file // param OutputFilename name of file to write out to - private void Translate(String OutputFilename){ + public void Translate(String OutputFilename){ try{ BufferedWriter bw = new BufferedWriter(new FileWriter(new File(OutputFilename)));; for( String s: searchTerms){ @@ -50,7 +51,7 @@ private void Translate(String OutputFilename){ // param term string to translate // param ctp hashtable to use in translation // return ArrayList list of strings forming the necessary DVR moves - public ArrayList translateLine(String term){ + private ArrayList translateLine(String term){ Point pointAt = new Point(0,0); // Always start at 0,0 which is A ArrayList output = new ArrayList(); for(int i = 0; i < term.length(); i++){ diff --git a/VoiceDVRTestRunner.java b/VoiceDVRTestRunner.java index 0a35b46..703e16b 100644 --- a/VoiceDVRTestRunner.java +++ b/VoiceDVRTestRunner.java @@ -4,7 +4,7 @@ public class VoiceDVRTestRunner { public static void main(String[] args) { - Result result = JUnitCore.runClasses(VoiceDVRTest.class); + Result result = JUnitCore.runClasses(VoiceDVRTests.class); for (Failure failure : result.getFailures()) { System.out.println(failure.toString()); } diff --git a/VoiceDVRTests.java b/VoiceDVRTests.java index 9fde5e3..5a519de 100644 --- a/VoiceDVRTests.java +++ b/VoiceDVRTests.java @@ -1,22 +1,97 @@ -import static org.junit.jupiter.api.Assertions.*; -import org.junit.jupiter.api.Test; +import static org.junit.Assert.*; import java.util.*; +import java.util.List; import java.lang.reflect.*; +import java.awt.*; public class VoiceDVRTests { - - @BeforeClass + public static VoiceDVR voicedvr; + + @org.junit.BeforeClass public static void beforeClass() { voicedvr = new VoiceDVR("test1"); } - // Testing is the string is only "a" - @Test - public void lookForA(){ - Method method = voicedvr.class.getDeclaredMethod("translate", String.class); + // Testing is the string is only "A" + @org.junit.Test + public void lookForA() throws NoSuchMethodException, SecurityException, IllegalAccessException, + IllegalArgumentException, InvocationTargetException { + Method method = VoiceDVR.class.getDeclaredMethod("translateLine", String.class); + method.setAccessible(true); + String input = "A"; + @SuppressWarnings("unchecked") + List result = (List) method.invoke(voicedvr, input); + assertEquals(result.get(0), "#"); + assertEquals(1, result.size()); + } + + // Testing is the string is only "B" + @org.junit.Test + public void lookForB() throws NoSuchMethodException, SecurityException, IllegalAccessException, + IllegalArgumentException, InvocationTargetException { + Method method = VoiceDVR.class.getDeclaredMethod("translateLine", String.class); + method.setAccessible(true); + String input = "B"; + @SuppressWarnings("unchecked") + List result = (List) method.invoke(voicedvr, input); + assertEquals(result.get(0), "R"); + assertEquals(result.get(1), "#"); + assertEquals(2, result.size()); + } + + // Testing is the string is only " " + @org.junit.Test + public void lookForSpace() throws NoSuchMethodException, SecurityException, IllegalAccessException, + IllegalArgumentException, InvocationTargetException { + Method method = VoiceDVR.class.getDeclaredMethod("translateLine", String.class); method.setAccessible(true); - List result = (List) method.invoke(voicedvr, "a"); - assertEquals(result[0],"#"); + String input = " "; + @SuppressWarnings("unchecked") + List result = (List) method.invoke(voicedvr, input); + assertEquals(result.get(0), "S"); assertEquals(1, result.size()); } + + // Testing is the string is only "AB" + @org.junit.Test + public void lookForAB() throws NoSuchMethodException, SecurityException, IllegalAccessException, + IllegalArgumentException, InvocationTargetException { + Method method = VoiceDVR.class.getDeclaredMethod("translateLine", String.class); + method.setAccessible(true); + String input = "AB"; + @SuppressWarnings("unchecked") + List result = (List) method.invoke(voicedvr, input); + assertEquals(result.get(0), "#"); + assertEquals(result.get(1), "R"); + assertEquals(result.get(2), "#"); + assertEquals(3, result.size()); + } + + // Testing is the string is only "0" + @org.junit.Test + public void lookForZero() throws NoSuchMethodException, SecurityException, IllegalAccessException, + IllegalArgumentException, InvocationTargetException { + Method method = VoiceDVR.class.getDeclaredMethod("translateLine", String.class); + method.setAccessible(true); + String input = "0"; + @SuppressWarnings("unchecked") + List result = (List) method.invoke(voicedvr, input); + assertEquals(result.get(0), "D"); + assertEquals(result.get(9), "R"); + assertEquals(result.get(10), "#"); + assertEquals(11, result.size()); + } + + // Testing the char to point hash generation + @org.junit.Test + public void generateCharToPointHash() throws NoSuchMethodException, SecurityException, IllegalAccessException, + IllegalArgumentException, InvocationTargetException { + Method method = VoiceDVR.class.getDeclaredMethod("makeCharToPoint", HashMap.class); + method.setAccessible(true); + HashMap input = new HashMap(); + method.invoke(voicedvr, input); + assertTrue(input.containsKey('A')); + assertFalse(input.containsKey('a')); + assertEquals(new Point(0,0), input.get('A')); + } } From f9012e6af524fff6b1384c3efb235f563e169846 Mon Sep 17 00:00:00 2001 From: Gregory Woodward Date: Sun, 27 Oct 2019 19:17:26 -0400 Subject: [PATCH 09/11] Delete .VoiceDVR.java.swp --- .VoiceDVR.java.swp | Bin 16384 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .VoiceDVR.java.swp diff --git a/.VoiceDVR.java.swp b/.VoiceDVR.java.swp deleted file mode 100644 index 1b160e0ea3fa769d852c04d6e667bb537bd10259..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeHNO>7)j9UsEyl%_3k2oObjaSxfT*X#YTX;RyjT|2Z%?4*rjH%3(Q?Ce|bG_y0K znYUgqRUl_B+z`iHkq{tC0f|c_q~<_Xap{3ukWjgxN^mdY_kZur+HYqG^nyToEB!Q{ z_j@1z_xpdmnO(Q*yH~c@#ai9L=NZTO`#;`!WA{rxa*nv;9Ax}}n*ZI0`ps=^&pp4k zc?@IFyI@zH*0VDhyLScvYb`GD)5OE z7>MrN#nVo!*^sIJ?96%gl`rpnqA6@=tAJI&Dqt0`3RnfK0#*U5fK}lCTLF=ta=wQx zoYLDUUb{b~?~CiF_5FE$ZBOv})?TavRspMkRlq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Ba38n_>;tO+103KH)_VZZcL4W*eP9(}0DT8Q_Iw?%AFF^> zz$#!BunJfOtO8a6tAJJDzoG!X8lrE9#=jWVjbC&YtBVuAC|xr6g%W?!;9DjBd4q43 z_-`0|qr@*7e7(dk82n;&VZ#2F!7r5frop#Le8b?ICH}U-H%k1T!PiT?IexL)ny~+M zWBfvi-!=GFiQh5!W{JOL@Qo6`ZSeIHf79R>tIY}fUo-fH691~fw@UmCgKw7j>jvK_ x@mmI8FY%iOzgTTd*niF77fSq9gKw4iD+b>z@vj(sqr|^#@bwZuslWV1_@9sq_lW=i From dc44d42e3f30d78ceb9a31934315e82ad8f63c56 Mon Sep 17 00:00:00 2001 From: Gregory Woodward Date: Sun, 27 Oct 2019 19:17:38 -0400 Subject: [PATCH 10/11] Delete test2 --- test2 | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 test2 diff --git a/test2 b/test2 deleted file mode 100644 index df4fe3c..0000000 --- a/test2 +++ /dev/null @@ -1,2 +0,0 @@ -IT -IT From 170395956c369cafcd878fdd7f838c4917b1f58a Mon Sep 17 00:00:00 2001 From: Gregory Woodward Date: Sun, 27 Oct 2019 19:23:34 -0400 Subject: [PATCH 11/11] Create AboutMe --- AboutMe | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 AboutMe diff --git a/AboutMe b/AboutMe new file mode 100644 index 0000000..a985c19 --- /dev/null +++ b/AboutMe @@ -0,0 +1,9 @@ +Written by Gregory Woodward + +My solution to this project is written in java. First compile Driver.java and VoiceDVR.java with javac. VoiceDVR is a class that actually translates strings into DVR moves, while Driver calls this class with command line arguments. + +To run: java Driver + +All input strings in the input file are written out on the same line in the output file + +I wrote unit tests for VoiceDVR.java using junit4, those tests can be found in VoiceDVRTests. To run the tests use VoiceDVRTestRunner. I am not an expert with junit so I think you can just compile VoiceDVRTests and VoiceDVRTestRunner with the right dependencies installed and you should be good.