小编Gra*_*ace的帖子

当我尝试使用 python networkx 总结文本文档时出现错误“幂迭代未能在 100 次迭代内收敛”)

当我尝试使用 python networkx 总结文本文档(如下面的代码所示)时,我得到了 PowerIterationFailedConvergence:(PowerIterationFailedConvergence(...), 'power iteration failed to fusion inside 100 iterations') 。代码“scores = nx.pagerank(sentence_similarity_graph)”显示的错误

\n
def read_article(file_name):\n    file = open(file_name, "r",encoding="utf8")\n    filedata = file.readlines()\n    text=""\n    for s in filedata:\n        text=text+s.replace("\\n","")\n        text=re.sub(' +', ' ', text) #remove space\n        text=re.sub('\xe2\x80\x94',' ',text)\n    \n    article = text.split(". ") \n    sentences = []\n    for sentence in article:\n#         print(sentence)\n        sentences.append(sentence.replace("[^a-zA-Z]", "").split(" "))\n    sentences.pop()\n    new_sent=[]\n    for lst in sentences:\n        newlst=[]\n        for i in range(len(lst)):\n            if lst[i].lower()!=lst[i-1].lower():\n                newlst.append(lst[i])\n            else:\n                newlst=newlst\n        new_sent.append(newlst)\n    return new_sent\ndef sentence_similarity(sent1, sent2, stopwords=None):\n …
Run Code Online (Sandbox Code Playgroud)

python nlp networkx

6
推荐指数
1
解决办法
9772
查看次数

无法从函数源生成清单:类型错误:无法读取未定义的属性(读取“秘密”)反应 js 节点 js

我尝试替换:

const stripe =const stripe=require("stripe")('sk_test_51KMbN...');
Run Code Online (Sandbox Code Playgroud)

const stripe = require("stripe")(functions.config().stripe.secret);
Run Code Online (Sandbox Code Playgroud)

但是当我运行 firebase 模拟器时,我遇到了一个错误:

错误:无法从源加载函数定义:无法从​​函数源生成清单:TypeError:无法读取未定义的属性(读取“秘密”)

我已经将其设置如下:

firebase functions:config:set stripe.secret=< SECRET KEY>
Run Code Online (Sandbox Code Playgroud)

我可以通过运行看到它:

firebase functions:config:get
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我在functions/index.js中的代码是

const functions = require("firebase-functions");
const express=require("express");
const cors=require("cors");
require('dotenv').config({ path: './.env' });
//API
const stripe = require("stripe")(functions.config().stripe.secret);

//App config
const app=express();
var admin = require("firebase-admin");
var serviceAccount = require("./serviceAccountKey.json");
admin.initializeApp({
  credential: admin.credential.cert(serviceAccount)
});
//middlewares
app.use(cors({origin: true}));
app.use(express.json());
async function createCheckoutSession(req, res) {
  
  const domainUrl = process.env.WEB_APP_URL;
  const { line_items, customer_email } = req.body;
  if (!line_items || …
Run Code Online (Sandbox Code Playgroud)

node.js stripe-payments firebase reactjs google-cloud-functions

0
推荐指数
1
解决办法
3673
查看次数