Ejemplo n.º 1
0
 public function testEqualTexts()
 {
     $text1 = file_get_contents(__DIR__ . '/../../../resources/text/file1.txt');
     $text2 = file_get_contents(__DIR__ . '/../../../resources/text/file1.txt');
     $simhash = new SimHash();
     $extractor = new SimpleTextExtractor();
     $comparator = new GaussianComparator();
     $fp1 = $simhash->hash($extractor->extract($text1));
     $fp2 = $simhash->hash($extractor->extract($text2));
     self::assertEquals(1, $comparator->compare($fp1, $fp2));
 }
Ejemplo n.º 2
0
 /**
  * Compute the similarity hash on the given text
  *
  * @param string $text        	
  * @param int $size        	
  * @return Fingerprint
  */
 public function hashText($text, $size = self::SIMHASH_64)
 {
     $extractor = new SimpleTextExtractor();
     return $this->hash($extractor->extract($text), $size);
 }
Ejemplo n.º 3
0
 /**
  * GoCompare!
  * @since Version 3.10.0
  * @return \Railpage\Users\SockpuppetManager
  */
 public function compare()
 {
     /**
      * Load our reference data first
      */
     $ref = array("ips" => json_encode($this->ReferenceUser->getIPs(new DateTime("6 months ago"))));
     /**
      * Start our SimHash stuff
      */
     $SimHash = new SimHash();
     $Extractor = new SimpleTextExtractor();
     $Comparator = new GaussianComparator(3);
     foreach ($ref as $key => $lookup) {
         $this->hashes[$key]['reference'] = $SimHash->hash($Extractor->extract($lookup), SimHash::SIMHASH_64);
     }
     foreach ($this->suspects as $Suspect) {
         $suspectData = array("ips" => json_encode($Suspect->getIPs(new DateTime("6 months ago"))));
         foreach ($suspectData as $key => $lookup) {
             $this->hashes[$key]['suspect'] = $SimHash->hash($Extractor->extract($lookup), SimHash::SIMHASH_64);
         }
         foreach ($this->hashes as $key => $users) {
             $this->results[$Suspect->id][$key] = $Comparator->compare($users['reference'], $users['suspect']);
         }
     }
 }