public function getSynsetFromString($line)
    {
        $row = str_getcsv($line," ");  
        $synset = new Synset((int)$row[0], $row[2]);
        $synset->setDefinition(trim(substr($line, strpos($line,"|")+1)));
        
        for($index = 0; $index < (int)$row[3]; $index++)
        {                        
            $synset->addWord($row[4 + $index*2], $row[5 + $index*2]);
        }
        
        $startIdx =  5 + $row[3] * 2;
        $endIdx = ($row[$startIdx-1] * 4) + $startIdx; 
        $embeddedSynsets = array_splice($row, $startIdx, $endIdx);
        for($index = 0; $index < $row[$startIdx-1] * 4; $index+=4)
        {
            $linkedSynset = new Synset($embeddedSynsets[$index+1], $embeddedSynsets[$index+2]);
            $linkedSynset->setPtrSymbols([$embeddedSynsets[$index]]);
            
            // set src and target word indexes
            if((int)$embeddedSynsets[$index+3] === 0) {
                $linkedSynset->setSrcWordIdx(0);
                $linkedSynset->setTargetWordIdx(0);
            } else {
                $linkedSynset->setSrcWordIdx((int)($embeddedSynsets[$index+3]) % 100);
                $linkedSynset->setTargetWordIdx((int) floor($embeddedSynsets[$index+3] / 100));
            }   
            $synset->addLinkedSynset($linkedSynset);
        }              
        return $synset;        
    }
public function getSynsetFromString($line)
    {
        $row = str_getcsv($line," ");  
        $synset = new Synset((int)$row[0], $row[2]);
        $synset->setDefinition(trim(substr($line, strpos($line,"|")+1)));
        
        for($index = 0; $index < (int)$row[3]; $index++)
        {                        
            $synset->addWord($row[4 + $index*2], $row[5 + $index*2]);
        }
        
        $startIdx =  5 + $row[3] * 2;
        $endIdx = ($row[$startIdx-1] * 4) + $startIdx; 
        $embeddedSynsets = array_splice($row, $startIdx, $endIdx);
        for($index = 0; $index < $row[$startIdx-1] * 4; $index+=4)
        {
            $linkedSynset = new Synset($embeddedSynsets[$index+1], $embeddedSynsets[$index+2]);
            $linkedSynset->setPtrSymbols([$embeddedSynsets[$index]]);
            
            // set src and target word indexes
            if((int)$embeddedSynsets[$index+3] === 0) {
                $linkedSynset->setSrcWordIdx(0);
                $linkedSynset->setTargetWordIdx(0);
            } else {
                $linkedSynset->setSrcWordIdx((int)($embeddedSynsets[$index+3]) % 100);
                $linkedSynset->setTargetWordIdx((int) floor($embeddedSynsets[$index+3] / 100));
            }   
            $synset->addLinkedSynset($linkedSynset);
        }              
        return $synset;        
    }
public function getSynsetFromString ( $ line ) { $ row = str_getcsv ( $ line , " " ) ; $ synset = new Synset ( ( int ) $ row [ 0 ] , $ row [ 2 ] ) ; $ synset -> setDefinition ( trim ( substr ( $ line , strpos ( $ line , "|" ) + 1 ) ) ) ; for ( $ index = 0 ; $ index < ( int ) $ row [ 3 ] ; $ index ++ ) { $ synset -> addWord ( $ row [ 4 + $ index * 2 ] , $ row [ 5 + $ index * 2 ] ) ; } $ startIdx = 5 + $ row [ 3 ] * 2 ; $ endIdx = ( $ row [ $ startIdx - 1 ] * 4 ) + $ startIdx ; $ embeddedSynsets = array_splice ( $ row , $ startIdx , $ endIdx ) ; for ( $ index = 0 ; $ index < $ row [ $ startIdx - 1 ] * 4 ; $ index += 4 ) { $ linkedSynset = new Synset ( $ embeddedSynsets [ $ index + 1 ] , $ embeddedSynsets [ $ index + 2 ] ) ; $ linkedSynset -> setPtrSymbols ( [ $ embeddedSynsets [ $ index ] ] ) ; // set src and target word indexes if ( ( int ) $ embeddedSynsets [ $ index + 3 ] === 0 ) { $ linkedSynset -> setSrcWordIdx ( 0 ) ; $ linkedSynset -> setTargetWordIdx ( 0 ) ; } else { $ linkedSynset -> setSrcWordIdx ( ( int ) ( $ embeddedSynsets [ $ index + 3 ] ) % 100 ) ; $ linkedSynset -> setTargetWordIdx ( ( int ) floor ( $ embeddedSynsets [ $ index + 3 ] / 100 ) ) ; } $ synset -> addLinkedSynset ( $ linkedSynset ) ; } return $ synset ; }
Parse the line from the synset file and turn it into a synset object
@param string $line
@return Synset
Parse the line from the synset file and turn it into a synset object