Re: [Apertium-stuff] Help on GSoC Coding Challenge

2012-04-11 Thread Arink Verma
Thanks Jacob!

I know more refining is needed in rules.jar
The major problem is Type cast can not be done over the dynamically
loaded classes from external dex. We have to use the Standard Data
Structure to invoke rules method. Even though the the Classes are of
same struct and name, we cant cast them.

So I have to include some depended package in rules.jar

Our work will be easier, if there is a way to cast them. Else we have
to use an interference using standard data structure.



-
Arink Verma
Computer Science and Engineering
Indian Institute of Technology

--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
___
Apertium-stuff mailing list
Apertium-stuff@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/apertium-stuff


Re: [Apertium-stuff] Help on GSoC Coding Challenge

2012-04-11 Thread Stephen Tigner
Sorry for the delay in responding. ^^; I tried version 21 on the
Android emulator last night. Still needs a bit of refinement, but it
does work. I'll try and look at version 22 later today or tonight when
I get home from work. Other comments are in-line below.

On Wed, Apr 11, 2012 at 8:53 AM, Arink Verma arinkve...@iitrpr.ac.in wrote:
 Thanks Jacob!

 I know more refining is needed in rules.jar
 The major problem is Type cast can not be done over the dynamically
 loaded classes from external dex. We have to use the Standard Data
 Structure to invoke rules method. Even though the the Classes are of
 same struct and name, we cant cast them.
Question for you. When you say you can't cast them, how were you
trying to do that?
The reason why I ask is I see that generic ?, and was wondering if
you'd tried something like this:

final Classwhatever.class.name.is Eo_En_t1x =
classloader.loadClass(RulePackage+.+classT1x);

(I don't recall what the class name should be off the top of my head,
but that filler name will do for this example.)
I dunno if that'd work, as I haven't tried it myself, but it couldn't
hurt to try. ^_^

 So I have to include some depended package in rules.jar

 Our work will be easier, if there is a way to cast them. Else we have
 to use an interference using standard data structure.



 -
 Arink Verma
 Computer Science and Engineering
 Indian Institute of Technology

 --
 Better than sec? Nothing is better than sec when it comes to
 monitoring Big Data applications. Try Boundary one-second
 resolution app monitoring today. Free.
 http://p.sf.net/sfu/Boundary-dev2dev
 ___
 Apertium-stuff mailing list
 Apertium-stuff@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/apertium-stuff

--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
___
Apertium-stuff mailing list
Apertium-stuff@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/apertium-stuff


Re: [Apertium-stuff] Help on GSoC Coding Challenge

2012-04-11 Thread Arink Verma
Thanks Jacob!
rules.jar has been reduced!

zip on same url has been updated!
http://cloud.github.com/downloads/arinkverma/Apertiurm-Androind-app-devlopment/ApertiumCode22.zip

contains of rules.jar
---
arink@arink-PC:~/Desktop/dex2jar-0.0.9.8$ unzip -l rules_dex2jar.jar
Archive:  rules_dex2jar.jar
  Length  DateTimeName
-  -- -   
  468  2012-04-12 00:51   android/annotation/SuppressLint.class
  395  2012-04-12 00:51   android/annotation/TargetApi.class
  165  2012-04-12 00:51   in/arink/gsoc/pair/BuildConfig.class
  204  2012-04-12 00:51   in/arink/gsoc/pair/R$attr.class
  267  2012-04-12 00:51   in/arink/gsoc/pair/R$drawable.class
  256  2012-04-12 00:51   in/arink/gsoc/pair/R$layout.class
  289  2012-04-12 00:51   in/arink/gsoc/pair/R$string.class
  358  2012-04-12 00:51   in/arink/gsoc/pair/R.class
 2636  2012-04-12 00:51   in/arink/rule/eo_en/eo_en_antaux_t2x.class
43120  2012-04-12 00:51   in/arink/rule/eo_en/eo_en_t1x.class
12991  2012-04-12 00:51   in/arink/rule/eo_en/eo_en_t2x.class
 2556  2012-04-12 00:51   in/arink/rule/eo_en/eo_en_t3x.class
- ---
63705 12 files

-
Arink Verma
Computer Science and Engineering
Indian Institute of Technology

--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
___
Apertium-stuff mailing list
Apertium-stuff@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/apertium-stuff


