run.php in Bibliography Module 7.2
File
lib/msrc-authortool/functest/run.php
View source
<?php
use Analyzer\ContributorNames;
require_once __DIR__ . '/../autoload.php';
spl_autoload_register('adAutoload', true, true);
$authorList = file('authors.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$orgWords = file('orgwords.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$analyzer = new ContributorNames();
$analyzer
->setOrgWords($orgWords);
usort($authorList, function ($a, $b) {
if (strlen($a) == strlen($b)) {
$testArr = array(
$a,
$b,
);
$test2Arr = $testArr;
sort($test2Arr);
return $test2Arr == $testArr ? 1 : -1;
}
else {
return strlen($a) > strlen($b) ? -1 : 1;
}
});
file_put_contents('output/found.txt', '');
file_put_contents('output/skipped.txt', '');
$numFound = 0;
$numSkipped = 0;
foreach ($authorList as $author) {
$result = $analyzer
->analyze($author);
if ($result instanceof \Analyzer\ContributorObject) {
file_put_contents('output/found.txt', (string) $result . "\n", FILE_APPEND);
$numFound++;
}
else {
file_put_contents('output/skipped.txt', $author . "\n", FILE_APPEND);
$numSkipped++;
}
}
printf("\n\nDone.\n%d | Num Found: %s | Num Skipped: %s\n\n", time(), number_format($numFound, 0), number_format($numSkipped, 0));