original_string: public function recognize($filename, array $languages = null, $pageSegMode = self::PAGE_SEG_MODE_AUTOMATIC_OCR)
      {
          if ($pageSegMode < 0 || $pageSegMode > 10) {
              throw new \InvalidArgumentException(
                  'Page seg mode must be between 0 and 10'
              );
          }
          
          $tempFile = tempnam(sys_get_temp_dir(), 'tesseract');
          
          $arguments = array(
              $filename,
              $tempFile,
              '-psm',
              $pageSegMode
          );
          
          if (null !== $languages) {
              $arguments[] = '-l';
              $arguments[] = implode('+', $languages);
          }
          
          $this->execute($arguments);
  
          $recognizedText = trim(\file_get_contents($tempFile . '.txt'));
  
          if (file_exists($tempFile)) {
              unlink($tempFile);
          }
  
          if (file_exists($tempFile . '.txt')) {
              unlink($tempFile . '.txt');
          }
  
          return $recognizedText;
      }
code: public function recognize($filename, array $languages = null, $pageSegMode = self::PAGE_SEG_MODE_AUTOMATIC_OCR)
      {
          if ($pageSegMode < 0 || $pageSegMode > 10) {
              throw new \InvalidArgumentException(
                  'Page seg mode must be between 0 and 10'
              );
          }
          
          $tempFile = tempnam(sys_get_temp_dir(), 'tesseract');
          
          $arguments = array(
              $filename,
              $tempFile,
              '-psm',
              $pageSegMode
          );
          
          if (null !== $languages) {
              $arguments[] = '-l';
              $arguments[] = implode('+', $languages);
          }
          
          $this->execute($arguments);
  
          $recognizedText = trim(\file_get_contents($tempFile . '.txt'));
  
          if (file_exists($tempFile)) {
              unlink($tempFile);
          }
  
          if (file_exists($tempFile . '.txt')) {
              unlink($tempFile . '.txt');
          }
  
          return $recognizedText;
      }
code_tokens: public function recognize ( $ filename , array $ languages = null , $ pageSegMode = self :: PAGE_SEG_MODE_AUTOMATIC_OCR ) { if ( $ pageSegMode < 0 || $ pageSegMode > 10 ) { throw new \ InvalidArgumentException ( 'Page seg mode must be between 0 and 10' ) ; } $ tempFile = tempnam ( sys_get_temp_dir ( ) , 'tesseract' ) ; $ arguments = array ( $ filename , $ tempFile , '-psm' , $ pageSegMode ) ; if ( null !== $ languages ) { $ arguments [ ] = '-l' ; $ arguments [ ] = implode ( '+' , $ languages ) ; } $ this -> execute ( $ arguments ) ; $ recognizedText = trim ( \ file_get_contents ( $ tempFile . '.txt' ) ) ; if ( file_exists ( $ tempFile ) ) { unlink ( $ tempFile ) ; } if ( file_exists ( $ tempFile . '.txt' ) ) { unlink ( $ tempFile . '.txt' ) ; } return $ recognizedText ; }
docstring: Perform OCR on an image file
  
  @param string $filename
  @param array  $languages   An array of language codes
  @param int    $pageSegMode Page segmentation mode
  
  @return string Text recognized from the image
docstring_tokens: Perform OCR on an image file