我正在寻找从PHP代码到Delphi的转换。目前,我在使用PHP代码中的Isset()函数处理时遇到困难。有什么办法可以将下面的代码转换成Delphi吗?如何在delphi中使用isset()
$collection = array(
'doc1' =>'php powerbuilder',
'doc2' =>'php visual');
$dictionary = array();
$docCount = array();
foreach ($collection as $docID => $doc) {
$doc = strtolower($doc);
$terms = explode(' ', $doc);
$docCount[$docID] = count($terms);
foreach ($terms as $term) {
if (!isset($dictionary[$term])) {
$dictionary[$term] = array('df' => 0, 'postings' => array());
}
if (!isset($dictionary[$term]['postings'][$docID])) {
$dictionary[$term]['df']++;
$dictionary[$term]['postings'][$docID] = array('tf' => 0);
}
$dictionary[$term]['postings'][$docID]['tf']++;
}
}
我是否需要组合记录数组来实现它? – akunyer 2012-03-08 08:23:59
看起来你需要使用字典 – 2012-03-08 08:30:15
请发布你使用的Delphi版本,所以我们知道你是否有泛型。也许有人会找时间写一些代码,但我怀疑任何人都会冒风险,不知道泛型是否可用。 – 2012-03-08 08:41:04