Re: [Apertium-stuff] Help on GSoC Coding Challenge

2012-04-11 Thread Arink Verma
-- Forwarded message --
From: Arink Verma arinkve...@gmail.com
Date: Thu, Apr 12, 2012 at 1:15 AM
Subject: Re: Help on GSoC Coding Challenge
To: apertium-stuff@lists.sourceforge.net


Thanks Jacob!
rules.jar has been reduced!

zip on same url has been updated!
http://cloud.github.com/downloads/arinkverma/Apertiurm-Androind-app-devlopment/ApertiumCode22.zip

contains of rules.jar
---
arink@arink-PC:~/Desktop/dex2jar-0.0.9.8$ unzip -l rules_dex2jar.jar
Archive:  rules_dex2jar.jar
 Length      Date    Time    Name
-  -- -   
     468  2012-04-12 00:51   android/annotation/SuppressLint.class
     395  2012-04-12 00:51   android/annotation/TargetApi.class
     165  2012-04-12 00:51   in/arink/gsoc/pair/BuildConfig.class
     204  2012-04-12 00:51   in/arink/gsoc/pair/R$attr.class
     267  2012-04-12 00:51   in/arink/gsoc/pair/R$drawable.class
     256  2012-04-12 00:51   in/arink/gsoc/pair/R$layout.class
     289  2012-04-12 00:51   in/arink/gsoc/pair/R$string.class
     358  2012-04-12 00:51   in/arink/gsoc/pair/R.class
    2636  2012-04-12 00:51   in/arink/rule/eo_en/eo_en_antaux_t2x.class
   43120  2012-04-12 00:51   in/arink/rule/eo_en/eo_en_t1x.class
   12991  2012-04-12 00:51   in/arink/rule/eo_en/eo_en_t2x.class
    2556  2012-04-12 00:51   in/arink/rule/eo_en/eo_en_t3x.class
-                     ---
   63705                     12 files

-
Arink Verma
Computer Science and Engineering
Indian Institute of Technology

--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
___
Apertium-stuff mailing list
Apertium-stuff@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/apertium-stuff


Re: [Apertium-stuff] Help on GSoC Coding Challenge

2012-04-11 Thread Jacob Nordfalk
Sendt fra min Android
Den 11/04/2012 18.56 skrev Stephen Tigner stephen.tig...@gmail.com:

 Sorry for the delay in responding. ^^; I tried version 21 on the
 Android emulator last night. Still needs a bit of refinement, but it
 does work. I'll try and look at version 22 later today or tonight when
 I get home from work. Other comments are in-line below.

 On Wed, Apr 11, 2012 at 8:53 AM, Arink Verma arinkve...@iitrpr.ac.in
wrote:
  Thanks Jacob!
 
  I know more refining is needed in rules.jar
  The major problem is Type cast can not be done over the dynamically
  loaded classes from external dex. We have to use the Standard Data
  Structure to invoke rules method. Even though the the Classes are of
  same struct and name, we cant cast them.
 Question for you. When you say you can't cast them, how were you
 trying to do that?

The problem is that the class loaders are different.


 The reason why I ask is I see that generic ?,

This is not related to generics.
--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev___
Apertium-stuff mailing list
Apertium-stuff@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/apertium-stuff


Re: [Apertium-stuff] Help on GSoC Coding Challenge

2012-04-11 Thread Stephen Tigner
(Responses inline)

On Wed, Apr 11, 2012 at 2:53 PM, Jacob Nordfalk
jacob.nordf...@gmail.com wrote:
 Sendt fra min Android
 Den 11/04/2012 18.56 skrev Stephen Tigner stephen.tig...@gmail.com:



 Sorry for the delay in responding. ^^; I tried version 21 on the
 Android emulator last night. Still needs a bit of refinement, but it
 does work. I'll try and look at version 22 later today or tonight when
 I get home from work. Other comments are in-line below.

 On Wed, Apr 11, 2012 at 8:53 AM, Arink Verma arinkve...@iitrpr.ac.in
 wrote:
  Thanks Jacob!
 
  I know more refining is needed in rules.jar
  The major problem is Type cast can not be done over the dynamically
  loaded classes from external dex. We have to use the Standard Data
  Structure to invoke rules method. Even though the the Classes are of
  same struct and name, we cant cast them.
 Question for you. When you say you can't cast them, how were you
 trying to do that?

 The problem is that the class loaders are different.
