After last code challenge on PC and thanks to those kind of people
idling on IRC and maillist, I'v been a little familiar with Apertium
and port it to the android simulator(2.3.3, api level10). Both of the
two challenge codes for PC or apk for Android can be found at
/*https://github.com/echoit/embedlt*/, even though they are very simple.
I have pushed the whole android project to github
<https://github.com/echoit/lttoolbox-android>(1M+). Some hardcode are:
org.apertium.Lttoolbox.MODE = "eo-en"
org.apertium.embed.Apertium.DATA_DIRECTORY = "/sdcard/forapertium/"
and make the dynamic java classes directly integrated into android
project rather than dynamically compile them, because android vm Dalvik
doesnot support this feature currently.
NOTE, this demo only supports "eo-en" mode for now.
What I want to share with GSoCers who want to get quick started to run
Lttoolbox-java in other places are as below:
1. On PC
* You'd better choose *nix OS for the development of apertium, since
it is easier than in Windows and more docs about it. I use Arch
Linux, only very a few OS issues to cope with.
* Choose one language pair(e.g., eo-en) for the simple
implementation. if one pair works, the other will definitely quick
to consider.
* Make origin lttoolbox-java input and output constant at first and
then refactor, e.g., you can hardcode the input stream just use a
constant text File object, in which you can put some words ready
to translate.
2. On Android
* Make your android challenge code based on PC ones, for they are
similiar to each other(same interface, e.g., you can use
StringWriter on Android instead of FileWriter for output stream,
both of them are subclasses of Writer).
* Download and use the most recent Android SDK, for some java-apis
are not implemented in the earlier version. The representitive one
is String.isEmpty() method which you can only find 2.3.3+(api
level 9+) rather below 2.2(api level 8). The reason why I want to
share this with you is that you will find there can be less error
or warning problems to tackle in your IDE.
* Besides,we cannot find any such javax.xml.stream.* apis in android
that it need us to import externally. In my case, I referred to the
method in dalvik
group:http://code.google.com/p/dalvik/wiki/JavaxPackages. Download
the hello_stax demo, extract the jsr*.jar and then import it to
android project.
BTW, It seems very slow in simulator(about 10s to translate "Hello, I am
apertium"). And many "GC_CONCURRENT freed", even "JitTable" resize from
512 to 1024 printed onto the LogCat. As below:
03-27 14:09:02.714: I/ActivityManager(73): Displayed
org.apertium/.Lttoolbox: +1s752ms
03-27 14:09:07.844: D/dalvikvm(317): GC_EXPLICIT freed 7K, 54% free
2544K/5511K, external 1625K/2137K, paused 93ms
03-27 14:09:16.114: D/dalvikvm(388): GC_CONCURRENT freed 159K, 41% free
3972K/6727K, external 1625K/2137K, paused 9ms+13ms
03-27 14:09:17.674: D/dalvikvm(388): GC_CONCURRENT freed 14K, 35% free
5003K/7623K, external 1625K/2137K, paused 10ms+16ms
03-27 14:09:18.816: D/dalvikvm(329): GC_EXPLICIT freed 322K, 54% free
2538K/5511K, external 1625K/2137K, paused 2077ms
03-27 14:09:19.455: D/dalvikvm(388): GC_CONCURRENT freed 7K, 29% free
6419K/9031K, external 1625K/2137K, paused 9ms+23ms
03-27 14:09:21.365: D/dalvikvm(388): GC_CONCURRENT freed 8K, 25% free
8273K/10887K, external 1625K/2137K, paused 9ms+17ms
03-27 14:09:23.565: D/dalvikvm(352): GC_EXPLICIT freed 104K, 51% free
2672K/5447K, external 2508K/2662K, paused 1803ms
03-27 14:09:24.164: D/dalvikvm(388): GC_CONCURRENT freed 6376K, 70% free
3953K/12935K, external 1625K/2137K, paused 8ms+36ms
03-27 14:09:25.184: D/dalvikvm(388): GC_CONCURRENT freed 6K, 62% free
4966K/12935K, external 1625K/2137K, paused 10ms+17ms
03-27 14:09:26.654: D/dalvikvm(388): GC_CONCURRENT freed 8K, 52% free
6315K/12935K, external 1625K/2137K, paused 9ms+18ms
03-27 14:09:28.164: D/dalvikvm(265): GC_EXPLICIT freed 12K, 55% free
2595K/5703K, external 1625K/2137K, paused 1376ms
03-27 14:09:28.405: D/dalvikvm(388): GC_CONCURRENT freed 6K, 38% free
8115K/12935K, external 1625K/2137K, paused 9ms+17ms
03-27 14:09:30.485: D/dalvikvm(388): GC_CONCURRENT freed 8K, 22% free
10155K/12935K, external 1625K/2137K, paused 11ms+18ms
03-27 14:09:32.565: D/dalvikvm(388): GC_CONCURRENT freed 7K, 18% free
12242K/14855K, external 1625K/2137K, paused 11ms+16ms
03-27 14:09:34.954: D/dalvikvm(388): GC_CONCURRENT freed 9K, 16% free
14289K/16903K, external 1625K/2137K, paused 9ms+19ms
03-27 14:09:36.144: I/dalvikvm(388): Jit: resizing JitTable from 512 to 1024
03-27 14:09:37.485: D/dalvikvm(388): GC_CONCURRENT freed 12470K, 80%
free 3875K/18951K, external 1625K/2137K, paused 10ms+19ms
03-27 14:09:38.684: D/dalvikvm(388): GC_CONCURRENT freed 24K, 75% free
4844K/18951K, external 1625K/2137K, paused 9ms+21ms
03-27 14:09:40.064: D/dalvikvm(388): GC_CONCURRENT freed 3K, 68% free
6157K/18951K, external 1625K/2137K, paused 9ms+17ms
03-27 14:09:41.874: D/dalvikvm(388): GC_CONCURRENT freed 1K, 59% free
7910K/18951K, external 1625K/2137K, paused 10ms+18ms
So I thought maybe the pipeline implementation in java is a little heavy
since the big IO objects such as: java.io.Writer and java.io.Reader. I
want to try other method to rewrite this section for embed ones, or
maybe @Jacob have got some ideas.
Thanks a lot.
--
cheers,
echo
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Apertium-stuff mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/apertium-stuff