For a given Sentence-Aligned Parallel Corpus, it prepars sentence pairs as an input for align.ibm1
and evaluation
functions in this package.
prepare.data(file.sorc, file.trgt, n = -1L,
encode.sorc = 'unknown' , encode.trgt = 'unknown',
min.len = 5, max.len = 40, remove.pt = TRUE, word.align = TRUE)
the name of source language file.
the name of target language file.
the number of sentences to be read.If -1, it considers all sentences.
encoding to be assumed for the source language. If the value is "latin1" or "UTF-8" it is used to mark character strings as known to be in Latin-1 or UTF-8. For more details please see scan
function.
encoding to be assumed for the target language. If the value is "latin1" or "UTF-8" it is used to mark character strings as known to be in Latin-1 or UTF-8. For more details please see scan
function.
a minimum length of sentences.
a maximum length of sentences.
logical. If TRUE, it removes all punctuation marks.
logical. If FALSE, it divides each sentence into its words. Results can be used in align.symmet
, cross.table
, align.test
and evaluation
functions.
A list.
if word_align = TRUE
An integer.
A matrix (n*2), where n is the number of remained sentence pairs after preprocessing.
An integer.
An integer.
A list of words for each the source sentence.
A list of words for each the target sentence.
It balances between source and target language as much as possible. For example, it removes extra blank sentences and equalization sentence pairs. Also, using nfirst2lower
function, it converts the first letter of each sentence into lowercase. Moreover, it removes short and long sentences.
Koehn P. (2010), "Statistical Machine Translation.", Cambridge University, New York.
# NOT RUN {
# Since the extraction of bg-en.tgz in Europarl corpus is time consuming,
# so the aforementioned unzip files have been temporarily exported to
# http://www.um.ac.ir/~sarmad/... .
# }
# NOT RUN {
aa1 = prepare.data ('http://www.um.ac.ir/~sarmad/word.a/euro.bg',
'http://www.um.ac.ir/~sarmad/word.a/euro.en',
n = 20, encode.sorc = 'UTF-8')
aa2 = prepare.data ('http://www.um.ac.ir/~sarmad/word.a/euro.bg',
'http://www.um.ac.ir/~sarmad/word.a/euro.en',
n = 20, encode.sorc = 'UTF-8', word.align = FALSE)
aa3 = prepare.data ('http://www.um.ac.ir/~sarmad/word.a/euro.bg',
'http://www.um.ac.ir/~sarmad/word.a/euro.en',
n = 20, encode.sorc = 'UTF-8', remove.pt = FALSE)
# }
Run the code above in your browser using DataLab