Ah, okay. n.n


 The reason why I ask is I see that generic ?,

 This is not related to generics.
My bad, then. ^^; Thanks for the clarification.

 --
 Better than sec? Nothing is better than sec when it comes to
 monitoring Big Data applications. Try Boundary one-second
 resolution app monitoring today. Free.
 http://p.sf.net/sfu/Boundary-dev2dev
 ___
 Apertium-stuff mailing list
 Apertium-stuff@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/apertium-stuff


--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
___
Apertium-stuff mailing list
Apertium-stuff@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/apertium-stuff


Re: [Apertium-stuff] Help on GSoC Coding Challenge

2012-04-10 Thread Arink Verma
Stephen, you can find it on http://www.github.com/arinkverma

After converting *.tx1.java to dex the resulting size is around 900kb

Apart from above mention method and coverting JVM Class to DVM dex file.I
think of another concept.
We can have single Main application for managing language pairs and
seperate language pair extention/addon in from of apk application
which
will have only service of communicating with Main application.
The benefit:


   1. LanguagePair.apk can be shipped with keypad of Language pair,
can Transfer Rules
   2. LanguagePair.apk can be install/uninstall/manage
*programmatically* from Main Application (ApertiumAndroid.apk)

See sub-version
LanguagePair , At present has to install manually
https://github.com/downloads/arinkverma/Apertiurm-Androind-app-devlopment/ApertiumPair.apk

ApertiumAndroid , load class from languagePair dynamically
https://github.com/downloads/arinkverma/Apertiurm-Androind-app-devlopment/ApertiumAndroid21.apk

-
Arink Verma
Computer Science and Engineering
Indian Institute of Technology
--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev___
Apertium-stuff mailing list
Apertium-stuff@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/apertium-stuff


Re: [Apertium-stuff] Help on GSoc Coding Challenge

2012-04-09 Thread Arink Verma
Stephen, you can find it on www.github.com/arinkverma

After converting *.tx1.java to dex the resulting size is around 900kb

Apart from above mention method and coverting JVM Class to DVM dex file.I
think of another concept.
We can have single Main application for managing language pairs. And
seperate language pair extention/addon in from of apk application which
will have only service of communicating with Main application.
The benefit is that user can install seprate language pair
(extentsion/addon watever) directly from market.
No need to unpack of language files in sdcard, all the file can be in
assest.


-
Arink Verma
Computer Science and Engineering
Indian Institute of Technology
--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
___
Apertium-stuff mailing list
Apertium-stuff@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/apertium-stuff


Re: [Apertium-stuff] Help on GSoC Coding Challenge

2012-04-08 Thread Arink Verma
I have tried converting java class to dex for DVM Android but the output
file size turnout to be quite large for mobile app.
I have used other approach! i,e bundle the compiled
apertium_eo_en_eo_en_t1x.java together with lttoolbox-java in the same Jar
file. Is there anyother improvement??


-
Arink Verma
Computer Science and Engineering
Indian Institute of Technology
--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
___
Apertium-stuff mailing list
Apertium-stuff@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/apertium-stuff


Re: [Apertium-stuff] Help on GSoC Coding Challenge

2012-04-08 Thread Stephen Tigner
On Sun, Apr 8, 2012 at 6:44 PM, Arink Verma arinkve...@gmail.com wrote:
 I have tried converting java class to dex for DVM Android but the output
 file size turnout to be quite large for mobile app.
How large, exactly? I know that many mobile apps have add-on content
they download from a server from inside the app itself, to help reduce
the download size of the original file. And how did you try to convert
the Java class? Using the DX tool?

 I have used other approach! i,e bundle the compiled
 apertium_eo_en_eo_en_t1x.java together with lttoolbox-java in the same Jar
 file. Is there anyother improvement??
Have you uploaded this updated jar anywhere?

 -
 Arink Verma
 Computer Science and Engineering
 Indian Institute of Technology

 --
 For Developers, A Lot Can Happen In A Second.
 Boundary is the first to Know...and Tell You.
 Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
 http://p.sf.net/sfu/Boundary-d2dvs2

 ___
 Apertium-stuff mailing list
 Apertium-stuff@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/apertium-stuff


