列出所有terms的token

本文介绍了一个使用token_custom插件定义特定token的示例。通过遍历节点的分类信息,将所有分类名称收集到数组中,并用特定格式合并成一个字符串。此方法可用于动态生成基于内容的标记。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

装上token_custom插件



定义一个token为:

// For all taxonmoy terms
$my_value = array();
foreach ($node->taxonomy as $tid => $term) {
$my_value[] = $term->name;
}
$yourtoken = implode(' ', $my_value);
print $yourtoken;
D:\python下载文件夹\Lib\site-packages\sklearn\utils\deprecation.py:87: FutureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated in 1.0 and will be removed in 1.2. Please use get_feature_names_out instead. warnings.warn(msg, category=FutureWarning) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[20], line 2 1 pyLDAvis.enable_notebook() ----> 2 vis = pyLDAvis.sklearn.prepare(lda, X, vectorizer) 3 vis File D:\python下载文件夹\Lib\site-packages\pyLDAvis\sklearn.py:95, in prepare(lda_model, dtm, vectorizer, **kwargs) 63 """Create Prepared Data from sklearn's LatentDirichletAllocation and CountVectorizer. 64 65 Parameters (...) 92 See `pyLDAvis.prepare` for **kwargs. 93 """ 94 opts = fp.merge(_extract_data(lda_model, dtm, vectorizer), kwargs) ---> 95 return pyLDAvis.prepare(**opts) File D:\python下载文件夹\Lib\site-packages\pyLDAvis\_prepare.py:398, in prepare(topic_term_dists, doc_topic_dists, doc_lengths, vocab, term_frequency, R, lambda_step, mds, n_jobs, plot_opts, sort_topics) 392 ## Quick fix for red bar width bug. We calculate the 393 ## term frequencies internally, using the topic term distributions and the 394 ## topic frequencies, rather than using the user-supplied term frequencies. 395 ## For a detailed discussion, see: https://github.com/cpsievert/LDAvis/pull/41 396 term_frequency = np.sum(term_topic_freq, axis=0) --> 398 topic_info = _topic_info(topic_term_dists, topic_proportion, term_frequency, term_topic_freq, vocab, lambda_step, R, n_jobs) 399 token_table = _token_table(topic_info, term_topic_freq, vocab, term_frequency) 400 topic_coordinates = _topic_coordinates(mds, topic_term_dists, topic_proportion) File D:\python下载文件夹\Lib\site-packages\pyLDAvis\_prepare.py:232, in _topic_info(topic_term_dists, topic_proportion, term_frequency, term_topic_freq, vocab, lambda_step, R, n_jobs) 225 saliency = term_proportion * distinctiveness 227 # Order the terms for the "default" view by decreasing saliency: 228 default_term_info = pd.DataFrame({'saliency': saliency, 'Term': vocab, \ 229 'Freq': term_frequency, 'Total': term_frequency, \ 230 'Category': 'Default'}). \ 231 sort_values(by='saliency', ascending=False). \ --> 232 head(R).drop('saliency', 1) 233 # Rounding Freq and Total to integer values to match LDAvis code: 234 default_term_info['Freq'] = np.floor(default_term_info['Freq']) TypeError: DataFrame.drop() takes from 1 to 2 positional arguments but 3 were given
03-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值