**文書の過去の版を表示しています。**
var fs = require("fs"); var data = fs.readFileSync('/System/Volumes/Data/home/2544842260/Public/100again.txt'); var arr = data.toString().split("\n"); arr.sort(); var speciesNumber=arr.length var speciesList={} var processlist=speciesList var savelist=[] var wordList=[] var countList=[] //save the data to array for (var s=0; s<speciesNumber; s++) { var rowKey=s+1 processlist["species"+rowKey]=arr[s].split(";") } //counting words var layer=0 do{ var counttmp=[] var wordListtmp=[] for (var s=0; s<speciesNumber; s++){ var rowKey=s+1 var existchecker="nonexist" for (i=0;i<wordListtmp.length;i++){ console.log("s "+s) console.log("rowkey "+rowKey) console.log("remain "+countNumber) console.log("species "+rowKey) console.log("layer "+layer) if (processlist["species"+rowKey][layer]===wordListtmp[i]){ existchecker="exist" var posilog=i } } if (existchecker=="exist"){ counttmp[posilog]=counttmp[posilog]+1 } else{ wordListtmp.push(processlist["species"+rowKey][layer]) counttmp.push(1) } } //get most counted word var countNumber=0 for (var j=0;j<wordListtmp.length;j++){ if (countNumber<counttmp[j]){ countNumber=counttmp[j] var indexOfCountNumber=j } var mostCountedWord=wordListtmp[indexOfCountNumber] } //keep the most counted species in processlist; //save other to savelist. savelisttmp=[] for (var s=0; s<speciesNumber; s++){ var rowKey=s+1 if (mostCountedWord!==processlist["species"+rowKey][layer]){ savelisttmp.push("species"+rowKey) delete processlist["species"+rowKey] } } if (savelisttmp.length!==0){ savelist.push(savelisttmp) } //save less counted words and numbers to list wordList.push(wordListtmp) countList.push(counttmp) layer=layer+1 speciesNumber=countNumber console.log("processlist length:") console.log(Object.keys(processlist).length) console.log("wordlist:") console.log(wordList) console.log("countlist:") console.log(countList) console.log("times:") console.log(countNumber) console.log("most counted word:") console.log(mostCountedWord) console.log(" ") console.log("savelist:") console.log(savelist) console.log(" ") } while (countNumber>(speciesNumber/8))
is not working well
/System/Volumes/Data/home/2544842260/Public/classifyWithAssosiateArray.js:42 wordListtmp.push(processlist["species"+rowKey][layer]) ^ TypeError: Cannot read property '10' of undefined at Object.<anonymous> (/System/Volumes/Data/home/2544842260/Public/classifyWithAssosiateArray.js:42:59) at Module._compile (node:internal/modules/cjs/loader:1108:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10) at Module.load (node:internal/modules/cjs/loader:973:32) at Function.Module._load (node:internal/modules/cjs/loader:813:14) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) at node:internal/main/run_main_module:17:47 pch12005m:Public 2544842260$