use of org.omegat.core.segmentation.Segmenter in project omegat by omegat-org.
the class Core method initializeGUI.
/**
* Initialize application components.
*/
public static void initializeGUI(final Map<String, String> params) throws Exception {
cmdLineParams = params;
// 1. Initialize project
currentProject = new NotLoadedProject();
// 2. Initialize application frame
MainWindow me = new MainWindow();
mainWindow = me;
// Load recent used projects
RecentProjects.updateMenu();
Core.registerMarker(new ProtectedPartsMarker());
Core.registerMarker(new RemoveTagMarker());
Core.registerMarker(new NBSPMarker());
Core.registerMarker(new TransTipsMarker());
Core.registerMarker(new WhitespaceMarkerFactory.SpaceMarker());
Core.registerMarker(new WhitespaceMarkerFactory.TabMarker());
Core.registerMarker(new WhitespaceMarkerFactory.LFMarker());
Core.registerMarker(new BidiMarkerFactory.RLMMarker());
Core.registerMarker(new BidiMarkerFactory.LRMMarker());
Core.registerMarker(new BidiMarkerFactory.PDFMarker());
Core.registerMarker(new BidiMarkerFactory.LROMarker());
Core.registerMarker(new BidiMarkerFactory.RLOMarker());
Core.registerMarker(new ReplaceMarker());
Core.registerMarker(new ComesFromAutoTMMarker());
Core.registerMarker(new FontFallbackMarker());
LanguageToolWrapper.init();
segmenter = new Segmenter(Preferences.getSRX());
filterMaster = new FilterMaster(Preferences.getFilters());
// 3. Initialize other components. They add themselves to the main window.
editor = new EditorController(me);
tagValidation = new TagValidationTool();
issuesWindow = new IssuesPanelController(me);
matcher = new MatchesTextArea(me);
GlossaryTextArea glossaryArea = new GlossaryTextArea(me);
glossary = glossaryArea;
glossaryManager = new GlossaryManager(glossaryArea);
notes = new NotesTextArea(me);
comments = new CommentsTextArea(me);
machineTranslatePane = new MachineTranslateTextArea(me);
dictionaries = new DictionariesTextArea(me);
spellChecker = new SpellChecker();
multiple = new MultipleTransPane(me);
new SegmentPropertiesArea(me);
SaveThread th = new SaveThread();
saveThread = th;
th.start();
}
use of org.omegat.core.segmentation.Segmenter in project omegat by omegat-org.
the class RealProject method loadProject.
/**
* Load exist project in a "big" sense -- loads project's properties, glossaries, tms, source files etc.
*/
public synchronized void loadProject(boolean onlineMode) {
Log.logInfoRB("LOG_DATAENGINE_LOAD_START");
UIThreadsUtil.mustNotBeSwingThread();
// load new project
try {
if (!lockProject()) {
throw new KnownException("PROJECT_LOCKED");
}
isOnlineMode = onlineMode;
if (RuntimePreferences.isLocationSaveEnabled()) {
Preferences.setPreference(Preferences.CURRENT_FOLDER, new File(config.getProjectRoot()).getAbsoluteFile().getParent());
Preferences.save();
}
Core.getMainWindow().showStatusMessageRB("CT_LOADING_PROJECT");
if (remoteRepositoryProvider != null) {
tmxPrepared = null;
glossaryPrepared = null;
remoteRepositoryProvider.switchAllToLatest();
// Add filters.xml and segmentation.conf
for (String file : new String[] { '/' + config.getProjectInternalRelative() + FilterMaster.FILE_FILTERS, '/' + config.getProjectInternalRelative() + SRX.CONF_SENTSEG }) {
remoteRepositoryProvider.copyFilesFromRepoToProject(file);
}
// After adding filters.xml and segmentation.conf, we must reload them again
config.loadProjectFilters();
config.loadProjectSRX();
loadFilterSettings();
loadTranslations();
Core.getMainWindow().showStatusMessageRB("TEAM_REBASE_AND_COMMIT");
rebaseAndCommitProject(true);
// retrieve other directories
remoteRepositoryProvider.switchAllToLatest();
for (String dir : new String[] { config.getSourceDir().getUnderRoot(), config.getGlossaryDir().getUnderRoot(), config.getTmDir().getUnderRoot(), config.getDictDir().getUnderRoot() }) {
if (dir == null || dir.contains("..")) {
continue;
}
// copy but skip project_save.tmx and glossary.txt
remoteRepositoryProvider.copyFilesFromRepoToProject(dir, '/' + config.getProjectInternalRelative() + OConsts.STATUS_EXTENSION, '/' + config.getWritableGlossaryFile().getUnderRoot());
}
} else {
loadFilterSettings();
loadTranslations();
}
// Set project specific segmentation rules if they exist, or defaults otherwise.
// This can be done after loadTranslations(), as segmentation is not used for this
SRX srx = Optional.ofNullable(config.getProjectSRX()).orElse(Preferences.getSRX());
Core.setSegmenter(new Segmenter(srx));
loadSourceFiles();
allProjectEntries = Collections.unmodifiableList(allProjectEntries);
importHandler = new ImportFromAutoTMX(this, allProjectEntries);
importTranslationsFromSources();
loadTM();
loadOtherLanguages();
// build word count
String stat = CalcStandardStatistics.buildProjectStats(this, hotStat);
String fn = config.getProjectInternal() + OConsts.STATS_FILENAME;
Statistics.writeStat(fn, stat);
loaded = true;
// Project Loaded...
Core.getMainWindow().showStatusMessageRB(null);
setProjectModified(false);
} catch (Exception e) {
Log.logErrorRB(e, "TF_LOAD_ERROR");
Core.getMainWindow().displayErrorRB(e, "TF_LOAD_ERROR");
if (!loaded) {
unlockProject();
}
} catch (OutOfMemoryError oome) {
// Fix for bug 1571944 @author Henry Pijffers
// (henry.pijffers@saxnot.com)
// Oh shit, we're all out of storage space!
// Of course we should've cleaned up after ourselves earlier,
// but since we didn't, do a bit of cleaning up now, otherwise
// we can't even inform the user about our slacking off.
allProjectEntries.clear();
projectFilesList.clear();
transMemories.clear();
projectTMX = null;
// There, that should do it, now inform the user
long memory = Runtime.getRuntime().maxMemory() / 1024 / 1024;
Log.logErrorRB("OUT_OF_MEMORY", memory);
Log.log(oome);
Core.getMainWindow().showErrorDialogRB("TF_ERROR", "OUT_OF_MEMORY", memory);
// Just quit, we can't help it anyway
System.exit(0);
}
Log.logInfoRB("LOG_DATAENGINE_LOAD_END");
}
Aggregations