From 6e96ebe6145fb4fba7d7e3f758dcc98621ebecb7 Mon Sep 17 00:00:00 2001 From: mepripri Date: Wed, 15 Feb 2023 19:32:05 -0600 Subject: [PATCH 1/3] Code to Change Words to LowerCase --- S23/mepripri/ToLowerCase.py | 49 +++++++++++++++++++++++++++++++++++++ S23/mepripri/tests.tsv | 15 ++++++++++-- 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 S23/mepripri/ToLowerCase.py diff --git a/S23/mepripri/ToLowerCase.py b/S23/mepripri/ToLowerCase.py new file mode 100644 index 00000000..a465d81d --- /dev/null +++ b/S23/mepripri/ToLowerCase.py @@ -0,0 +1,49 @@ +import csv + +def splitLang(l): + l=l.split('-') + if len(l[0])==2: + l=l[0] + return l + +def toLower(s,lang): + str='' + first=0 + lang=splitLang(lang) + if lang=='tr' or lang=='az': + for i in s: + if ord(i)==73: + str+=chr(305) + else: + str+=i.lower() + elif lang=='ga': + first=0 + for i in range(len(s)): + if i==0: + if (s[0]=='n' or s[0]=='t') and s[1] in ['A','E','I','O','U','Á','É','Í','Ó','Ú']: + str+=s[0].lower()+'-'+s[1].lower() + first=1 + else: + str+=s[i].lower() + elif i==1 and first==1: + continue + else: + str+=s[i].lower() + elif lang=='el': + if ord(s[-1])==931: + str+=s[:-1].lower() + str+=chr(962) + else: + str=str+s.lower() + elif lang=='zh' or lang=='th' or lang=='ja' or lang=='en': + str+=s.lower() + else: + str+='Invalid Language' + return str + + +with open("tests.tsv") as file: + read = csv.reader(file,delimiter="\t") + for r in read: + print("Word : ",r[0]) + print("Lowercase : ",toLower(r[0],r[1]),"\n") diff --git a/S23/mepripri/tests.tsv b/S23/mepripri/tests.tsv index bb7a831e..3e28083a 100644 --- a/S23/mepripri/tests.tsv +++ b/S23/mepripri/tests.tsv @@ -1,5 +1,6 @@ HELLO en hello WORLD en-US world +WORLD eng-US Invalid Language cAmEl en-IE camel ---OK en-Latn ---ok tAcht ga t-acht @@ -7,12 +8,22 @@ tACHT ga t-acht TACHT ga tacht nAthair ga n-athair nATHAIR ga n-athair -NATHAIR ga nathair +NATHAIR ga-IE nathair +fÚG ga fúg +tNÚG ga tnúg +tÚG ga t-úg nÓg ga-IE n-óg nÕg ga-IE nõg -nÕg ga-IE nõg +nÕg ga-IE nõg +ÜNİVERSITESİ tr üni̇versıtesi̇ +İSTANBUL az i̇stanbul KASIM tr kasım KASIM en kasim ΠΌΛΗΣ el πόλης +ΠΌΣΛΗ el πόσλη +ΠΌΗ el πόη +ΣΣ el σς 官话 zh-Hans 官话 ภาษาไทย th ภาษาไทย +資本主義 ja 資本主義 +丹麦的首都 zh 丹麦的首都 From 53ed85244b7a21091572491bbf459b4e4f5dfe4f Mon Sep 17 00:00:00 2001 From: mepripri Date: Fri, 17 Feb 2023 15:20:46 -0600 Subject: [PATCH 2/3] Changes Made --- S23/mepripri/ToLowerCase.py | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/S23/mepripri/ToLowerCase.py b/S23/mepripri/ToLowerCase.py index a465d81d..ee61abc6 100644 --- a/S23/mepripri/ToLowerCase.py +++ b/S23/mepripri/ToLowerCase.py @@ -1,10 +1,8 @@ import csv -def splitLang(l): - l=l.split('-') - if len(l[0])==2: - l=l[0] - return l +def splitLang(lang): + lang=lang.split('-') + return lang[0] def toLower(s,lang): str='' @@ -12,38 +10,30 @@ def toLower(s,lang): lang=splitLang(lang) if lang=='tr' or lang=='az': for i in s: - if ord(i)==73: + if i=='I': str+=chr(305) else: str+=i.lower() elif lang=='ga': - first=0 - for i in range(len(s)): - if i==0: - if (s[0]=='n' or s[0]=='t') and s[1] in ['A','E','I','O','U','Á','É','Í','Ó','Ú']: - str+=s[0].lower()+'-'+s[1].lower() - first=1 - else: - str+=s[i].lower() - elif i==1 and first==1: - continue - else: - str+=s[i].lower() + if (s[0]=='n' or s[0]=='t') and s[1] in ['A','E','I','O','U','Á','É','Í','Ó','Ú']: + str+=s[0].lower()+'-'+s[1:].lower() + else: + str+=s.lower() elif lang=='el': if ord(s[-1])==931: str+=s[:-1].lower() str+=chr(962) else: str=str+s.lower() - elif lang=='zh' or lang=='th' or lang=='ja' or lang=='en': - str+=s.lower() - else: + elif len(lang)!=2: str+='Invalid Language' + else: + str+=s.lower() return str - + with open("tests.tsv") as file: read = csv.reader(file,delimiter="\t") for r in read: print("Word : ",r[0]) - print("Lowercase : ",toLower(r[0],r[1]),"\n") + print("Lowercase : ",toLower(r[0],r[1]),"\n") \ No newline at end of file From e52c93b91f259d88676c178e2ef2b2749046cf9e Mon Sep 17 00:00:00 2001 From: mepripri Date: Wed, 22 Feb 2023 15:29:03 -0600 Subject: [PATCH 3/3] Tests for Triangle Functions --- S23/mepripri/myers.tsv | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/S23/mepripri/myers.tsv b/S23/mepripri/myers.tsv index 42ee3390..54037e75 100644 --- a/S23/mepripri/myers.tsv +++ b/S23/mepripri/myers.tsv @@ -1,3 +1,25 @@ {"a" : 3, "b" : 4, "c" : 5} scalene +{"a" : 9, "b" : 6, "c" : 8} scalene +{"a" : 9.5, "b" : 6.4, "c" : 8.6} scalene +{"a" : 9, "b" : 6.5, "c" : 8.5} scalene {"a" : 3, "b" : 3, "c" : 1} isosceles +{"a" : 3.5, "b" : 1, "c" : 3.5} isosceles +{"a" : 3.5, "b" : 1.5, "c" : 3.5} isosceles +{"a" : 3.0, "b" : 1.0, "c" : 3} isosceles +{"a" : 3, "b" : 3, "c" : 3} equilateral +{"a" : 3.4, "b" : 3.4, "c" : 3.4} equilateral +{"a" : 3.0, "b" : 3, "c" : 3} equilateral +{"a" : 3.0, "b" : 3.0, "c" : 3} equilateral +{"a" : , "b" : , "c" : } error +{"a" : , "b" : 4, "c" : 100} error +{"a" : 3, "b" : , "c" : 100} error +{"a" : 3, "b" : 4, "c" : } error +{"a" : 3, "b" : , "c" : } error +{"a" : , "b" : 4, "c" : } error +{"a" : , "b" : , "c" : 100} error {"a" : 3, "b" : 4, "c" : 100} error +{"a" : 3.5, "b" : 4.5, "c" : 10} error +{"a" : 3, "b" : 4, "c" : 7} error +{"a" : 3.5, "b" : 4.5, "c" : 8} error +{"a" : 3.5, "b" : 4.5, "c" : } error +{"a" : 3.5, "b" : , "c" : 4.5} error