--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
___
Apertium-stuff mailing list
Apertium-stuff@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/apertium-stuff


Re: [Apertium-stuff] Help on GSoC Coding Challenge

2012-03-27 Thread Stephen Tigner
On Mon, Mar 26, 2012 at 5:01 PM, Stephen Tigner
stephen.tig...@gmail.com wrote:
[snip]
 Hmm... perhaps when run as a standalone, the transfer compile could
 have an option for invoking the ADK to compile to Dalvik classes?
 I'll need to look and see how/if it's possible to programatically
 invoke the ADK compiler, as well as how to tell if the ADK is present.

After some research
(http://www.betaversion.org/~stefano/linotype/news/110/  [see the
first point under update and errata], and
http://mylifewithandroid.blogspot.com/2008/12/dalvik-opcodes.html), it
seems that Dalvik classes are actually Java classes that have been
transformed by the dx tool *after* compilation (the dx tool is found
in android-sdk/platform-tools). Further research and tinkering is
required, but at this point it looks fairly trivial to just call the
dx tool to convert the pre-compiled transfer class files to dex files,
and then there will need to be a bit of code added to the class loader
to look for the dex file instead of the class file if running under
android.

-- Stephen

--
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
Apertium-stuff@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/apertium-stuff


Re: [Apertium-stuff] Help on GSoC Coding Challenge

2012-03-26 Thread Jacob Nordfalk
Hi,
All interested in
http://wiki.apertium.org/wiki/Ideas_for_Google_Summer_of_Code/Make_lttoolbox-java_embeddable
 or
http://wiki.apertium.org/wiki/Ideas_for_Google_Summer_of_Code/Apertium_on_your_mobile
please
read below.


2012/3/26 Chinmay Dabral chinmay@gmail.com

 Hi,

 Investigating further, I looked at
 org/apertium/transfer/compile/ApertiumTransferCompile.java and it looks
 like it's trying to put the class files in the language directory, but it
 can't so it puts them in /tmp.
 I moved the files from /tmp to the language directory and it worked fine
 on the desktop, but on the phone it says can't load this type of class
 file.



Yes, that is correct: Android can't run java .class files directly.
They'd need to be converted to Dalwik bytecode format first.

I didn't think of that complication.

Chinmay, congratulations, you have done a very important step in the
investigation of lttoolbox-java's embedability.





 On Mon, Mar 26, 2012 at 4:24 AM, Chinmay Dabral chinmay@gmail.comwrote:

 Hi,

 I created an Android project and also modified the class I created to
 output to a string. But when I run the project on the phone, it throws a
 FileNotFoundException: /sdcard/apertium_eo_en_eo_en_t1x.java.

 I noticed that when you run a language pair first time on the desktop, it
 says:

 Compiling: javac -cp /usr/local/share/apertium/lttoolbox.jar
 /tmp/apertium_en_es_en_es_t3x.java

 and similar for a few other files. It doesn't say that the next time on.
 There are class files corresponding to that in the /tmp folder after that.
 If I delete those files it again compiles. Is it trying to do the same
 thing on the phone? If so, is there a way to store those compiled files
 somewhere it can find them (after first compiling on the desktop).


Good work.

Yes, transfer code is actually compiled to Java bytecode and loaded runtime.
If you look at this Java files you will see that it
represent apertium_eo-en_eo-en.t1x


The easiest way to get it to run on Android would be to bundle the
compiled apertium_eo_en_eo_en_t1x.java together with lttoolbox-java in the
same Jar file.
I.e., to add it to the source code and load the class from classpath
instead of loading it from an external file.
That might also be the best long-term solution, but it is also 'ugly'.

Another solution would be to look into how to convert a java JVM .class
file  into a Dalwik class file (can they exist outside .dex files?). Also
not that pretty.

