Commit 79018720 authored by Seyed Reza  Sajjadinasab's avatar Seyed Reza Sajjadinasab
Browse files

Merge branch 'Reza' into 'master'

updateTurkishAccuracy

See merge request ec504/ec504_projects/group6!71
parents f849b9ed 18c9a14f
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public class Checker {
                for (String sentence : extractedSentences) {
                    i++;
                    //dbInterface.updateTokenInDatabase(sentence.toLowerCase(), graph);
                    sentence = StringProcessor.handleApostrophe(sentence.toLowerCase());
                    sentence = StringProcessor.handleApostrophe(sentence.toLowerCase(), argPars.isTurkish());
                    PhraseExtractor extractorPhrase = PhraseExtractor.fromSentence(sentence, 3, 5);
                    List<String> phrases = extractorPhrase.getPhrases();
                    for (String phrase : phrases) {
@@ -79,7 +79,7 @@ public class Checker {
                System.out.println("\n-------------------------------------------\n"+ "Number of update: "+ cntUpdate);
            }else if(argPars.isCheckSentence()){
                //dbInterface.updateTokenInDatabase(argPars.getSentence().toLowerCase(), graph);
                for (String phrase : PhraseExtractor.fromSentence(StringProcessor.handleApostrophe(argPars.getSentence()),3, 5).getPhrases()) {
                for (String phrase : PhraseExtractor.fromSentence(StringProcessor.handleApostrophe(argPars.getSentence(), argPars.isTurkish()),3, 5).getPhrases()) {
                    dbInterface.updateTokenInDatabase(phrase.toLowerCase(), graph);                    
                }
            }
@@ -105,7 +105,7 @@ public class Checker {
                        manager = new HashTableMaker("SQLite/hash_database_english.db");
                    }
                    for (String sentence : extractedSentences) {
                        sentence = StringProcessor.handleApostrophe(sentence.toLowerCase());
                        sentence = StringProcessor.handleApostrophe(sentence.toLowerCase(), argPars.isTurkish());
                        manager.updateDatabase(sentence.toLowerCase());
                        PhraseExtractor extractorPhrase = PhraseExtractor.fromSentence(sentence, 1, 4);
                        List<String> phrases = extractorPhrase.getPhrases();
@@ -120,8 +120,8 @@ public class Checker {
            }else if(argPars.isCheckSentence()){
                try {
                    HashTableMaker manager = new HashTableMaker("SQLite/hash_database_english.db");
                    manager.updateDatabase(StringProcessor.handleApostrophe(argPars.getSentence().toLowerCase()));
                    for (String phrase : PhraseExtractor.fromSentence(StringProcessor.handleApostrophe(argPars.getSentence().toLowerCase()),1, 4).getPhrases()) {
                    manager.updateDatabase(StringProcessor.handleApostrophe(argPars.getSentence().toLowerCase(), argPars.isTurkish()));
                    for (String phrase : PhraseExtractor.fromSentence(StringProcessor.handleApostrophe(argPars.getSentence().toLowerCase(), argPars.isTurkish()),1, 4).getPhrases()) {
                        manager.updateDatabase(phrase.toLowerCase());                      
                    }
                    manager.closeConnection();
@@ -136,7 +136,7 @@ public class Checker {
                HashTableMaker manager = new HashTableMaker("SQLite/hash_database_english.db");
                for (String sentence : extractedSentences) {
                    System.out.println("Sentence: " + sentence);
                    sentence = StringProcessor.handleApostrophe(sentence.toLowerCase());
                    sentence = StringProcessor.handleApostrophe(sentence.toLowerCase(), argPars.isTurkish());
                    System.out.println("*********************************************************");
                    PhraseExtractor extractorPhrase = PhraseExtractor.fromSentence(sentence);
                    List<String> phrases = extractorPhrase.getPhrases();
@@ -165,13 +165,13 @@ public class Checker {
            try {
                HashTableMaker manager = new HashTableMaker("SQLite/hash_database_english.db");
                System.out.println("Sentence: " + argPars.getSentence());
                String sentence = StringProcessor.handleApostrophe(argPars.getSentence().toLowerCase());
                String sentence = StringProcessor.handleApostrophe(argPars.getSentence().toLowerCase(), argPars.isTurkish());
                int ngram        = manager.nGram(sentence, 3);
                int stateMachine = dbInterface.checkTokenInDatabase(sentence.toLowerCase(), graph);
                int conf         = (ngram>=0)?(int)(ngram*0.2+stateMachine*0.8):stateMachine;
                jsonMaker.addSentence(sentence, conf);
                System.out.println("*********************************************************");
                PhraseExtractor extractorPhrase = PhraseExtractor.fromSentence(StringProcessor.handleApostrophe(argPars.getSentence().toLowerCase()));
                PhraseExtractor extractorPhrase = PhraseExtractor.fromSentence(StringProcessor.handleApostrophe(argPars.getSentence().toLowerCase(), argPars.isTurkish()));
                List<String> phrases = extractorPhrase.getPhrases();
                for (String phrase : phrases) {
                    ngram        = manager.nGram(phrase.toLowerCase(), 3);
+12 −11
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import Translator.DirectTranslatorEnglishToDutch;
import DBinterface.DBinterface;
import DirectedGraph.BasicGraph;
import DirectedGraph.DirectedGraph;
@@ -46,7 +47,7 @@ public class Corrector implements GUIListener {
        this.stringWriterGUI = StringFileWriter.of("corrected.txt");
        this.senteceIndGUI = 0;
        this.curSentenceGUI = extractedSentencesGUI.get(0);
        this.curSentenceGUI = StringProcessor.handleApostrophe(this.curSentenceGUI.toLowerCase());
        this.curSentenceGUI = StringProcessor.handleApostrophe(this.curSentenceGUI.toLowerCase(), this.argParsGUI.isTurkish());
        String tempString = dbInterfaceGUI.correctTokenInDatabase(this.curSentenceGUI.toLowerCase(), graphGUI, 1, false);
        SelectCorrectionGUI gui = new SelectCorrectionGUI(this, this.curSentenceGUI);
    }
@@ -70,7 +71,7 @@ public class Corrector implements GUIListener {
            this.curSentenceGUI = tempString;
            String tempSentenceGUI = dbInterfaceGUI.correctTokenInDatabase(this.curSentenceGUI.toLowerCase(), graphGUI, 1, false);
        }
        this.curSentenceGUI = StringProcessor.handleApostrophe(this.curSentenceGUI.toLowerCase());
        this.curSentenceGUI = StringProcessor.handleApostrophe(this.curSentenceGUI.toLowerCase(), this.argParsGUI.isTurkish());
        return this.curSentenceGUI;
    }

@@ -92,7 +93,7 @@ public class Corrector implements GUIListener {
        }
        
        this.curSentenceGUI = extractedSentencesGUI.get(senteceIndGUI);
        this.curSentenceGUI = StringProcessor.handleApostrophe(this.curSentenceGUI.toLowerCase());
        this.curSentenceGUI = StringProcessor.handleApostrophe(this.curSentenceGUI.toLowerCase(), this.argParsGUI.isTurkish());
        String tempSentenceGUI = dbInterfaceGUI.correctTokenInDatabase(this.curSentenceGUI.toLowerCase(), graphGUI, 1, false);
        return this.curSentenceGUI;

@@ -129,7 +130,7 @@ public class Corrector implements GUIListener {
        if(argPars.isUpdateWordSimilarity()){
            if(argPars.isCheckFile()){
                wordPairDatabase.createTable();
                wordPairDatabase.processSentences(argPars.getFileName());
                wordPairDatabase.processSentences(argPars.getFileName(), argPars.isTurkish());
            }
        }else if(argPars.isTranslateToDutch()){
            DirectTranslatorEnglishToDutch directTranslator = DirectTranslatorEnglishToDutch.make();
@@ -139,7 +140,7 @@ public class Corrector implements GUIListener {
                List<String> extractedSentences = extractor.getSentences();
                for (String sentence : extractedSentences) {
                    System.out.println("Sentence: " + sentence);
                    sentence = StringProcessor.handleApostrophe(sentence.toLowerCase());
                    sentence = StringProcessor.handleApostrophe(sentence.toLowerCase(), argPars.isTurkish());
                    String tempString = directTranslator.replaceWordsInSentence(sentence.toLowerCase());
                    stringWriter.appendString(tempString);
                    System.out.println("##########################################################");
@@ -147,7 +148,7 @@ public class Corrector implements GUIListener {
            }else{
                
                System.out.println("Sentence: " + argPars.getSentence());
                String tempString = directTranslator.replaceWordsInSentence(StringProcessor.handleApostrophe(argPars.getSentence().toLowerCase()));
                String tempString = directTranslator.replaceWordsInSentence(StringProcessor.handleApostrophe(argPars.getSentence().toLowerCase(), argPars.isTurkish()));
                stringWriter.appendString(tempString);
                System.out.println("Translation: "+tempString);
                System.out.println("##########################################################");
@@ -166,7 +167,7 @@ public class Corrector implements GUIListener {
                List<String> extractedSentences = extractor.getSentences();
                for (String sentence : extractedSentences) {
                    System.out.println("Sentence: " + sentence);
                    sentence = StringProcessor.handleApostrophe(sentence.toLowerCase());
                    sentence = StringProcessor.handleApostrophe(sentence.toLowerCase(), argPars.isTurkish());
                    String tempString = directTranslator.replaceWordsInSentence(sentence.toLowerCase());
                    stringWriter.appendString(tempString);
                    System.out.println("##########################################################");
@@ -174,7 +175,7 @@ public class Corrector implements GUIListener {
            }else{
                
                System.out.println("Sentence: " + argPars.getSentence());
                String tempString = directTranslator.replaceWordsInSentence(StringProcessor.handleApostrophe(argPars.getSentence().toLowerCase()));
                String tempString = directTranslator.replaceWordsInSentence(StringProcessor.handleApostrophe(argPars.getSentence().toLowerCase(), argPars.isTurkish()));
                stringWriter.appendString(tempString);
                System.out.println("Translation: "+tempString);
                System.out.println("##########################################################");
@@ -195,7 +196,7 @@ public class Corrector implements GUIListener {
                List<String> extractedSentences = extractor.getSentences();
                for (String sentence : extractedSentences) {
                    System.out.println("Sentence: " + sentence);
                    sentence = StringProcessor.handleApostrophe(sentence.toLowerCase());
                    sentence = StringProcessor.handleApostrophe(sentence.toLowerCase(), argPars.isTurkish());
                    String tempString = dbInterface.correctTokenInDatabase(sentence.toLowerCase(), graph, 2, true);
                    stringWriter.appendString(tempString);

@@ -211,11 +212,11 @@ public class Corrector implements GUIListener {
            }
        }else if(argPars.isCheckSentence()){
            if(argPars.isCorrectionGUI()){  
                Corrector corrector = new Corrector(SentenceExtractor.ofLine(StringProcessor.handleApostrophe(argPars.getSentence().toLowerCase())), argPars);  
                Corrector corrector = new Corrector(SentenceExtractor.ofLine(StringProcessor.handleApostrophe(argPars.getSentence().toLowerCase(), argPars.isTurkish())), argPars);  
                corrector.start();
            }else{
                System.out.println("Sentence: " + argPars.getSentence());
                stringWriter.appendString(dbInterface.correctTokenInDatabase(StringProcessor.handleApostrophe(argPars.getSentence().toLowerCase()), graph, 2, true));
                stringWriter.appendString(dbInterface.correctTokenInDatabase(StringProcessor.handleApostrophe(argPars.getSentence().toLowerCase(), argPars.isTurkish()), graph, 2, true));
                try {
                    stringWriter.writeToFile();
                    System.out.println("Corrected version has been written to the file.");
+2 −2
Original line number Diff line number Diff line
@@ -113,8 +113,8 @@ public class HighlighterGUI extends JFrame {
            }
            
            for (String phrase : phrases) {
                double conf = dbInterface.checkTokenInDatabase(StringProcessor.handleApostrophe(phrase), basicGraphClass.getGraph())*0.8;   
                conf += manager.nGram(StringProcessor.handleApostrophe(phrase), 3)*0.2;
                double conf = dbInterface.checkTokenInDatabase(StringProcessor.handleApostrophe(phrase, isTurkish), basicGraphClass.getGraph())*0.8;   
                conf += manager.nGram(StringProcessor.handleApostrophe(phrase, isTurkish), 3)*0.2;
                //System.out.println(phrase + "| "+ conf);
                highlightPhrase(phrase, (int)conf);
            }
+261 −1
Original line number Diff line number Diff line
@@ -56,3 +56,263 @@ biliyorum verb knowing
biliyor verb knowing
bildim verb knew
bilmiş verb known

ben pronoun i
sen pronoun you (singular, informal)
o pronoun he/she/it
biz pronoun we
siz pronoun you (plural or formal singular)
onlar pronoun they
bu pronoun this
şu pronoun that (nearby/within sight)

elma noun apple
portakal noun orange
muz noun banana
telefon noun phone
bilgisayar noun computer
televizyon noun television
araba noun car
ev noun house
bahçe noun garden
ağaç noun tree
çiçek noun flower
kitap noun book
kalem noun pen
defter noun notebook
masa noun table
sandalye noun chair
yatak noun bed
yastık noun pillow
kapı noun door
pencere noun window
halı noun carpet
lamba noun lamp
saat noun clock
ayna noun mirror
tablo noun painting
fotoğraf noun photograph
anahtar noun key
şemsiye noun umbrella
çanta noun bag
ayakkabı noun shoe
elbise noun dress
gömlek noun shirt
pantolon noun pants
ceket noun coat
çorap noun socks
eldiven noun gloves
şapka noun hat
cüzdan noun wallet
para noun money
bilet noun ticket
pasaport noun passport
vize noun visa 
harita noun map
pusula noun compass
şişe noun bottle
su noun water
meyve noun fruit
suyu noun juice
kahve noun coffee
çay noun tea
süt noun milk
ekmek noun bread
peynir noun cheese
yumurta noun egg
et noun meat
balık noun fish
tavuk noun chicken
pirinç noun rice
makarna noun pasta
salata noun salad
çorba noun soup
tuz noun salt
biber noun pepper
şeker noun sugar
yağ noun oil
sirke noun vinegar
bıçak noun knife
çatal noun fork
kaşık noun spoon
tabak noun plate
bardak noun glass
fincan noun cup
okul noun school
öğrenci noun student
öğretmen noun teacher
otobüs noun bus
hastane noun hospital
doktor noun doctor
hemşire noun nurse
polis noun police officer
market noun market
fırın noun bakery
eczane noun pharmacy
anne noun mother
baba noun father
kardeş noun sibling
arkadaş noun friend
güneş noun sun
ay noun moon
yıldız noun star
gezegen noun planet
gökyüzü noun sky
bulut noun cloud
yağmur noun rain
kar noun snow
rüzgar noun wind
deniz noun sea
sahil noun beach
kum noun sand
orman noun forest
ağaç noun tree
yaprak noun leaf
çiçek noun flower
hayvan noun animal
kuş noun bird
balık noun fish
böcek noun insect
yol noun road
köprü noun bridge
bina noun building
sokak noun street
dükkan noun shop
restoran noun restaurant
mutfak noun kitchen
oda noun room
yatak noun bed
masa noun table
sandalye noun chair
televizyon noun television
bilgisayar noun computer
renk noun color
kırmızı noun red
mavi noun blue
yeşil noun green
sarı noun yellow
turuncu noun orange
mor noun purple
siyah noun black
beyaz noun white
kahverengi noun brown
pembe noun pink
gri noun gray
gün noun day
hafta noun week
ay noun month
yıl noun year
saat noun hour
dakika noun minute
saniye noun second
zaman noun time
sabah noun morning
öğle noun noon
akşam noun evening
gece noun night
sıcak noun hot
soğuk noun cold
iyi noun good
kötü noun bad
büyük noun big
küçük noun small
uzun noun long
kısa noun short
kolay noun easy
zor noun difficult
güzel adjective beautiful
yakışıklı adjective handsome
çirkin adjective ugly
genç adjective young
yaşlı adjective old
uzun adjective tall
kısa adjective short
şişman adjective fat
zayıf adjective thin
akıllı adjective smart
aptal adjective stupid
zengin adjective rich
fakir adjective poor
mutlu adjective happy
üzgün adjective sad
kızgın adjective angry
hasta adjective sick
yorgun adjective tired
aç adjective hungry
tok adjective full
temiz adjective clean
kirli adjective dirty
hızlı adjective fast
yavaş adjective slow
yeni adjective new
eski adjective old (for objects)
sıcak adjective hot
soğuk adjective cold
lezzetli adjective delicious
tatsız adjective tasteless
güçlü adjective strong
zayıf adjective weak (not just physically)
korkak adjective cowardly
cesur adjective brave
komik adjective funny
sıkıcı adjective boring
ilginç adjective interesting
tehlikeli adjective dangerous
güvenli adjective safe
pahalı adjective expensive
ucuz adjective cheap
dolu adjective full
boş adjective empty
sert adjective hard
yumuşak adjective soft
kuru adjective dry
ıslak adjective wet
karanlık adjective dark
aydınlık adjective light/bright
çabuk adverb quickly
yavaşça adverb slowly
dikkatlice adverb carefully
kolayca adverb easily
sık sık adverb often
bazen adverb sometimes
asla adverb never
her zaman adverb always
burada adverb here
orada adverb there
şurada adverb nearby
yukarıda adverb above
aşağıda adverb below
ileride adverb forward
geride adverb behind
neşeyle adverb happily
üzgünce adverb sadly
sessizce adverb quietly
gürültüyle adverb loudly
kibarca adverb politely
kaba bir şekilde adverb rudely
aceleyle adverb hurriedly
sabırla adverb patiently
birlikte adverb together
yalnız adverb alone
hemen adverb immediately
şimdi adverb now
sonra adverb later
zaten adverb already
henüz adverb yet (as in "not yet")
hâlâ adverb still
daha adverb more
az adverb less
çok adverb very
biraz adverb a little
yeterince adverb enough
den preposition from
dan preposition from
ile preposition with
la  preposition with
için preposition inside
e preposition to
a preposition a 
üzerine preposition on
i preposition object

Loading