小编Har*_*ech的帖子

从字符串数组创建唯一组合的数组

我正在编写一些需要一段文本的内容,并将其分解为可用于查找类似文本块的可能的数据库查询.(类似于我输入时生成的"类似问题"列表)基本过程:

  1. 从文本中删除停用词
  2. 删除特殊字符
  3. 从剩下的文本中创建一个独特的"词干"数组
  4. 创建一个可能的茎阵列组合数组(我被卡住了......有点)

这是我到目前为止所拥有的:

    //baseList starts with an empty array
    //candList starts with the array of unique stems
    //target is where the arrays of unique combinations are stored

    function createUniqueCombos(baseList,candList,target){

    for(var i=0;i<candList.length;i++){         

        //copy the base List
        var newList = baseList.slice(0);

        //add the candidate list item to the base list copy
        newList.push(candList[i]);

        //add the new array to the target array
        target.push(newList);   

        //re-call function using new array as baseList
        //and remaining candidates as candList
        var nextCandList = candList.slice(i + 1); …
Run Code Online (Sandbox Code Playgroud)

javascript algorithm combinations combinatorics

7
推荐指数
1
解决办法
1224
查看次数