use of org.omegat.util.Language in project omegat by omegat-org.
the class HunspellTokenizer method langsToStrings.
private static String[] langsToStrings(Set<Language> langs) {
List<String> result = new ArrayList<String>(langs.size() * 2);
for (Language lang : langs) {
result.add(lang.getLanguage().toLowerCase(Locale.ENGLISH));
result.add(lang.getLanguageCode().toLowerCase(Locale.ENGLISH));
}
return result.toArray(new String[result.size()]);
}
use of org.omegat.util.Language in project omegat by omegat-org.
the class ExternalTMFactoryTest method setUp.
@Before
public final void setUp() {
Core.setSegmenter(new Segmenter(SRX.getDefault()));
FilterMaster.setFilterClasses(Arrays.asList(PoFilter.class, MozillaLangFilter.class));
Core.setFilterMaster(new FilterMaster(FilterMaster.createDefaultFiltersConfig()));
ProjectProperties props = new ProjectProperties() {
public Language getSourceLanguage() {
return new Language("en");
}
public Language getTargetLanguage() {
return new Language("pl");
}
@Override
public boolean isSentenceSegmentingEnabled() {
return true;
}
};
Core.setProject(new NotLoadedProject() {
@Override
public ProjectProperties getProjectProperties() {
return props;
}
});
}
use of org.omegat.util.Language in project omegat by omegat-org.
the class TmxSegmentationTest method testProjectTMX.
@Test
public void testProjectTMX() throws Exception {
ProjectProperties props = new ProjectProperties();
props.setSupportDefaultTranslations(true);
props.setSourceLanguage(new Language("en"));
props.setTargetLanguage(new Language("fr"));
props.setSentenceSegmentingEnabled(true);
ProjectTMX tmx = new ProjectTMX(props.getSourceLanguage(), props.getTargetLanguage(), props.isSentenceSegmentingEnabled(), new File("test/data/tmx/resegmenting.tmx"), new ProjectTMX.CheckOrphanedCallback() {
public boolean existSourceInProject(String src) {
return true;
}
public boolean existEntryInProject(EntryKey key) {
return true;
}
});
assertEquals(2, tmx.defaults.size());
assertEquals("Ceci est un test.", tmx.defaults.get("This is test.").translation);
assertEquals("Juste un test.", tmx.defaults.get("Just a test.").translation);
}
use of org.omegat.util.Language in project omegat by omegat-org.
the class TmxSegmentationTest method testExternalTMX.
@Test
public void testExternalTMX() throws Exception {
ExternalTMX tmx = new ExternalTMFactory.TMXLoader(new File("test/data/tmx/resegmenting.tmx")).setDoSegmenting(true).load(new Language("en"), new Language("fr"));
assertEquals(2, tmx.getEntries().size());
assertEquals("This is test.", tmx.getEntries().get(0).source);
assertEquals("Ceci est un test.", tmx.getEntries().get(0).translation);
assertEquals("Just a test.", tmx.getEntries().get(1).source);
assertEquals("Juste un test.", tmx.getEntries().get(1).translation);
}
use of org.omegat.util.Language in project omegat by omegat-org.
the class DictionaryDataTest method testLookup.
@Test
public void testLookup() {
DictionaryData<String> data = new DictionaryData<>(new Language(Locale.ENGLISH));
data.add("foobar", "bazbiz");
data.add("foobar", "buzzfizz");
data.add("ho\u0308ge", "hogehoge");
data.add("blah", "blooh");
data.add("BLAH", "blooh2");
// Test pre-finalized state
assertEquals(-1, data.size());
try {
data.lookUp("foobar");
fail();
} catch (IllegalStateException ex) {
// Not finalized yet
}
try {
data.lookUpPredictive("foobar");
fail();
} catch (IllegalStateException ex) {
// Not finalized yet
}
data.done();
assertEquals(4, data.size());
// Test normal lookup
List<Entry<String, String>> result = data.lookUp("foobar");
assertEquals(2, result.size());
assertEquals("bazbiz", result.get(0).getValue());
assertEquals("buzzfizz", result.get(1).getValue());
List<Entry<String, String>> presult = data.lookUpPredictive("foobar");
assertEquals(2, result.size());
assertEquals("bazbiz", presult.get(0).getValue());
assertEquals("buzzfizz", presult.get(1).getValue());
// Test case matching
result = data.lookUp("FOOBAR");
assertEquals(2, result.size());
assertEquals("bazbiz", result.get(0).getValue());
assertEquals("foobar", result.get(0).getKey());
assertEquals("buzzfizz", result.get(1).getValue());
assertEquals("foobar", result.get(1).getKey());
// Test case differentiation
result = data.lookUp("blah");
assertEquals(2, result.size());
assertEquals("blooh", result.get(0).getValue());
assertEquals("blah", result.get(0).getKey());
assertEquals("blooh2", result.get(1).getValue());
assertEquals("blah", result.get(1).getKey());
result = data.lookUp("BLAH");
assertEquals(1, result.size());
assertEquals("blooh2", result.get(0).getValue());
assertEquals("BLAH", result.get(0).getKey());
// Test prediction
presult = data.lookUpPredictive("foo");
assertEquals(2, presult.size());
assertEquals("bazbiz", presult.get(0).getValue());
assertEquals("foobar", presult.get(0).getKey());
assertEquals("buzzfizz", presult.get(1).getValue());
assertEquals("foobar", presult.get(1).getKey());
result = data.lookUp("foo");
assertTrue(result.isEmpty());
// Test Unicode normalization
result = data.lookUp("h\u00f6ge");
assertEquals(1, result.size());
assertEquals("hogehoge", result.get(0).getValue());
// Test non-existent key
result = data.lookUp("zzzz");
assertTrue(result.isEmpty());
}
Aggregations