Difference between revisions of "Apertium-viewer"

From Apertium
Jump to navigation Jump to search
 
(82 intermediate revisions by 12 users not shown)
Line 1: Line 1:
Apertium-viewer is a tool to view and edit the output of the various stages of an apertium translation.
{{TOCD}}
Apertium-viewer is a little program which can be used to view and edit the output of the various stages of an apertium translation.


[[Image:Screenshot-jApertiumView.png‎|thumb|400px|right|A screen shot showing translation from English to Esperanto]]
The various stages update ''while you type'', and a change made in any one pane updates the subsequent stages.


The various stages update ''while you type'', and you can make change in any of the stages and see what then happens in the subsequent stages.
[[Image:Screenshot-jApertiumView.png‎|thumb|400px|right|A screen shot. Some stages are hidden (split panes have been moved togehter)]]
Really invaluable when you want to work with and understand a language pair.


== Installing and running apertium-viewer ==
Such a tool is invaluable when you want to work with a language pair.


You don't need to install Apertium to try it out.
== What you need ==
Only requirement is that you have Java 7 or later installed.


Download apertium-viewer.jar from [https://github.com/apertium/apertium-viewer/releases github] and save it to your hard drive. Double-click on apertium-viewer.jar (or right click on it and open with Java Runtime)
* Java JDK 1.6
* Apertium


Or, from the command line, type:
== Installing and running apertium-viewer ==
<pre>
wget https://github.com/apertium/apertium-viewer/releases/download/2.6.0/apertium-viewer.jar -O apertium-viewer.jar
java -Xmx500m -jar apertium-viewer.jar
</pre>


(the parameter -Xmx500m is only neccesary if you want to edit very large dictionary files)
You don't have to install anything!


== Testing unreleased language pairs from Github ==
Just point your Java-enabled browser to http://javabog.dk:8080/apertium-viewer/launch.jnlp and start working.
At startup Apertium-viewer will scan for languages installed on the system, but you really don't need to install your own language pairs anywhere to use it. Just compile the language pair with 'make' and point to the .mode file generated: Choose File | Load mode and select the mode file from the language pair.
Accept to trust the application (it is using your local installation of Apertium).
[[Image:Screenshot-jApertiumView-OpenMode.png‎|thumb|300px|right|Opening a mode file]]


The [[Language pair packages#List of ready-to-use packages|online language pairs]] are also supported. You can choose any of the 24 online pairs that are available and work with them as if they where installed locally, even if they aren't.
You can also save the link, rename it and put it in your start menu
(nice for off-line use).



If this doesent work for you, try typing from the command line:
==Keyboard shortcuts==
* Alt-U: Set/unset 'mark unknown words'
* Alt-I: Fit text: Automatically resising panes. Stages with unchanged text are automatically collapsed.
* Alt-C: Copy All: Puts text for all stages into clipboard
* Alt-S: Hide/Show commands (for clearer view)
* Ctrl-0/Ctrl-1 brings focus to the first pane (input),
* Ctrl-2 brings focus to the to the second pane (etc).
* Ctrl-9 brings focus to the last pane (output). It autoscrolls to make the panes fully visible.
* Ctrl-Pgup, Ctrl-PgDn: Cycle throgh the text panes
* Ctrl-Z/Ctrl-Y Undo/redo on a per text-pane/stage basis
* Ctrl-T: Make test case: Text can be copied directly into a [[Wiki regression testing]] wiki page (also using Tools | Make Test Case...).
* Ctrl-I: Import Wiki text case

==Features==

* Syntax highlighting. If a surface form has an ambigious analysis it's shown in red. If you click on an alternative it is selected (basically, between / /) and can be removed it pressing Delete key.
[[Image:Screenshot-jApertiumView-3.png|thumb|400px|right|A click on an ambigious analysis selects one possibility (press Del to delete it). Also, the freeze button is shown.]]
* Views can be frozen/paused to not propagate changes
* Zoom button to get a detached window (particularly input and output windows).
[[Image:Screenshot-Apertium-viewer-1.png|thumb|400px|right| When the text is the same as on the former stage it is shown with a yellow background. Commands have been hidden for a clearer view.
Coloring scheme for version 1.4 is shown]]
* Language pairs can be tested directly from the Github source directory, without installing them ('make install'). You can just directly point to a mode file and use it.
* [[Language pair packages#List of ready-to-use packages|Online language pairs]] can be used within the application without the need of having them locally.


'''Version 1.3 (dec 2008)'''
[[Image:Wiki test case paste.png|thumb|400px|right|Apertium-viewer showing a [[Wiki regression testing]] case text ready to be pasted.]]

[[Image:Apertium-Viewer_Wiki_test_case_import.png|thumb|400px|right|Apertium-viewer import of a [[Wiki regression testing]] case.]]

* Up to 10 texts can be stored for later use
* Text field with keyboard focus is highlighted

'''Version 1.4 (apr 2010)'''

* Highlighting: Different colors for ambigious and unrecognized words, and for chunks
* A "Hide intermediate" button hides all but input and output text

'''Version 1.5 (nov 2010)'''

* Option to ignore error messages from commands (stderr) to make it usable for Gramtrans stuff

'''Version 2.0 (aug 2012)'''

* Removed the requirement of a local Apertium installation, and offers a much higher translation speed, based on [[lttoolbox-java]]. External processing can still be enabled in the options.
* Support for the 25 [[Language pair packages#List of ready-to-use packages|online language pairs]]. All these pairs can be used within the application without the need of having them locally.
* Full and meaningful names for the modes (for instance, "Basque → Spanish" instead of "eu-es").

'''Version 2.1 (april 2015)'''
* Automatically store separate input text for each source language

'''Version 2.3 (may 2015)'''

* If you switch to a new language, a bundled example phrase is shown
* It's become a development platform! You can easily view/edit the concerned dictionaries and compile from within the tool!

For developers that installed pairs from SVN source:
* Click on a command to edit the source code.
* The tool validates XML dictionary and transfer files.
* After a change, you can recompile the pair and immediately see the result

'''Version 2.4 (may 2015)'''

* Support for trace of transfer/interchunk - with links to the applied rules - also works for online modes
* Support for editing the .lexc source file from a HFST binary file

'''Version 2.5 (may 2015)'''

* Easy tool to download and compile language pair from SVN (using [https://github.com/unhammer/apertium-get apertium-get])
* "Edit | Search for development language pairs" will find most language pairs on your system so you dont have to load modes
* List of modes can be arbitrarily large and contain commments


'''Version 2.5.2 (august 2015)'''

* Option to edit source code in external editor
* About box: Show Environment variables and other stuff that might help locating problems
* Userfriendly Download menu
* Automatic checks if a new version of Apertium-viewer is available

'''Version 2.5.3 (july 2017)'''

* Fix: Mode lines with quotes and spaces are now handled correctly

'''Version 2.5.4 (july 2018)'''

* Fix online language pairs (path had moved)

=== Version 2.5.5 (oct 2019) ===

* External editor can be specified. Jumping to line numbers works as well.
* Fixed internal editor works with Java JDK 9 to 13
* lttoolbox-java kan read files compiled with lttoolbox version 3.5.0
* '''note''' lttoolbox-java currently lacks support for functionality added the last 5 years - and it doesent work in Java JDK 9+. Use C++ version instead.

== Troubleshooting ==

=== Troubleshooting if it won't start ===

If the wiewer wont start up and you get something like this in the console
<pre>
<pre>
Unregognized parameter: ?
javaws http://javabog.dk:8080/apertium-viewer/launch.jnlp
LTProc3.2j: process a stream with a letter transducer
USAGE: LTProc [-c] [-a|-g|-n|-d|-b|-p|-s|-t] fst_file [input_file [output_file]]
</pre>
</pre>


then it means that you've hit an internal bug that prevents the viewer from starting: The viewer is internally using lttoolbox-java for processing (when the viewer starts, it will try to use lttoolbox-java on the last used language pair, but if that pair is using an option unkown to lttoolbox-java, then the program will EXIT, making you unable to switch to another mode!).
=== Faster startup ===
For faster startup (or if Java webstart doesent work for you), you can download manually to your PC by


The solution
wget --no-host-directories -r http://javabog.dk:8080/apertium-viewer/
A) either is to delete a preferences file that apertium-viewer uses to remember the last used pair.
On Linux the file to delete would be:


rm -f ~/.java/.userPrefs/apertiumview/prefs.xml
now skip the Java webstart step by double-clicking on apertium-viewer.jar or typing


B) remove the problematic .mode. You can do so by uninstalling language pairs.
java -jar apertium-viewer/apertium-viewer.jar


===OSX troubleshooting ===
this gives a loading time on 0.5 seconds (java web start takes 4 seconds) on my PC
Delete the preferences file:

Users/<yourusername>/Library/Preferences/com.apple.java.util.prefs.plist

If this still doesn't work try recompiling the program from source (run, ant run)
--[[User:Jonasfromseier|Jonasfromseier]] 17:09, 6 May 2013 (UTC)


=== Mac users ===
=== Mac users ===
Many modern macs come with an old JDK 1.5. Make sure JDK 1.6 is installed and paste
Many modern macs come with an old JDK 1.6 or earlier. Make sure JDK 8 is installed and paste


/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/javaws http://javabog.dk:8080/apertium-viewer/launch.jnlp
'/Library/Internet Plug-ins/JavaAppletPlugin.plugin/Contents/Home/bin/java' -jar ~/apertium-viewer.jar


into the terminal
into the terminal

<!--

Executable JAR (old): http://javabog.dk/filer/ApertiumView.jar

ZIP file (newer): http://javabog.dk/filer/apertium-viewer.zip

-->



== Getting, compiling and running apertium-viewer from source ==
== Getting, compiling and running apertium-viewer from source ==



Check out the source code (Netbeans project) from the subversion repository ([https://apertium.svn.sourceforge.net/svnroot/apertium/trunk/apertium-viewer <code>apertium-tools/apertium-viewer</code>])
Check out the source code (Netbeans project) from https://github.com/apertium/apertium-viewer.


<pre>
<pre>
svn co https://apertium.svn.sourceforge.net/svnroot/apertium/trunk/apertium-viewer
git clone https://github.com/apertium/apertium-viewer
cd apertium-viewer
cd apertium-viewer
ant
ant run
ant run
</pre>
</pre>


To run it's easiest just to type 'ant run' or use Netbeans to compile.
To run it's easiest just to type 'ant run' or use Netbeans to compile.
You might need to specify where to look for JDK, like:
<pre>
ant -Dplatforms.default_platform.home=/usr run
</pre>


You need a copy of http://wiki.apertium.org/wiki/Lttoolbox-java (put lttooolbox.jar in lib/ or link the projects)
=== Running apertium-viewer ===


== TODO ==
Running the binary: Just double-click on apertium-viewer.jar


It this don't work, type
<pre>
java -jar apertium-viewer.jar
</pre>
from the command line. Remember to use JDK 1.6 (java -version shows the version number)


(but if you really insist on going the longes possible way you can compile from command line with ant and then type <code>java -cp "lib/swing-app-framework/appframework-1.0.3.jar:lib/swing-app-framework/swing-worker-1.1.jar:dist/apertium-viewer.jar" apertiumview.ApertiumViewMain</code>)


See development in https://github.com/apertium/apertium-viewer/commits/master
== Testing unreleased language pairs from subversion ==
At startup Apertium-viewer will scan for languages installed on the system.


==== Feature requests/bugs ====
But you don't need to install your own language pairs anywhere to use it! All what is needed is to compile the language pair with 'make' and point to the .mode file generated.
Just choose File | Load mode and select the mode file from the language pair.
[[Image:Screenshot-jApertiumView-OpenMode.png‎|thumb|300px|right|Opening a mode file]]


* Even if a file is saved, the editor sometimes still warns about unsaved changes
==Features==
* Alt-U: Set/unset 'mark unknown words'
* Alt-I: Fit text: Automatically resizing panes. Stages with unchanged text are automatically collapsed.
* Alt-C: Copy All: Puts text for all stages into clipboard
* Alt-S: Hide/Show commands (for clearer view)
* Ctrl-0/Ctrl-1 brings focus to the first pane (input),
* Ctrl-2 brings focus to the to the second pane (etc).
* Ctrl-9 brings focus to the last pane (output). It autoscrolls to make the panes fully visible.
* Ctrl-Pgup, Ctrl-PgDn: Cycle throgh the text panes
* Ctrl-Z/Ctrl-Y Undo/redo on a per text-pane/stage basis
* Ctrl-T: Make test case: Text can be copied directly into a [[Regression testing]] wiki page (also using Tools | Make Test Case...).
* Ctrl-I: Import Wiki text case
* Views can be frozen/paused to not propagate changes
* Syntax highlighting
* If a surface form has an ambigious analysis its shown in red. If you click on an alternative it is selected (basically, between / /) and can be removed it pressing Delete key.
[[Image:Screenshot-jApertiumView-3.png|thumb|400px|right|A click on an ambigious analysis selects one posibility (press Del to delete it). Also the freeze button is shown.]]
* Removing scrollbars when not wanted.
* Configuration / choosing language pair in the GUI.
* Scroll panes down when they fill with more information.
* Zoom button to get a detached window (particularly input and output windows).
* Remember settings when closed (language pair, input text, size of panes, windows size and position etc).
* It DOESENT use dbus. Rather you can just directly point to a mode file and use it. Therefore language pairs can be tested directly from the SVN source directory, without installing them.


* Create a dedicated lexer (see http://jflex.de/) for our dictionary format
[[Image:Screenshot-jApertiumView2.png‎|thumb|400px|right| When the text is the same as on the former stage it is shown with a yellow background. Commands have been hidden for a clearer view.]]


* Polish the editor, create better autocompletion
[[Image:Wiki test case paste.png|thumb|400px|right|Apertium-viewer showing a Wiki [[Regression testing]] case text ready to be pasted.]]


* Integrate tools from apertium-dixtools
* Run via Java WebStart, so user doesent have to install anything (apart from Java).
* Up to 10 texts can be stored for later use --[[User:Jacob Nordfalk|Jacob Nordfalk]] 06:21, 5 December 2008 (UTC)


* If it can't auto-find the source, maybe it could ask for (and store) the location of the source? (Should probably also be editable for the auto-found sources, in case it finds the wrong file.). Most of the time I find the files, and if not I try some 'desperate searches' using wildcards. I'll do a select list of I get to the 'desperate' step and remember the decision. The problem is, what if the user chooses the wrong file?
[[Image:Apertium-Viewer_Wiki_test_case_import.png|thumb|400px|right|Apertium-viewer import of a Wiki [[Regression testing]] case.]]
I would also need an option to select another file..
* Text field with keyboard focus is highlighted


* If I use Ctrl-F to search a word, and then click in the editor with the mouse, I jump back to where I was before searching


Please report bugs to https://github.com/apertium/apertium-viewer/issues
===Feature requests/bugs===
* Restoring of view sizes after restart is not perfect yet (press Fit to text to fix)
* Shrinking view sizes not perfect yet (press Fit to text a few times to fix)
* Moving chunks as units rather than text.
: foo{ bar } baz { bin } → baz{ bin } foo { bar }


==Related software==
==Related software==


* [[Apertium-view]] is a simpler version of the same program and coded in Python instead of Java and dequires dbus and that you install your language pairs.
* [[Apertium-view]] is a simpler version of the same program and coded in Python instead of Java and requires dbus and that you install your language pairs.
* [[Apertium-view.sh]] is a short shell script that just displays output from all parts of the pipeline, no interactive features
* [[Apertium-tolk]] is similar to, but much simpler than Apertium-viewer. It only has an input window and an output window. Where Apertium-viewer is aimed at developers, Apertium-tolk is intended to be as user friendly as possible.
* [[Apertium-tolk]] is similar to, but much simpler than Apertium-viewer. It only has an input window and an output window. Where Apertium-viewer is aimed at developers, Apertium-tolk is intended to be as user friendly as possible.



Latest revision as of 20:54, 20 February 2022

Apertium-viewer is a tool to view and edit the output of the various stages of an apertium translation.

A screen shot showing translation from English to Esperanto

The various stages update while you type, and you can make change in any of the stages and see what then happens in the subsequent stages. Really invaluable when you want to work with and understand a language pair.

Installing and running apertium-viewer[edit]

You don't need to install Apertium to try it out. Only requirement is that you have Java 7 or later installed.

Download apertium-viewer.jar from github and save it to your hard drive. Double-click on apertium-viewer.jar (or right click on it and open with Java Runtime)

Or, from the command line, type:

wget https://github.com/apertium/apertium-viewer/releases/download/2.6.0/apertium-viewer.jar -O apertium-viewer.jar
java -Xmx500m -jar apertium-viewer.jar 

(the parameter -Xmx500m is only neccesary if you want to edit very large dictionary files)

Testing unreleased language pairs from Github[edit]

At startup Apertium-viewer will scan for languages installed on the system, but you really don't need to install your own language pairs anywhere to use it. Just compile the language pair with 'make' and point to the .mode file generated: Choose File | Load mode and select the mode file from the language pair.

Opening a mode file

The online language pairs are also supported. You can choose any of the 24 online pairs that are available and work with them as if they where installed locally, even if they aren't.


Keyboard shortcuts[edit]

  • Alt-U: Set/unset 'mark unknown words'
  • Alt-I: Fit text: Automatically resising panes. Stages with unchanged text are automatically collapsed.
  • Alt-C: Copy All: Puts text for all stages into clipboard
  • Alt-S: Hide/Show commands (for clearer view)
  • Ctrl-0/Ctrl-1 brings focus to the first pane (input),
  • Ctrl-2 brings focus to the to the second pane (etc).
  • Ctrl-9 brings focus to the last pane (output). It autoscrolls to make the panes fully visible.
  • Ctrl-Pgup, Ctrl-PgDn: Cycle throgh the text panes
  • Ctrl-Z/Ctrl-Y Undo/redo on a per text-pane/stage basis
  • Ctrl-T: Make test case: Text can be copied directly into a Wiki regression testing wiki page (also using Tools | Make Test Case...).
  • Ctrl-I: Import Wiki text case

Features[edit]

  • Syntax highlighting. If a surface form has an ambigious analysis it's shown in red. If you click on an alternative it is selected (basically, between / /) and can be removed it pressing Delete key.
A click on an ambigious analysis selects one possibility (press Del to delete it). Also, the freeze button is shown.
  • Views can be frozen/paused to not propagate changes
  • Zoom button to get a detached window (particularly input and output windows).
When the text is the same as on the former stage it is shown with a yellow background. Commands have been hidden for a clearer view. Coloring scheme for version 1.4 is shown
  • Language pairs can be tested directly from the Github source directory, without installing them ('make install'). You can just directly point to a mode file and use it.
  • Online language pairs can be used within the application without the need of having them locally.


Version 1.3 (dec 2008)

Apertium-viewer showing a Wiki regression testing case text ready to be pasted.
Apertium-viewer import of a Wiki regression testing case.
  • Up to 10 texts can be stored for later use
  • Text field with keyboard focus is highlighted

Version 1.4 (apr 2010)

  • Highlighting: Different colors for ambigious and unrecognized words, and for chunks
  • A "Hide intermediate" button hides all but input and output text

Version 1.5 (nov 2010)

  • Option to ignore error messages from commands (stderr) to make it usable for Gramtrans stuff

Version 2.0 (aug 2012)

  • Removed the requirement of a local Apertium installation, and offers a much higher translation speed, based on lttoolbox-java. External processing can still be enabled in the options.
  • Support for the 25 online language pairs. All these pairs can be used within the application without the need of having them locally.
  • Full and meaningful names for the modes (for instance, "Basque → Spanish" instead of "eu-es").

Version 2.1 (april 2015)

  • Automatically store separate input text for each source language

Version 2.3 (may 2015)

  • If you switch to a new language, a bundled example phrase is shown
  • It's become a development platform! You can easily view/edit the concerned dictionaries and compile from within the tool!

For developers that installed pairs from SVN source:

  • Click on a command to edit the source code.
  • The tool validates XML dictionary and transfer files.
  • After a change, you can recompile the pair and immediately see the result

Version 2.4 (may 2015)

  • Support for trace of transfer/interchunk - with links to the applied rules - also works for online modes
  • Support for editing the .lexc source file from a HFST binary file

Version 2.5 (may 2015)

  • Easy tool to download and compile language pair from SVN (using apertium-get)
  • "Edit | Search for development language pairs" will find most language pairs on your system so you dont have to load modes
  • List of modes can be arbitrarily large and contain commments


Version 2.5.2 (august 2015)

  • Option to edit source code in external editor
  • About box: Show Environment variables and other stuff that might help locating problems
  • Userfriendly Download menu
  • Automatic checks if a new version of Apertium-viewer is available

Version 2.5.3 (july 2017)

  • Fix: Mode lines with quotes and spaces are now handled correctly

Version 2.5.4 (july 2018)

  • Fix online language pairs (path had moved)

Version 2.5.5 (oct 2019)[edit]

  • External editor can be specified. Jumping to line numbers works as well.
  • Fixed internal editor works with Java JDK 9 to 13
  • lttoolbox-java kan read files compiled with lttoolbox version 3.5.0
  • note lttoolbox-java currently lacks support for functionality added the last 5 years - and it doesent work in Java JDK 9+. Use C++ version instead.

Troubleshooting[edit]

Troubleshooting if it won't start[edit]

If the wiewer wont start up and you get something like this in the console

Unregognized parameter: ?
LTProc3.2j: process a stream with a letter transducer
USAGE: LTProc [-c] [-a|-g|-n|-d|-b|-p|-s|-t] fst_file [input_file [output_file]]

then it means that you've hit an internal bug that prevents the viewer from starting: The viewer is internally using lttoolbox-java for processing (when the viewer starts, it will try to use lttoolbox-java on the last used language pair, but if that pair is using an option unkown to lttoolbox-java, then the program will EXIT, making you unable to switch to another mode!).

The solution A) either is to delete a preferences file that apertium-viewer uses to remember the last used pair. On Linux the file to delete would be:

 rm -f ~/.java/.userPrefs/apertiumview/prefs.xml

B) remove the problematic .mode. You can do so by uninstalling language pairs.

OSX troubleshooting[edit]

Delete the preferences file:

Users/<yourusername>/Library/Preferences/com.apple.java.util.prefs.plist

If this still doesn't work try recompiling the program from source (run, ant run) --Jonasfromseier 17:09, 6 May 2013 (UTC)

Mac users[edit]

Many modern macs come with an old JDK 1.6 or earlier. Make sure JDK 8 is installed and paste

'/Library/Internet Plug-ins/JavaAppletPlugin.plugin/Contents/Home/bin/java' -jar ~/apertium-viewer.jar

into the terminal




Getting, compiling and running apertium-viewer from source[edit]

Check out the source code (Netbeans project) from https://github.com/apertium/apertium-viewer.

git clone https://github.com/apertium/apertium-viewer
cd apertium-viewer
ant run

To run it's easiest just to type 'ant run' or use Netbeans to compile. You might need to specify where to look for JDK, like:

ant -Dplatforms.default_platform.home=/usr run

You need a copy of http://wiki.apertium.org/wiki/Lttoolbox-java (put lttooolbox.jar in lib/ or link the projects)

TODO[edit]

See development in https://github.com/apertium/apertium-viewer/commits/master

Feature requests/bugs[edit]

  • Even if a file is saved, the editor sometimes still warns about unsaved changes
  • Polish the editor, create better autocompletion
  • Integrate tools from apertium-dixtools
  • If it can't auto-find the source, maybe it could ask for (and store) the location of the source? (Should probably also be editable for the auto-found sources, in case it finds the wrong file.). Most of the time I find the files, and if not I try some 'desperate searches' using wildcards. I'll do a select list of I get to the 'desperate' step and remember the decision. The problem is, what if the user chooses the wrong file?

I would also need an option to select another file..

  • If I use Ctrl-F to search a word, and then click in the editor with the mouse, I jump back to where I was before searching

Please report bugs to https://github.com/apertium/apertium-viewer/issues

Related software[edit]

  • Apertium-view is a simpler version of the same program and coded in Python instead of Java and requires dbus and that you install your language pairs.
  • Apertium-view.sh is a short shell script that just displays output from all parts of the pipeline, no interactive features
  • Apertium-tolk is similar to, but much simpler than Apertium-viewer. It only has an input window and an output window. Where Apertium-viewer is aimed at developers, Apertium-tolk is intended to be as user friendly as possible.