Esempio n. 1
0
parser.add_argument('-r', help='Check for pairs reversibly as well',  action='store_true')
parser.add_argument('-s', help='Ignore single words',  action='store_true')
args = parser.parse_args()

#Getting optional command line inputs.
l_dir = args.d
reverse = args.r
single_words_allowed = args.s

#Applying some preprocessing on input data.
pairs = args.P.split('-')
s_sentence = preprocess(args.S)
t_sentence = preprocess(args.T)

#Testing for Apertium system wide installation.
apertium = Apertium(pairs[0], pairs[1])
(lps,err) = apertium.test_apertium()
assertion(err == '', "Apertium can't be found.\nPlease check the installation.")

#Testing Input data
assertion(s_sentence != "", "S should be there.\nSee -h for help")
assertion(t_sentence != "", "T should be there.\nSee -h for help")
assertion(len(pairs) == 2, "P should be of form 'a-b', eg 'en-eo'\nSee -h for help")

#Checking Language pair Installation.
check_installation(apertium, args.P, lps, l_dir)

#Obtain Subsequences.
subseq = get_subseqs(s_sentence, single_words_allowed)

#Conversion and printing
Esempio n. 2
0
parser.add_argument('-s', help='Ignore single words',  action='store_true')
args = parser.parse_args()

#Getting optional command line inputs.
tmx_out	= args.o
single_words_allowed = args.s
reverse = args.r

#Applying some preprocessing on input data.
l_dir = args.d
tmname = args.TM
lp = args.P
pairs = args.P.split('-')

#Testing for Apertium system wide installation.
apertium = Apertium(pairs[0], pairs[1])
(lps,err) = apertium.test_apertium()
assertion(err == '', "Apertium can't be found.\nPlease check the installation.")

#Testing Input data
assertion(os.path.isfile(tmname), "TM couldn't be found.\nSee -h for help")
assertion(len(pairs) == 2, "P should be of form 'a-b', eg 'en-eo'\nSee -h for help")

#Checking Language pair Installation.
check_installation(apertium, lp, lps, l_dir)

#If reverse, test for reverse
if reverse:
	apertium_rev = Apertium(pairs[1], pairs[0])
	lp_rev = '-'.join(lp.split('-'))
	check_installation(apertium_rev, lp_rev, lps, l_dir)