PersonStringNlm30NameSchemaFilter::setFilterTitle PHP Method

setFilterTitle() public method

Set whether we parse for a title
public setFilterTitle ( $filterTitle )
$filterTitle boolean
    function setFilterTitle($filterTitle)
    {
        $this->_filterTitle = (bool) $filterTitle;
    }

Usage Example

 /**
  * @covers PersonStringNlm30NameSchemaFilter
  * @covers Nlm30PersonStringFilter
  * @depends testExecuteWithSinglePersonString
  */
 public function testExecuteWithMultiplePersonsStrings()
 {
     $personsString = 'MULLER:IFC Peterberg:Peters HC:Yu QK:Hans Peter B. Sperling:et al';
     $expectedResults = array(array(null, null, null, 'Muller'), array(null, array('I', 'F', 'C'), null, 'Peterberg'), array(null, array('H', 'C'), null, 'Peters'), array(null, array('Q', 'K'), null, 'Yu'), array(null, array('Hans', 'Peter', 'B'), null, 'Sperling'));
     $personStringNlm30NameSchemaFilter = new PersonStringNlm30NameSchemaFilter(ASSOC_TYPE_AUTHOR, PERSON_STRING_FILTER_MULTIPLE);
     $personDescriptions =& $personStringNlm30NameSchemaFilter->execute($personsString);
     // The last description should be an 'et-al' string
     self::assertEquals(PERSON_STRING_FILTER_ETAL, array_pop($personDescriptions));
     foreach ($personDescriptions as $testNumber => $personDescription) {
         $this->assertPerson($expectedResults[$testNumber], $personDescription, $testNumber);
     }
     // Test again, this time with title and degrees
     $personsString = 'Dr. MULLER; IFC Peterberg; Prof. Peters HC, MSc.; Yu QK;Hans Peter B. Sperling; etal';
     $expectedResults = array(array('Dr.', null, null, 'Muller'), array(null, array('I', 'F', 'C'), null, 'Peterberg'), array('Prof. - MSc', array('H', 'C'), null, 'Peters'), array(null, array('Q', 'K'), null, 'Yu'), array(null, array('Hans', 'Peter', 'B'), null, 'Sperling'));
     $personStringNlm30NameSchemaFilter->setFilterTitle(true);
     $personStringNlm30NameSchemaFilter->setFilterDegrees(true);
     $personDescriptions =& $personStringNlm30NameSchemaFilter->execute($personsString);
     // The last description should be an 'et-al' string
     self::assertEquals(PERSON_STRING_FILTER_ETAL, array_pop($personDescriptions));
     foreach ($personDescriptions as $testNumber => $personDescription) {
         $this->assertPerson($expectedResults[$testNumber], $personDescription, $testNumber);
     }
     // Test whether Vancouver style comma separation works correctly
     $personsString = 'Peterberg IFC, Peters HC, Sperling HP';
     $expectedResults = array(array(null, array('I', 'F', 'C'), null, 'Peterberg'), array(null, array('H', 'C'), null, 'Peters'), array(null, array('H', 'P'), null, 'Sperling'));
     $personStringNlm30NameSchemaFilter->setFilterTitle(false);
     $personStringNlm30NameSchemaFilter->setFilterDegrees(false);
     $personDescriptions =& $personStringNlm30NameSchemaFilter->execute($personsString);
     foreach ($personDescriptions as $testNumber => $personDescription) {
         $this->assertPerson($expectedResults[$testNumber], $personDescription, $testNumber);
     }
     // Single name strings should not be cut when separated by comma.
     $personsString = 'Willinsky, John';
     $expectedResult = array(null, array('John'), null, 'Willinsky');
     $personDescriptions =& $personStringNlm30NameSchemaFilter->execute($personsString);
     $this->assertEquals(1, count($personDescriptions));
     $this->assertPerson($expectedResult, $personDescriptions[0], $testNumber);
     // Test APA style author tokenization.
     $singleAuthor = array(1 => 'Berndt, T. J.');
     $twoAuthors = array(2 => 'Wegener-Prent, D. T., & Petty, R. E.');
     $threeToSevenAuthors = array(6 => 'Kernis Wettelberger, M. H., Cornell, D. P., Sun, C. R., Berry, A., Harlow, T., & Bach, J. S.');
     $moreThanSevenAuthors = array(7 => 'Miller, F. H., Choi, M.J., Angeli, L. L., Harland, A. A., Stamos, J. A., Thomas, S. T., . . . Rubin, L. H.');
     $singleEditor = array(1 => 'A. Editor');
     $twoEditors = array(2 => 'A. Editor-Double & B. Editor');
     $threeToSevenEditors = array(6 => 'M.H. Kernis Wettelberger, D. P. Cornell, C.R. Sun, A. Berry, T. Harlow & J.S. Bach');
     $moreThanSevenEditors = array(7 => 'F. H. Miller, M. J. Choi, L. L. Angeli, A. A. Harland, J. A. Stamos, S. T. Thomas . . . L. H. Rubin');
     foreach (array($singleAuthor, $twoAuthors, $threeToSevenAuthors, $moreThanSevenAuthors, $singleEditor, $twoEditors, $threeToSevenEditors, $moreThanSevenEditors) as $test) {
         $expectedNumber = key($test);
         $testString = current($test);
         $personDescriptions =& $personStringNlm30NameSchemaFilter->execute($testString);
         $this->assertEquals($expectedNumber, count($personDescriptions), 'Offending string: ' . $testString);
     }
 }