首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >从多个同义词中创建最可能的句子?

从多个同义词中创建最可能的句子?
EN

Stack Overflow用户
提问于 2018-08-22 06:01:45
回答 1查看 0关注 0票数 0

在php中,我想从多个单词块中获得尽可能多的不同句子。 例如我放入PHP代码:

"today" "yesturday" | "is" "is not" | "monday" "tuesday"

It would become:

today is monday
yesturday is monday
today is not tuesday
yesturday is tuesday
etc...

我怎么能在PHP中创建这个?

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2018-08-22 15:45:26

试试这个。

$block1 = array("today", "yesturday" );
$block2 = array("is", "is not");
$block3 = array("monday", "tuesday");

foreach($block1 as $word1) {
    foreach($block2 as $word2) {
        foreach($block3 as $word3) {
            echo $word1.' '.$word2.' '.$word3."\n";
        }
    }
} 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100002353

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档