小编0TT*_*TT0的帖子

node.js TypeError:path必须是绝对的或指定root到res.sendFile [无法解析JSON]

[add]所以我的下一个问题是,当我尝试添加一个新的依赖(npm install --save socket.io).JSON文件也有效.我收到此错误:无法解析json

npm ERR! Unexpected string
npm ERR! File: /Users/John/package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR! 
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse 
Run Code Online (Sandbox Code Playgroud)

所以我一直试图弄清楚为什么这个错误已经回归.所有文件(HTML,JSON,JS)都在我桌面上的同一文件夹中.我正在使用node.js和socket.io

这是我的JS文件:

var app = require('express')();
var http = require('http').Server(app);

app.get('/', function(req, res){
  res.sendFile('index.html');
});

http.listen(3000,function(){
    console.log('listening on : 3000');
});
Run Code Online (Sandbox Code Playgroud)

这是返回的内容:

MacBook-Pro:~ John$ node /Users/John/Desktop/Chatapp/index.js 
listening on …
Run Code Online (Sandbox Code Playgroud)

javascript dependencies json node.js socket.io

134
推荐指数
4
解决办法
13万
查看次数

Tensorflow 中的 Python SSL 认证问题

我正在尝试下载据称在以下位置处理的 MNIST 数据:

tensorflow.examples.tutorials.mnist.input_data.read_data_sets()

据我所知 read_data_sets 向服务器发送拉取请求以下载(大约)1.5GB 的数据。

我不断收到此回溯错误:

文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py”,第 1318 行,在 do_open encode_chunked=req.has_header('Transfer-encoding')) 文件“/Library /Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request self._send_request(method, url, body, headers, encode_chunked) File "/Library/Frameworks/ Python.framework/Versions/3.6/lib/python3.6/http/client.py”,第 1285 行,在 _send_request self.endheaders(body, encode_chunked=encode_chunked) 文件“/Library/Frameworks/Python.framework/Versions/3.6 /lib/python3.6/http/client.py", line 1234, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ http/客户端。py”,第 1026 行,在 _send_output self.send(msg) 文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py”,第 964 行,在发送 self.connect () File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1400, in connect server_hostname=server_hostname) File "/Library/Frameworks/Python.framework/ Versions/3.6/lib/python3.6/ssl.py", line 401, in wrap_socket _context=self, _session=session) 文件"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl .py”,第 808 行,在/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1400, in connect server_hostname=server_hostname) 文件 "/Library/Frameworks/Python.framework/Versions/3.6/ …

python ssl download mnist tensorflow

6
推荐指数
2
解决办法
2473
查看次数

Python列表内存存储

据我了解,Python 列表本质上是 C 数组,它们分配特定的顺序内存块;但是,这些内存块实际上存储列表中的数据还是它们只是指向内存中存储实际数据的另一个位置?

它可能取决于列表中存储的对象的大小吗?因为您可以轻松地按顺序存储整数列表,但动态存储包括自定义对象在内的各种对象会更困难。

python memory list python-3.x

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

get_dumies中不可用的类型'list'错误

我有一个数据框,其数据类似于下面的示例数据.我正在尝试使用get_dummies为categories字段中的值创建虚拟变量,但是当我运行下面的代码时,我得到以下错误.我想要的是例如第一个记录,有一个名为"Ramen"的列,其中包含1个,另一个列名为"Japanese",其中包含1个.

样本数据:

                 user_id             business_id  stars_x  \
1  CxDOIDnH8gp9KXzpBHJYXw  XSiqtcVEsP6dLOL7ZA9OxA        4   
2  CxDOIDnH8gp9KXzpBHJYXw  v95ot_TNwTk1iJ5n56dR0g        3   
3  CxDOIDnH8gp9KXzpBHJYXw  uloYxyRAMesZzI99mfNInA        2   
4  CxDOIDnH8gp9KXzpBHJYXw  gtcsOodbmk4E0TulYHnlHA        4   

                address                                         attributes  \
1      522 Yonge Street  {u'BusinessParking': {u'garage': False, u'stre...   
2   1661 Denison Street  {u'BusinessParking': {u'garage': False, u'stre...   
3  4101 Rutherford Road  {u'BusinessParking': {u'garage': False, u'stre...   
4    815 W Bloor Street  {u'Alcohol': u'full_bar', u'HasTV': False, u'N...   

                                          categories        city  \
1                     [Restaurants, Ramen, Japanese]     Toronto   
2                    [Chinese, Seafood, Restaurants]     Markham   
3                             [Italian, Restaurants]  Woodbridge   
4  [Food, Coffee & …
Run Code Online (Sandbox Code Playgroud)

python pandas

2
推荐指数
1
解决办法
713
查看次数

将 REGEX 实体添加到 SpaCy 的 Matcher

我正在尝试将正则表达式定义的实体添加到 SpaCy 的 NER 管道中。理想情况下,我应该能够使用从具有定义的实体类型的 json 文件加载的任何正则表达式。作为一个例子,我正在尝试执行下面的代码。

下面的代码显示了我想要做的事情,遵循 Spacy 关于使用正则表达式的自定义属性的讨论中给出的示例。我尝试以各种方式调用“set_extension”方法(到 Doc、Span、Token),但无济于事。我什至不确定我应该将它们设置为什么。

    nlp = spacy.load("en_core_web_lg")
    matcher = Matcher(nlp.vocab)
    pattern = [{"_": {"country": {"REGEX": "^[Uu](\.?|nited) ?[Ss](\.|tates)$"}}}]
    matcher.add("US", None, pattern)
    doc = nlp(u"I'm from the United States.")
    matches = matcher(doc)
    for match_id, start, end in matches:
        string_id = nlp.vocab.strings[match_id]
       span = doc[start:end]
       print(match_id, string_id, start, end, span.text)
Run Code Online (Sandbox Code Playgroud)

我期望match_id, string_id 3 4 United States被打印出来。

相反,我得到AttributeError: [E046] Can't retrieve unregistered extension attribute 'country'. Did you forget to call the 'set_extension' method?

regex spacy

2
推荐指数
1
解决办法
4865
查看次数

内环显然卡住了

当我运行以下代码时,它仅记录一个循环;但是,当我删除内部循环时,它会按预期运行所有5次。我在俯视什么?

for (var i = 0; i < 5; i++) {
  var fieldset = document.getElementsByTagName("fieldset")[i];
  console.log("fieldset", i);
  var params = [];
  for (var i = 0; i < 5; i++) {
    params.push(fieldset.getElementsByTagName("input")[i].value);
  }
  console.log(params);
}
Run Code Online (Sandbox Code Playgroud)

javascript loops

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