llm.prg
- Code: Select all Expand view
- static hWords := {=>}
function Main()
AddSentence( hWords, hb_ATokens( "Hello my friend, Hello how are you ? Hello" ) )
? hWords[ "Hello" ][ 2 ][ "how" ]
return nil
function AddSentence( hWords, aWords )
local cWord
for each cWord in aWords
if ! hb_HHasKey( hWords, cWord )
hWords[ cWord ] = { 1, {=>} }
else
hWords[ cWord ][ 1 ]++
endif
AddSentence( hWords[ cWord ][ 2 ], SubArray( aWords, HB_EnumIndex() + 1 ) )
next
return nil
function SubArray( aArray, nStart )
local aSub := {}
for n = nStart to Len( aArray )
AAdd( aSub, aArray[ n ] )
next
return aSub