A third solution would be to change transfer. Instead of making Java source
code which is compiled (requiring the Java compiler and thus that JDK is
installed on the user's machine) perhaps bytecode could be generated
directly and saved for subsequent use.
This would require use of a bytecode generator (there's a lot of them out
there, but I havent looked into this area).

The bytecode that needs to be generated is not that complicated, as can be
seen from the generated apertium_eo_en_eo_en_t1x.java. It consists of some
variables, some methods (the macros), some if-statements and method
invocations.
Please also see http://wiki.apertium.org/wiki/Bytecode_for_transfer


Jacob


-- 
Jacob Nordfalk https://plus.google.com/114820443085046080944
http://javabog.dk
Android-udvikler og underviser på
IHKhttp://cv.ihk.dk/diplomuddannelser/itd/vf/MAUog
LundBendsen https://www.lundogbendsen.dk/undervisning/beskrivelse/LB1809/
--
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
Apertium-stuff@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/apertium-stuff


Re: [Apertium-stuff] Help on GSoC Coding Challenge

2012-03-26 Thread echo
On 03/26/2012 05:01 PM, Jacob Nordfalk wrote:
 The easiest way to get it to run on Android would be to bundle the 
 compiled apertium_eo_en_eo_en_t1x.java together with lttoolbox-java in 
 the same Jar file.
 I.e., to add it to the source code and load the class from classpath 
 instead of loading it from an external file.
 That might also be the best long-term solution, but it is also 'ugly'.

 Another solution would be to look into how to convert a java JVM 
 .class file  into a Dalwik class file (can they exist outside .dex 
 files?). Also not that pretty.

 A third solution would be to change transfer. Instead of making Java 
 source code which is compiled (requiring the Java compiler and thus 
 that JDK is installed on the user's machine) perhaps bytecode could be 
 generated directly and saved for subsequent use.
 This would require use of a bytecode generator (there's a lot of them 
 out there, but I havent looked into this area).

 The bytecode that needs to be generated is not that complicated, as 
 can be seen from the generated apertium_eo_en_eo_en_t1x.java. It 
 consists of some variables, some methods (the macros), some 
 if-statements and method invocations.
 Please also see http://wiki.apertium.org/wiki/Bytecode_for_transfer

Yes, the easiest way has been working for me, but ugly as Jacob said, I 
will commit my source code after make it a little more beautiful.

And it do need more efforts to figure the other two methods, especially 
the third one - almost totally deprecated origin codes.


-- 
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
Apertium-stuff@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/apertium-stuff


Re: [Apertium-stuff] Help on GSoC Coding Challenge

2012-03-26 Thread Chinmay Dabral
Hi echo,

Congratulations on getting it working on Android. :)

I was hoping to get it working without touching anything inside
lttoolbox.jar, but I think that's not possible. I think it would be better
to keep all the language-dependent stuff on the sdcard so that the user can
download languages independent of the application itself.

And thanks for the suggestions, Jacob. :)

