如何搜索词干匹配?
即目前我有许多文件在item_title字段中包含"滑板"一词,但只有3个文件包含"滑板"一词.因此,当我进行以下搜索时:
POST /my_index/my_type/_search
{
"size": 100,
"query" : {
"multi_match": {
"query": "skateboards",
"fields": [ "item_title^3" ]
}
}
}
Run Code Online (Sandbox Code Playgroud)
我只得到3个结果.但是,我还希望返回带有"滑板"一词的文件.
根据我对Elasticsearch的理解,我希望通过在item_title包含分析器的字段上指定映射来完成此操作,该分析器对每个单词的词干版本进行索引,但我似乎无法找到有关如何执行此操作的文档,表明它是以不同的方式完成的.
建议?
我曾经stem_graphic绘制过茎叶图并将其保存为 pdf 但在尝试输入标题时出现错误:Figure object have no attribute set_title.
ax, b=stem_graphic(mileage['disp'])
ax.set_title("Vicky")
This is the error
Traceback (most recent call last):
File "<pyshell#214>", line 1, in <module>
ax.set_title("Vicky")
AttributeError: 'Figure' object has no attribute 'set_title'
Run Code Online (Sandbox Code Playgroud) 我正在尝试从Stem项目中获取To Love With Toto乐队。
from io import StringIO
import socket
import urllib3
import time
import socks # SocksiPy module
import stem.process
from stem.util import term
SOCKS_PORT = 9150
# Set socks proxy and wrap the urllib module
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', SOCKS_PORT)
socket.socket = socks.socksocket
# Perform DNS resolution through the socket
def getaddrinfo(*args):
return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]
socket.getaddrinfo = getaddrinfo
def query(url):
"""
Uses urllib to fetch a site using SocksiPy for Tor over the SOCKS_PORT. …Run Code Online (Sandbox Code Playgroud) 我试过这个例子:
import getpass
import sys
import stem
import stem.connection
from stem.control import Controller
if __name__ == '__main__':
try:
controller = Controller.from_port()
except stem.SocketError as exc:
print("Unable to connect to tor on port 9051: %s" % exc)
sys.exit(1)
try:
controller.authenticate()
except stem.connection.MissingPassword:
pw = getpass.getpass("Controller password: ")
try:
controller.authenticate(password = pw)
except stem.connection.PasswordAuthFailed:
print("Unable to authenticate, password is incorrect")
sys.exit(1)
except stem.connection.AuthenticationFailure as exc:
print("Unable to authenticate: %s" % exc)
sys.exit(1)
print("Tor is running version %s" % controller.get_version())
controller.close() …Run Code Online (Sandbox Code Playgroud) 我正在使用一个使用Tor的刮刀,在这个示例项目中有一个简化版本:https://github.com/khpeek/scraper-compose.该项目具有以下(简化)结构:
.
??? docker-compose.yml
??? privoxy
? ??? config
? ??? Dockerfile
??? scraper
? ??? Dockerfile
? ??? requirements.txt
? ??? tutorial
? ? ??? scrapy.cfg
? ? ??? tutorial
? ? ??? extensions.py
? ? ??? __init__.py
? ? ??? items.py
? ? ??? middlewares.py
? ? ??? pipelines.py
? ? ??? settings.py
? ? ??? spiders
? ? ? ??? __init__.py
? ? ? ??? quotes_spider.py
? ? ??? tor_controller.py
? ??? wait-for …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用stem python库从远程机器连接到tor的控制端口(9051)。
矮胖
from stem import Signal
from stem.control import Controller
def set_new_ip():
"""Change IP using TOR"""
with Controller.from_port(address = '10.130.8.169', port=9051) as controller:
controller.authenticate(password='password')
controller.signal(Signal.NEWNYM)
set_new_ip()
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
Traceback (most recent call last):
File "/home/jkl/anaconda3/lib/python3.5/site-packages/stem/socket.py", line 398, in _make_socket
control_socket.connect((self._control_addr, self._control_port))
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "dum.py", line 28, in <module>
set_new_ip();
File "dum.py", line 7, in set_new_ip
with Controller.from_port(address = '10.130.4.162', port=9051) as controller: …Run Code Online (Sandbox Code Playgroud) 我目前正在使用以下设置来更改 Mac OS X 中的 IP 地址:
from stem import Signal
from stem.control import Controller
with Controller.from_port(port = 9051) as controller:
controller.authenticate()
controller.signal(Signal.NEWNYM)
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.1'
}
proxies = {
"http": "http://127.0.0.1:8118"
}
r_ip = requests.get("http://icanhazip.com", proxies=proxies, headers=headers_tor)
print(r_ip.text)
Run Code Online (Sandbox Code Playgroud)
我首先在命令行中运行 Tor,然后执行上面的命令。我注意到 IP 地址不会立即更改,而是需要几秒钟才能运行上面的代码块以生成新的 IP 地址。此外,在我运行 Tor 的终端页面上,它输出如下消息:
Aug 25 04:13:53.000 [notice] Rate limiting NEWNYM request: delaying by 7 second(s)
Run Code Online (Sandbox Code Playgroud)
有没有办法在没有延迟的情况下更改IP地址?
在如何在 matplolib 中制作更粗的干线中,描述了如何控制干线的宽度。但是如何控制词干标记的大小呢?
当我从词干文档中运行[example] [1]时,出现错误:
OSError: Process terminated: Failed to bind one of the listener ports.
Run Code Online (Sandbox Code Playgroud)
我正在运行的确切代码如下:
import socks
import socket
import stem.process
import urllib
from stem.util import term
SOCKS_PORT = 7000
# Set socks proxy and wrap the urllib module
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', SOCKS_PORT)
socket.socket = socks.socksocket
# Perform DNS resolution through the socket
def getaddrinfo(*args):
return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]
socket.getaddrinfo = getaddrinfo
def query(url):
return urllib.urlopen(url).read()
def print_bootstrap_lines(line):
if "Bootstrapped " in line:
print(term.format(line, term.Color.BLUE))
print(term.format("Starting Tor:\n", term.Attr.BOLD))
tor_process …Run Code Online (Sandbox Code Playgroud) 我想在使用时在python中制作更粗的干线plt.stem.
这是我的代码
import matplotlib.pyplot as plt
import numpy as np
N = 20
n = np.arange(0, 2*N, 1)
x = np.exp(-n/N)*np.exp(1j * 2*np.pi/N*n)
plt.stem(n,x.real)
plt.show()
Run Code Online (Sandbox Code Playgroud)
我改变了plt.stem(n,x.real,linewidth=10),但没有改变.有没有函数来设置linewidth的plt.stem?
我安装了Tor作为我的Windows机器上的服务运行,我试图通过Stem包在python中发出请求.在我的torrc文件中,我将ControlPort指定为9051并设置了HashedControlPassword.当我运行netstat时,我看到Tor在localhost:9050上运行,但没有任何东西正在侦听端口9051.因此,当我尝试连接到python中的ControlPort时:
Controller.from_port(port=9051)
Run Code Online (Sandbox Code Playgroud)
结果是
[Errno 10061] No connection could be made because the target machine actively refused it
Run Code Online (Sandbox Code Playgroud)
我尝试重新启动服务,我甚至重新安装了Tor浏览器,但似乎没有什么能让ControlPort工作.
stem ×11
python ×8
tor ×7
matplotlib ×2
python-3.x ×2
figure ×1
gplots ×1
markers ×1
privoxy ×1
python-2.7 ×1
scrapy ×1
search ×1