public function getSynsetByOffsetAndPos($synsetOffset, $pos)
    {
        // check if the synset has already been cached
        if(isset($this->synsets[$pos.$synsetOffset])) {
            return $this->synsets[$pos.$synsetOffset];
        }
        
        $fileName = "data.{$this->posFileMaps[$pos]}";
        if(!in_array($fileName, $this->getDataFileNames())) {
            throw new RuntimeException("That is not a correct wordnet file {$fileName}");            
        } elseif(!file_exists($this->getDir().$fileName)) {
            throw new RuntimeException("Wordnet file missing {$fileName}");                        
        }
        
        
        $fh = fopen($this->getDir().$fileName,'r');        
        if(!$fh) {
            throw new RuntimeException("Could not open wordnet file for reading {$fileName}");                                    
        }        
        if(fseek($fh, $synsetOffset) === -1) {
            throw new RuntimeException("Could not seek to {$synsetOffset} in {$fileName}");
        }
        
        $line = trim(fgets($fh));
        fclose($fh);
        return $this->getSynsetFromString($line);
        
    }
public function getSynsetByOffsetAndPos($synsetOffset, $pos)
    {
        // check if the synset has already been cached
        if(isset($this->synsets[$pos.$synsetOffset])) {
            return $this->synsets[$pos.$synsetOffset];
        }
        
        $fileName = "data.{$this->posFileMaps[$pos]}";
        if(!in_array($fileName, $this->getDataFileNames())) {
            throw new RuntimeException("That is not a correct wordnet file {$fileName}");            
        } elseif(!file_exists($this->getDir().$fileName)) {
            throw new RuntimeException("Wordnet file missing {$fileName}");                        
        }
        
        
        $fh = fopen($this->getDir().$fileName,'r');        
        if(!$fh) {
            throw new RuntimeException("Could not open wordnet file for reading {$fileName}");                                    
        }        
        if(fseek($fh, $synsetOffset) === -1) {
            throw new RuntimeException("Could not seek to {$synsetOffset} in {$fileName}");
        }
        
        $line = trim(fgets($fh));
        fclose($fh);
        return $this->getSynsetFromString($line);
        
    }
public function getSynsetByOffsetAndPos ( $ synsetOffset , $ pos ) { // check if the synset has already been cached if ( isset ( $ this -> synsets [ $ pos . $ synsetOffset ] ) ) { return $ this -> synsets [ $ pos . $ synsetOffset ] ; } $ fileName = "data.{$this->posFileMaps[$pos]}" ; if ( ! in_array ( $ fileName , $ this -> getDataFileNames ( ) ) ) { throw new RuntimeException ( "That is not a correct wordnet file {$fileName}" ) ; } elseif ( ! file_exists ( $ this -> getDir ( ) . $ fileName ) ) { throw new RuntimeException ( "Wordnet file missing {$fileName}" ) ; } $ fh = fopen ( $ this -> getDir ( ) . $ fileName , 'r' ) ; if ( ! $ fh ) { throw new RuntimeException ( "Could not open wordnet file for reading {$fileName}" ) ; } if ( fseek ( $ fh , $ synsetOffset ) === - 1 ) { throw new RuntimeException ( "Could not seek to {$synsetOffset} in {$fileName}" ) ; } $ line = trim ( fgets ( $ fh ) ) ; fclose ( $ fh ) ; return $ this -> getSynsetFromString ( $ line ) ; }
Opens the raw data file and reads the synsets in
@param int $synsetOffset
@param string $pos Part of speech
@return Synset
Opens the raw data file and reads the synsets in