On Mon, Mar 26, 2012 at 8:08 PM, echo echo...@gmail.com wrote:

 On 03/26/2012 05:01 PM, Jacob Nordfalk wrote:
  The easiest way to get it to run on Android would be to bundle the
  compiled apertium_eo_en_eo_en_t1x.java together with lttoolbox-java in
  the same Jar file.
  I.e., to add it to the source code and load the class from classpath
  instead of loading it from an external file.
  That might also be the best long-term solution, but it is also 'ugly'.
 
  Another solution would be to look into how to convert a java JVM
  .class file  into a Dalwik class file (can they exist outside .dex
  files?). Also not that pretty.
 
  A third solution would be to change transfer. Instead of making Java
  source code which is compiled (requiring the Java compiler and thus
  that JDK is installed on the user's machine) perhaps bytecode could be
  generated directly and saved for subsequent use.
  This would require use of a bytecode generator (there's a lot of them
  out there, but I havent looked into this area).
 
  The bytecode that needs to be generated is not that complicated, as
  can be seen from the generated apertium_eo_en_eo_en_t1x.java. It
  consists of some variables, some methods (the macros), some
  if-statements and method invocations.
  Please also see http://wiki.apertium.org/wiki/Bytecode_for_transfer

 Yes, the easiest way has been working for me, but ugly as Jacob said, I
 will commit my source code after make it a little more beautiful.

 And it do need more efforts to figure the other two methods, especially
 the third one - almost totally deprecated origin codes.


 --
 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
 Apertium-stuff@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/apertium-stuff

--
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
Apertium-stuff@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/apertium-stuff


Re: [Apertium-stuff] Help on GSoC Coding Challenge

2012-03-26 Thread Stephen Tigner
On Mon, Mar 26, 2012 at 3:01 AM, Jacob Nordfalk
jacob.nordf...@gmail.com wrote:
 Hi,
 All interested
 in http://wiki.apertium.org/wiki/Ideas_for_Google_Summer_of_Code/Make_lttoolbox-java_embeddable or http://wiki.apertium.org/wiki/Ideas_for_Google_Summer_of_Code/Apertium_on_your_mobile please
 read below.


 2012/3/26 Chinmay Dabral chinmay@gmail.com

 Hi,

 Investigating further, I looked at
 org/apertium/transfer/compile/ApertiumTransferCompile.java and it looks like
 it's trying to put the class files in the language directory, but it can't
 so it puts them in /tmp.
 I moved the files from /tmp to the language directory and it worked fine
 on the desktop, but on the phone it says can't load this type of class
 file.
Yes, by default it tries to put the compiled class files in the
language pair directory, but if that fails, then it falls back to the
system temp directory.

 Yes, that is correct: Android can't run java .class files directly.
 They'd need to be converted to Dalwik bytecode format first.

 I didn't think of that complication.

 Chinmay, congratulations, you have done a very important step in the
 investigation of lttoolbox-java's embedability.

Yeah, I hadn't thought of that either until it was mentioned on IRC. ^^;

 On Mon, Mar 26, 2012 at 4:24 AM, Chinmay Dabral chinmay@gmail.com
 wrote:

 Hi,

 I created an Android project and also modified the class I created to
 output to a string. But when I run the project on the phone, it throws a
 FileNotFoundException: /sdcard/apertium_eo_en_eo_en_t1x.java.

 I noticed that when you run a language pair first time on the desktop, it
 says:

 Compiling: javac -cp /usr/local/share/apertium/lttoolbox.jar
 /tmp/apertium_en_es_en_es_t3x.java

 and similar for a few other files. It doesn't say that the next time on.
 There are class files corresponding to that in the /tmp folder after that.
 If I delete those files it again compiles. Is it trying to do the same thing
 on the phone? If so, is there a way to store those compiled files somewhere
 it can find them (after first compiling on the desktop).


 Good work.

 Yes, transfer code is actually compiled to Java bytecode and loaded runtime.
 If you look at this Java files you will see that it
 represent apertium_eo-en_eo-en.t1x

Yeah, the reason why you only see those messages the first time is
that for efficiency and compatibility, it looks in the language pair
directory and the system temp directory for the compiled class files,
before trying to re-compile them. This is to eliminate the delay
caused by the compilation step after the first invocation, and also to
allow the compiled class files to be distributed with the language
pair files for systems where a JDK isn't available.

 The easiest way to get it to run on Android would be to bundle the
 compiled apertium_eo_en_eo_en_t1x.java together with lttoolbox-java in the
 same Jar file.
 I.e., to add it to the source code and load the class from classpath instead
 of loading it from an external file.
 That might also be the best long-term solution, but it is also 'ugly'.
So, when you compile the runtime for Android, those class files get
generated automatically? Hmm... yeah, not the most elegant of
solutions.

 Another solution would be to look into how to convert a java JVM .class file
  into a Dalwik class file (can they exist outside .dex files?). Also not
 that pretty.
Hmm... perhaps when run as a standalone, the transfer compile could
have an option for invoking the ADK to compile to Dalvik classes?
I'll need to look and see how/if it's possible to programatically
invoke the ADK compiler, as well as how to tell if the ADK is present.

 A third solution would be to change transfer. Instead of making Java source
 code which is compiled (requiring the Java compiler and thus that JDK is
 installed on the user's machine) perhaps bytecode could be generated
 directly and saved for subsequent use.
 This would require use of a bytecode generator (there's a lot of them out
 there, but I havent looked into this area).

 The bytecode that needs to be generated is not that complicated, as can be
 seen from the generated apertium_eo_en_eo_en_t1x.java. It consists of some
 variables, some methods (the macros), some if-statements and method
 invocations.
 Please also see http://wiki.apertium.org/wiki/Bytecode_for_transfer
Yeah, this solution would be re-inventing the wheel somewhat, IMO, as
(AFAIK) the language pairs still have to be built from source (using
make) before being packaged up for mobile, and if the ADK can be
invoked to compile them for mobile, that can be done during that
building for packaging process.

-- Stephen

--
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
Apertium-stuff@lists.sourceforge.net