【作业】chatGPT帮助写代码

2023年7月14日 xwj | 字体大小 | |繁體|

点击其它区域隐藏菜单

```html
 

	菜单隐藏



菜单 



```
/* 

,剔除英文文章中全部低权重单词

在代码中,我们首先通过`toggleMenu`函数切换菜单的显示与隐藏。当菜单显示时,我们通过`document.addEventListener`监听整个文档的点击事件,一旦点击除菜单以外的区域或菜单自己的链接时,调用`hideOnClickOutside`函数隐藏菜单。`hideOnClickOutside`函数会检查点击事件的目标元素,如果目标元素既不属于菜单也不是菜单的链接,则隐藏菜单。同时,在菜单隐藏时,我们通过`document.removeEventListener`移除点击事件的监听。*/

 function removeStopwords($article, $stopwords) {
    $pattern = '/\b(' . implode('|', $stopwords) . ')\b/i';
    $article = preg_replace($pattern, '', $article);
    return $article;
}

// 示例用法
$stopwords = array("is", "and", "the", "that");
$article = "This is a sample article and it contains some stop words like is and the.";
$article = removeStopwords($article, $stopwords);
echo $article;

$stopwords = array(
    'a', 'about', 'above', 'after', 'again', 'against', 'ain', 'all', 'am', 'an', 'and', 'any', 'are', 'aren', 'as', 'at', 'be', 'because', 'been', 'before', 'being', 'below', 'between', 'both', 'but', 'by', 'can', 'couldn', 'd', 'did', 'didn', 'do', 'does', 'doesn', 'doing', 'don', 'down', 'during', 'each', 'few', 'for', 'from', 'further', 'had', 'hadn', 'has', 'hasn', 'have', 'haven', 'having', 'he', 'her', 'here', 'hers', 'herself', 'him', 'himself', 'his', 'how', 'i', 'if', 'in', 'into', 'is', 'isn', 'it', 'itself', 'just', 'll', 'm', 'ma', 'me', 'mightn', 'more', 'most', 'mustn', 'my', 'myself', 'needn', 'no', 'nor', 'not', 'now', 'o', 'of', 'off', 'on', 'once', 'only', 'or', 'other', 'our', 'ours', 'ourselves', 'out', 'over', 'own', 're', 's', 'same', 'shan', 'she', 'should', 'shouldn', 'so', 'some', 'such', 't', 'than', 'that', 'the', 'their', 'theirs', 'them', 'themselves', 'then', 'there', 'these', 'they', 'this', 'those', 'through', 'to', 'too', 'under', 'until', 'up', 've', 'very', 'was', 'wasn', 'we', 'were', 'weren', 'what', 'when', 'where', 'which', 'while', 'who', 'whom', 'why', 'will', 'with', 'won', 'wouldn', 'y', 'you', 'your', 'yours', 'yourself', 'yourselves' );//chatGPT
//下面是我汇总的stopwords,人机结合效率就是高!!
$str1="a,about,above,after,again,against,all,am,an,and,any,are,aren't,as,at,be,because,been,before,being,below,between,both,but,by,can't,cannot,could,couldn't,did,didn't,do,does,doesn't,doing,don't,down,during,each,few,for,from,further,had,hadn't,has,hasn't,have,haven't,having,he,he'd,he'll,he's,her,here,here's,hers,herself,him,himself,his,how,how's,i,i'd,i'll,i'm,i've,if,in,into,is,isn't,it,it's,its,itself,let's,me,more,most,mustn't,my,myself,no,nor,not,of,off,on,once,only,or,other,ought,our,ours,ourselves,out,over,own,same,shan't,she,she'd,she'll,she's,should,shouldn't,so,some,such,than,that,that's,the,their,theirs,them,themselves,then,there,there's,these,they,they'd,they'll,they're,they've,this,those,through,to,too,under,until,up,very,was,wasn't,we,we'd,we'll,we're,we've,were,weren't,what,what's,when,when's,where,where's,which,while,who,who's,whom,why,why's,with,won't,would,wouldn't,you,you'd,you'll,you're,you've,your,yours,yourself,yourselves";
$str2="the,be,of,and,to,in,he,have,had,it,that,for,they,with,as,not,on,she,at,by,this,we,you,your,do,but,from,or,which,one,would,all,will,there,say,who,make,when,can,more,if,no,yes,man,out,other,so,what,up,go,about,than,into,could,only,new,some,come,these,see,use,get,like,then,any,now,may,such,over,most,find,also,after,way,many,must,before,back,through,where,much,should,well,down,own,just,because,good,ok,each,those,feel,seem,how,too,very,become,here,both,need,under,last,never,same,another,begin,while,might,want,form,off,end,my,me,they,his,her,her,she,our,is,gone,done";
$str3="a,about,actually,almost,also,although,always,am,an,and,any,are,as,at,be,became,become,but,by,can,could,did,do,does,each,either,else,for,from,had,has,have,hence,how,i,if,in,is,it,its,just,may,maybe,me,might,mine,must,my,mine,must,my,neither,nor,not,of,oh,ok,when,where,whereas,wherever,whenever,whether,which,while,who,whom,whoever,whose,why,will,with,within,without,would,yes,yet,you,your";
$arr1=explode(',',$str1);
$arr2=explode(',',$str2);
$arr3=explode(',',$str3);
$arr=array_unique (array_merge($arr1,$arr2,$arr3,$stopwords));
asort($arr);
echo implode(',',$arr);

exit;  

以下推文采用自研智能关联、组合专题技术…:

相关文章 延伸阅读

(文章仅为用户好友间自行存档分享,如有违规请在下方评论中留言说明,并点击上方举报钮,同时删除本文。) 本文二维码


评论