[英]How to fix brain.js error while using twitter api
嗨,我正在嘗試制作一個神經網絡,用預制的短語回復推文我一直收到錯誤消息
C:\Users\boich\OneDrive\Documents\bruh\bruh>node script1.js
node:internal/modules/cjs/loader:928
throw err;
^
Error: Cannot find module 'C:\Users\boich\OneDrive\Documents\bruh\bruh\script1.js'
[90m at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)[39m
[90m at Function.Module._load (node:internal/modules/cjs/loader:769:27)[39m
[90m at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)[39m
[90m at node:internal/main/run_main_module:17:47[39m {
code: [32m'MODULE_NOT_FOUND'[39m,
requireStack: []
}
我想知道如何解決這個問題以及為什么會發生,PS。 我是 node.js 的新手
var TwitterPackage = require('twitter'); 常量 fs = 要求('fs');
var secret = {
consumer_key: '',
consumer_secret: '',
access_token_key: '', // These are filled out
access_token_secret: ''
}
var Twitter = new TwitterPackage(secret);
// Call the stream function and pass in 'statuses/filter', our filter object, and our callback
Twitter.stream('statuses/filter', { track: '#obama' }, function (stream) {
// ... when we get tweet data...
stream.on('data', function (tweet) {
// print out the text of the tweet that came in
console.log(tweet.text);
const brain = require('brain.js')
const data = require('./tweet.json')
const net = new brain.recurrent.LSTM(); {
(
hiddenlayers = [3, 3]
)
}
const trainingData = data.map(item => ({
input: item.income,
output: item.outcome
}));
const trainRes = net.train(trainingData, {
iterations: 5,
callback: step => console.log(step)
});
const output = net.run(tweet.text)
console.log(`Favorites: ${output}`);
//build our reply object
var statusObj = { status: "Hi @" + tweet.user.screen_name + `${output}` }
//call the post function to tweet something
Twitter.post('statuses/update', statusObj, function (error, tweetReply, response) {
//if we get an error print it out
if (error) {
console.log(error);
}
//print the text of the tweet we sent out
console.log(tweetReply.text);
});
});
// ... when we get an error...
stream.on('error', function (error) {
//print out the error
console.log(error);
});
});
我正在使用 Brain.js 和 Twitter。 To install twitter I did npm i twitter if thats the right package and yes i know the AUTH details are not filled out i know those need to be filled out but when i do fill them out it still doesnt work
沒關系由於某種原因文件的名稱導致它不存在
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.