Exemplo n.º 1
0
 public function testRightUrlForTMS()
 {
     $expected_String = "http://api.mymemory.translated.net/get?q=This+provision+takes+effect+in+2014.&langpair=en-US%7Cit-IT&de=demo%40matecat.com&mt=1&numres=3&conc=true&mtonly=1";
     $config = TMS::getConfigStruct();
     $config['get_mt'] = true;
     $config['mt_only'] = true;
     $config['segment'] = "This provision takes effect in 2014.";
     $config['source_lang'] = "en-US";
     $config['target_lang'] = "it-IT";
     $config['email'] = "*****@*****.**";
     $config['id_user'] = null;
     $config['num_result'] = 3;
     $config['isConcordance'] = true;
     $tms = new MUTE_TMS(1);
     //MyMemory
     $tms->get($config);
     $class = new \ReflectionObject($tms);
     $prop = $class->getProperty('url');
     $prop->setAccessible(true);
     $this->assertEquals($expected_String, $prop->getValue($tms));
 }
Exemplo n.º 2
0
<?php

$test = false;
$skip = true;
include '/var/www/cattool/inc/config.inc.php';
@INIT::obtain();
include_once INIT::$MODEL_ROOT . '/queries.php';
include_once INIT::$UTILS_ROOT . '/Engines/engine.class.php';
include_once INIT::$UTILS_ROOT . '/Engines/tms.class.php';
include_once INIT::$UTILS_ROOT . '/Engines/mt.class.php';
$db = Database::obtain(INIT::$DB_SERVER, INIT::$DB_USER, INIT::$DB_PASS, INIT::$DB_DATABASE);
$db->debug = INIT::$DEBUG;
$db->connect();
$glossaries = array(array('file' => '140905_Copy of 140825_Glossary_Anti-trust-law Chinese Rev1_V01JH_English-Chinese_Trad.csv', 'source' => "en-US", 'target' => "zh-CN"));
foreach ($glossaries as $gloss) {
    $config = TMS::getConfigStruct();
    $config['source_lang'] = $gloss['source'];
    $config['target_lang'] = $gloss['target'];
    $config['email'] = "*****@*****.**";
    $config['get_mt'] = false;
    $config['id_user'] = "******";
    $config['num_result'] = null;
    $config['isGlossary'] = true;
    $fObject = new SplFileObject($gloss['file']);
    $fObject->setFlags(SplFileObject::READ_CSV | SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE);
    $fObject->setCsvControl(",", '"');
    $tms = new TMS(1);
    foreach ($fObject as $k => $row) {
        if ($test || $skip) {
            if (!isset($row[1]) || empty($row[1])) {
                echo "\nFailed at Row: ";