Exemplo n.º 1
0
 function testRunTestsFromFile()
 {
     $file = file(dirname(__FILE__) . "/../test_data_files/author_comparisons.txt");
     foreach ($file as $line => $test_case) {
         if (!preg_match("/^\\s*#/", $test_case) && preg_match("/^([^\\|]+)\\|([^\\|]+)\\|([^\\|]+)\\|([^\\|]+)\$/", $test_case, $arr)) {
             $name_string1 = trim($arr[1]);
             $name_string2 = trim($arr[2]);
             $test_result = trim($arr[3]);
             $test_score = trim($arr[4]);
             if ($test_result == 'false') {
                 $test_result = false;
             } else {
                 $test_result = true;
             }
             $info_1 = new Splitter(null, $name_string1);
             $info_2 = new Splitter(null, $name_string2);
             $res = AuthorMatch::compare_authorities($info_1->authors_years, $info_2->authors_years, null, false);
             echo $res . ' "' . $name_string1 . '" "' . $name_string2 . '" <br/>';
             $this->assertTrue($test_result == $res, "{$name_string1} `match` {$name_string2} should be {$test_result} on line (" . ($line + 1) . ")");
         }
     }
 }
Exemplo n.º 2
0
 public function match_authors($preparsed_1, $preparsed_2, $boolean = false)
 {
     $authorship1 = array('authors' => $preparsed_1['all_authors'], 'years' => $preparsed_1['all_years']);
     $authorship2 = array('authors' => $preparsed_2['all_authors'], 'years' => $preparsed_2['all_years']);
     return AuthorMatch::compare_authorities($authorship1, $authorship2, 50, $boolean);
 }