Difference between revisions of "User:Kanmuri/Notes/Java Runtime Port/Interchunk vs Transfer"
m (moved User:Kanmuri/Notes/Java Runtime Port/Interchunk vs Transfer/ to User:Kanmuri/Notes/Java Runtime Port/Interchunk vs Transfer: shouldn't have a slash at the end) |
|||
(8 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
I wouldn't count on them being entirely correct, in fact they may be downright completely wrong in places, but hopefully not. ;) This is mainly just to have a place to organize my thoughts. |
I wouldn't count on them being entirely correct, in fact they may be downright completely wrong in places, but hopefully not. ;) This is mainly just to have a place to organize my thoughts. |
||
==apertium_transfer vs apertium_interchunk== |
==apertium_transfer.cc vs apertium_interchunk.cc== |
||
We are only really concerned with one function in these two files at the moment, <code>main()</code>. |
We are only really concerned with one function in these two files at the moment, <code>main()</code>. |
||
Line 13: | Line 13: | ||
Transfer and interchunk take different parameters for their read functions. Transfer takes a transfer file, a data file, and an fst file. Interchunk takes just a transfer file and a data file. |
Transfer and interchunk take different parameters for their read functions. Transfer takes a transfer file, a data file, and an fst file. Interchunk takes just a transfer file and a data file. |
||
Transfer and |
Transfer and interchunk then call their <code>transfer()</code> and <code>interchunk()</code> functions respectively. |
||
==apertium_transfer.cc vs ApertiumTransfer.java== |
|||
Not a significant difference between these two. The basic premise is the same, parse command-line options and parameters, then call the <code>read()</code> and <code>transfer()</code> functions. |
|||
==transfer.cc vs interchunk.cc== |
|||
===<code>read()</code>=== |
|||
<code>void Transfer::read(string const &transferfile, string const &datafile, string const &fstfile)</code> |
|||
<code>void Interchunk::read(string const &transferfile, string const &datafile)</code> |
|||
The <code>read()</code> functions first call <code>readTransfer()</code> and <code>readInterchunk()</code> respectively. They then both try and open the specified data file. After that, <code>Transfer::read()</code> also calls a function to read the fst file, called <code>readBil()</code>. <code>Interchunk::read()</code> does not have that call, and that function (<code>readBil()</code>) does not exist in interchunk. |
|||
===<code>transfer()</code> vs <code>interchunk()</code>=== |
|||
Checks if null flush is set, then calls a null flush "wrapper" function (<code>*_wrapper_null_flush()</code>). |
|||
Initializes the MorphoStream. Then enters an infinite (<code>while(true)</code>) loop. |
|||
The code is the same up to the <code>if(tmpword.size() != 0)</code> line. |
|||
After that, the interchunk code diverges. It just outputs a '^', the contents of <code>tmpword</code>, and a '$', whereas the transfer code has a whole bunch of stuff it does. |
|||
They meet back up at <code>tmpword.clear()</code>, and continue the same up 'till the <code>tt_eof</code> case in a <code>switch(current.getType())</code> statement. In the else clause of an if-else statement there, interchunk adds a line <code>tmpblank.clear()</code>. |
|||
===<code>transfer_wrapper_null_flush()</code> vs <code>interchunk_wrapper_null_flush()</code>=== |
|||
The only difference between the two of these is that one calls <code>transfer()</code>, and the other one calls <code>interchunk()</code>. |
|||
If flushing on nulls, then what the wrapper does is call the respective function, which returns on a null, re-output the null, flush the output, then call the function again, until end of file. |
|||
One other significant thing is that it unsets the null_flush flag, so that we don't get the transfer/interchunk and the null flush functions infinitely calling each other. Instead it sets the <code>internal_null_flush</code> flag to indicate that null flush is actually enabled, but that we're already inside the wrapper. |
|||
===<code>applyWord()</code>=== |
|||
An extra case in interchunk for skipping over "the unmodifiable part of the chunk" according to the comments. |
|||
===<code>applyRule()</code>=== |
|||
Looks like Transfer has extra code for the bilingual dictionary. Also, Interchunk uses InterchunkWord and Transfer uses TransferWord. |
|||
===<code>readToken()</code>=== |
|||
Interchunk has a bunch of extra if statements that look to be for jumping over chunks, and an "inword" flag. |
Latest revision as of 03:39, 27 July 2010
I created this page to hold my notes as I go along trying to figure this out.
I wouldn't count on them being entirely correct, in fact they may be downright completely wrong in places, but hopefully not. ;) This is mainly just to have a place to organize my thoughts.
Contents
apertium_transfer.cc vs apertium_interchunk.cc[edit]
We are only really concerned with one function in these two files at the moment, main()
.
There's the obvious differences in the option parsing code, as interchunk doesn't have as many options as transfer does.
Transfer calls its read()
function differently depending on the command-line options and parameters.
Interchunk instead just assigns values to variables differently depending on the options and parameters, and then uses those to call its read()
function.
Transfer and interchunk take different parameters for their read functions. Transfer takes a transfer file, a data file, and an fst file. Interchunk takes just a transfer file and a data file.
Transfer and interchunk then call their transfer()
and interchunk()
functions respectively.
apertium_transfer.cc vs ApertiumTransfer.java[edit]
Not a significant difference between these two. The basic premise is the same, parse command-line options and parameters, then call the read()
and transfer()
functions.
transfer.cc vs interchunk.cc[edit]
read()
[edit]
void Transfer::read(string const &transferfile, string const &datafile, string const &fstfile)
void Interchunk::read(string const &transferfile, string const &datafile)
The read()
functions first call readTransfer()
and readInterchunk()
respectively. They then both try and open the specified data file. After that, Transfer::read()
also calls a function to read the fst file, called readBil()
. Interchunk::read()
does not have that call, and that function (readBil()
) does not exist in interchunk.
transfer()
vs interchunk()
[edit]
Checks if null flush is set, then calls a null flush "wrapper" function (*_wrapper_null_flush()
).
Initializes the MorphoStream. Then enters an infinite (while(true)
) loop.
The code is the same up to the if(tmpword.size() != 0)
line.
After that, the interchunk code diverges. It just outputs a '^', the contents of tmpword
, and a '$', whereas the transfer code has a whole bunch of stuff it does.
They meet back up at tmpword.clear()
, and continue the same up 'till the tt_eof
case in a switch(current.getType())
statement. In the else clause of an if-else statement there, interchunk adds a line tmpblank.clear()
.
transfer_wrapper_null_flush()
vs interchunk_wrapper_null_flush()
[edit]
The only difference between the two of these is that one calls transfer()
, and the other one calls interchunk()
.
If flushing on nulls, then what the wrapper does is call the respective function, which returns on a null, re-output the null, flush the output, then call the function again, until end of file.
One other significant thing is that it unsets the null_flush flag, so that we don't get the transfer/interchunk and the null flush functions infinitely calling each other. Instead it sets the internal_null_flush
flag to indicate that null flush is actually enabled, but that we're already inside the wrapper.
applyWord()
[edit]
An extra case in interchunk for skipping over "the unmodifiable part of the chunk" according to the comments.
applyRule()
[edit]
Looks like Transfer has extra code for the bilingual dictionary. Also, Interchunk uses InterchunkWord and Transfer uses TransferWord.
readToken()
[edit]
Interchunk has a bunch of extra if statements that look to be for jumping over chunks, and an "inword" flag.