[英]How to fix brain.js error while using twitter api
Hi im trying to make a neural network that replies to tweets with premade phrases i keep getting the error嗨,我正在尝试制作一个神经网络,用预制的短语回复推文我一直收到错误消息
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: []
}
I want to know how I could fix this and why its happening, PS.我想知道如何解决这个问题以及为什么会发生,PS。 I am new to node.js
我是 node.js 的新手
var TwitterPackage = require('twitter'); var TwitterPackage = require('twitter'); const fs = require('fs');
常量 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);
});
});
im using Brain.js And Twitter.我正在使用 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
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
nevermind for some reason the name of the file was causing it not exist没关系由于某种原因文件的名称导致它不存在
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.