PHP erstellen Wortpaare aus dem Satz
/*this will get all word pairs next to eachother */
$sentence = "the cat sat down outside";
$sentenceArr = explode(" ",$sentence);
$wordPairs = array();
for($i=0;$i<count($sentenceArr)-1;$i++) {
$wordPairs[] = $sentenceArr[$i].'_'.$sentenceArr[$i+1];
}
/*This will get all pairs (ie: all culmintions of two words)*/
$sentence = "the cat sat down outside";
$sentenceArr = explode(" ",$sentence);
$wordPairs = array();
foreach($sentenceArr as $kw1=>$word1){
for($j=($kw1+1);$j<count($sentenceArr);$j++) {
$wordPairs[]=$word1."_".$sentenceArr[$j];
}
}
Friendly Hawk