Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #192

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions S23/pmirukula/ConvTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

public class ConvTest {
@Test
public void turkishcheck() {
Conv ex = new Conversion();
String s = "KASIM";
String l = "tr";
Boolean m;
String out = ex.trazConv(s, l);
if (out.equals("kasım")) {
m = true;
} else {
m = false;
}
assertEquals(m, true);
}

@Test
public void azcheck() {
Conv ex1 = new Conversion();
String s1 = "KASIM";
String l1 = "az";
Boolean m;
String out = ex1.trazConv(s1, l1);
if (out.equals("kasım")) {
m1 = true;
} else {
m1 = false;
}
assertEquals(m1, true);
}

@Test
public void gacheck() {
Conv ex2 = new Conv();
String s2 = "nATHAIR";
String l2 = "ga";
Boolean m2;
String out = ex2.trazConv(s2, l2);
if (out.equals("n-athair")) {
m2 = true;
} else {
m2 = false;
}
assertEquals(m2, true);
}

@Test
public void nochangeincasecheck() {
Conv ex3 = new Conversion();
String s3 = "ภาษาไทย";
String l3 = "th";
Boolean m3;
String out = ex3.allConv(s3, l3);
if (out.equals("ภาษาไทย")) {
m3 = true;
} else {
m3 = false;
}
assertEquals(m3, true);
}

@Test
public void elcheck() {
Conv ex4 = new Conversion();
String s4 = "Σ";
String l4 = "el";
Boolean m4;
String out = ex3.allConv(s3, l3);
if (out.equals("σ")) {
m4 = true;
} else {
m4 = false;
}
assertEquals(m4, true);
}
@Test
public void turkish1check() {
Conv ex5 = new Conversion();
String s5 = "KASM";
String l5 = "tr";
Boolean m5;
String out = ex5.trazConv(s5, l5);
if (out.equals("kasm")) {
m5 = true;
} else {
m5 = false;
}
assertEquals(m5, true);
}
}
Binary file added S23/pmirukula/Conversion.class
Binary file not shown.
56 changes: 56 additions & 0 deletions S23/pmirukula/Conversion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.*;
import java.util.Locale;

public class Conversion {
public static String trazConv(String str_lang, String str) {
if (str.contains("I")) {
str = str.replaceAll("I", "\u0131");
return str.toLowerCase(new Locale(str_lang));
} else {
return str.toLowerCase(new Locale(str_lang));
}
}

public static String gaConv(String str_lang, String str) {

if (("nt".indexOf(str.charAt(0)) != -1)
&& ("AEIOUÁÉÚÍÓ".indexOf(str.charAt(1)) != -1))

{
String k;
k = str.toLowerCase(new Locale(str_lang));
String m = (k.substring(0, 1) + "-" + k.substring(1));
return m;
} else {
return str.toLowerCase(new Locale(str_lang));
}

}

public static String allConv(String str_lang, String str) {
return (str.toLowerCase(new Locale(str_lang)));
}

PMIRUKULA marked this conversation as resolved.
Show resolved Hide resolved
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please enter the word");
String str = br.readLine();
System.out.println("Please enter the language you would like to translate the word");
String str_lang = br.readLine();
PrintWriter out = new PrintWriter("output.txt");
String output = str.toLowerCase(new Locale(str_lang));
if (str_lang.equals("tr") || str_lang.equals("az")) {
output = trazConv(str_lang, str);
} else if (str_lang.contains("ga")) {
output = gaConv(str_lang, str);
} else {
output = allConv(str_lang, str);
}
out.println(output);
out.close();
}

}
23 changes: 23 additions & 0 deletions S23/pmirukula/updatedtests.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
HELLO en hello
WORLD en-US world
cAmEl en-IE camel
---OK en-Latn ---ok
tAcht ga t-acht
tACHT ga t-acht
TACHT ga tacht
nAthair ga n-athair
nATHAIR ga n-athair
NATHAIR ga nathair
nÓg ga-IE n-óg
nÕg ga-IE nõg
nÕg ga-IE nõg
KASIM tr kasım
KASIM en kasim
ΠΌΛΗ el πόλης
官话 zh-Hans 官话
ภาษาไทย th ภาษาไทย
nATHAIR ga n-athair
nAr ga n-ar
ภาษาไท th ภาษาไท
Σ el σ