Translator.java in android app now tries to find the lowercased first word in the lexicon if uppercased fails; added Est and Rus in the help file

This commit is contained in:
aarne
2017-04-12 14:21:54 +00:00
parent ee93c25d19
commit 173cd00873
2 changed files with 30 additions and 4 deletions

View File

@@ -2,7 +2,7 @@
<body>
</p>
<b>GF Offline Translator</b>:
text and speech translation for 14 languages with
text and speech translation for 16 languages with
quality control
</p>
<p>
@@ -82,15 +82,17 @@ The following table gives a rough idea of what to expect:
<tr> <th></th> <th>coverage</th> <th>quality</th> <th>speed</th> <th>speech</th> </tr>
<tr> <th>Bulgarian</th> <td bgcolor=yellow></td> <td bgcolor=yellow></td><td bgcolor=palegreen></td> <td bgcolor=yellow>in only</td></tr>
<tr> <th>Catalan</th> <td bgcolor=pink></td> <td bgcolor=yellow></td><td bgcolor=pink></td> <td bgcolor=yellow>in only</td></tr>
<tr> <th>Chinese*</th> <td bgcolor=pink></td> <td bgcolor=pink></td> <td bgcolor=palegreen></td> <td bgcolor=yellow></td> </tr>
<tr> <th>Chinese*</th> <td bgcolor=pink></td> <td bgcolor=pink></td> <td bgcolor=palegreen></td> <td bgcolor=yellow></td> </tr>
<tr> <th>Dutch</th> <td bgcolor=yellow></td> <td bgcolor=yellow></td> <td bgcolor=yellow></td> <td bgcolor=palegreen></td> </tr>
<tr> <th>English</th> <td bgcolor=palegreen></td> <td bgcolor=palegreen></td> <td bgcolor=palegreen></td> <td bgcolor=palegreen></td> </tr>
<tr> <th>Estonian</th> <td bgcolor=yellow></td> <td bgcolor=yellow></td><td bgcolor=pink></td> <td bgcolor=red></td></tr>
<tr> <th>Finnish</th> <td bgcolor=yellow></td> <td bgcolor=yellow></td><td bgcolor=pink></td> <td bgcolor=yellow>in only</td></tr>
<tr> <th>French</th> <td bgcolor=pink></td> <td bgcolor=yellow></td><td bgcolor=pink></td> <td bgcolor=palegreen></td></tr>
<tr> <th>German</th> <td bgcolor=pink></td> <td bgcolor=yellow></td><td bgcolor=pink></td> <td bgcolor=palegreen></td></tr>
<tr> <th>Hindi</th> <td bgcolor=pink></td> <td bgcolor=red></td> <td bgcolor=yellow></td> <td bgcolor=yellow>in only</td> </tr>
<tr> <th>Italian</th> <td bgcolor=pink></td> <td bgcolor=pink></td><td bgcolor=pink></td> <td bgcolor=palegreen></td></tr>
<tr> <th>Japanese**</th> <td bgcolor=pink></td> <td bgcolor=pink></td><td bgcolor=yellow></td> <td bgcolor=palegreen></td></tr>
<tr> <th>Japanese**</th><td bgcolor=pink></td> <td bgcolor=pink></td><td bgcolor=yellow></td> <td bgcolor=palegreen></td></tr>
<tr> <th>Russian</th> <td bgcolor=pink></td> <td bgcolor=red></td> <td bgcolor=yellow></td> <td bgcolor=yellow></td> </tr>
<tr> <th>Spanish</th> <td bgcolor=pink></td> <td bgcolor=yellow></td><td bgcolor=pink></td> <td bgcolor=palegreen></td></tr>
<tr> <th>Swedish</th> <td bgcolor=yellow></td> <td bgcolor=yellow></td> <td bgcolor=palegreen></td> <td bgcolor=yellow>in only</td></tr>
<tr> <th>Thai**</th> <td bgcolor=pink></td> <td bgcolor=pink></td><td bgcolor=yellow></td> <td bgcolor=palegreen></td></tr>

View File

@@ -291,6 +291,28 @@ public class Translator {
return output ;
}
// lowercase the first word if (1) it is not in the lexicon and (2) its lowercase version is in the lexicon
// otherwise it will be left uppercase and treated as a name
private String lowercaseIfBetter(String input) {
String[] words = input.split(" ") ;
String firstword = words[0] ;
String lowerfirstword = firstword.toLowerCase() ;
if (lookupMorpho(firstword).isEmpty() && !(lookupMorpho(lowerfirstword).isEmpty())) {
words[0] = lowerfirstword ;
String output = "" ;
for (String w : words) {
output = output + " " + w ;
}
return output ;
} else {
return input ;
}
}
/**
* Takes a lot of time. Must not be called on the main thread.
*/
@@ -298,7 +320,9 @@ public class Translator {
if (getSourceLanguage().getLangCode().equals("cmn-Hans-CN")) {
// for Chinese we need to put space after every character
input = explode(input);
}
} else {
input = lowercaseIfBetter(input);
} ;
String output = null;
List<ExprProb> exprs = new ArrayList<ExprProb>();