https://drive.google.com/file/d/0B7XkCw ... sp=sharing
https://www.h-schmidt.net/FloatConverter/IEEE754.html
embeddings.prg
Code: Select all | Expand
function Main()
local hFile := FOpen( "GoogleNews-vectors-negative300.bin", "r" )
local cBuffer := Chr( 0 ), cWord := "", n := 0
local cEmbeddings := Space( 1200 ), nBytesRead
DbCreate( "embeddings.dbf", { { "WORD", "C", 10, 0 }, { "EMBEDDINGS", "M", 10, 0 } } )
USE embeddings
while cBuffer != Chr( 10 )
FRead( hFile, @cBuffer, 1 )
?? cBuffer
end
APPEND BLANK
while cBuffer != Chr( 32 )
FRead( hFile, @cBuffer, 1 )
?? cBuffer
cWord += cBuffer
end
field->Word := cWord
while .T.
nBytesRead := FRead( hFile, @cEmbeddings, 1200 )
if nBytesRead < 1200
? "End of file"
exit
else
field->embeddings := cEmbeddings
endif
APPEND BLANK
cBuffer = Chr( 0 )
cWord = ""
? ""
while cBuffer != Chr( 32 )
nBytesRead := FRead( hFile, @cBuffer, 1 )
if nBytesRead == 0
? "End of file"
exit
endif
?? cBuffer
cWord += cBuffer
end
field->Word := cWord
end
FClose( hFile )
USE
return nil