- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 AWS 上的 Lambda 函数中使用 Python 拼写检查库 Pyenchant。 Pyenchant 是 C libenchant 库的包装器,它又依赖于 Aspell 等提供商提供的单词词典。
在我在 Lambda 上运行的 python 代码中,我能够在 AWS linux EC2 实例上成功导入已编译的 enchant 库和 C 库 (libenchant.so),并将输出复制到我的 Lambda 部署包。
但是,当在 Lambda 上运行时,pyenchant 库无法加载它需要工作的任何单词词典。然后,我使用以下方法在 EC2 实例上安装了 Aspell:
yum install aspell-en enchant-aspell
然后我将以下额外的 .so 文件复制到我的部署包的/lib 文件夹中:
我很确定 libenchant_aspell.so 是实际的字典,但它没有提取它,我不知道下一步该去哪里。
下面是我的 lambda_handler python 代码:
from __future__ import print_function
import os
import sys
import re
import enchant
enchant.set_param("enchant.aspell.dictionary.path","/var/task/lib")
def lambda_handler(event, context):
print("# List available enchant dictionary languages")
print(enchant.list_languages())
b = enchant.Broker()
print("# List available enchant brokers")
print(b.describe())
d = enchant.Dict("en_GB")
# print(d.provider.name)
# print(d.provider.file)
return "Done"
这是调用 Lambda 函数的输出:
START RequestId: 7539245b-d3d6-11e6-b7e6-edc1dc8cbdd4 Version: $LATEST
# List available enchant dictionary languages
[]
# List available enchant brokers
[]
Dictionary for language 'en_GB' could not be found: DictNotFoundError
Traceback (most recent call last):
File "/var/task/package_test.py", line 16, in lambda_handler
d = enchant.Dict("en_GB")
File "/var/task/enchant/__init__.py", line 558, in __init__
_EnchantObject.__init__(self)
File "/var/task/enchant/__init__.py", line 168, in __init__
self._init_this()
File "/var/task/enchant/__init__.py", line 565, in _init_this
this = self._broker._request_dict_data(self.tag)
File "/var/task/enchant/__init__.py", line 310, in _request_dict_data
self._raise_error(eStr % (tag,),DictNotFoundError)
File "/var/task/enchant/__init__.py", line 258, in _raise_error
raise eclass(default)
DictNotFoundError: Dictionary for language 'en_GB' could not be found
END RequestId: 7539245b-d3d6-11e6-b7e6-edc1dc8cbdd4
REPORT RequestId: 7539245b-d3d6-11e6-b7e6-edc1dc8cbdd4 Duration: 1.03 ms Billed Duration: 100 ms Memory Size: 256 MB Max Memory Used: 16 MB
如您所见,import enchant
工作正常,但找不到任何字典文件。
我真的坚持这个,花了 6 个小时的大部分时间试图弄清楚如何让它工作。在此先感谢您的帮助。
最佳答案
好吧,对于遇到此问题的任何其他人(可能没有人...),事实证明无法在 Lambda 上使用此程序包。与没有正确的基础设施来加载多个层次的共享对象资源有关。最后,我只是在 EC2 上使用了一个 Flask Web 服务器,它运行良好。
关于python - 在 AWS Lambda 上使用 Pyenchant,可以加载包但不能加载提供者字典,从 EC2 上的源代码编译并提取 .so 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41500160/
Pyenchant 弄乱了外来字符并且拼写检查失败。我的女朋友是德国人,所以“häßlich”这个词是一个真正的德语单词,我也使用不同的拼写检查服务检查了这个单词。 脚本文件编码为 ANSI 或 UT
我有一个调用 PyEnchant 的多线程 Python 应用程序。我不是 Python 专家,大部分代码都来自第三方。我所做的是添加代码以从多线程应用程序调用 PyEnchant。由于我进行了更改,
我尝试使用 python 库进行拼写检查、更正和替换。 对于一些复杂的拼写更正,我需要有第二意见,并看到被替换的单词加下划线或删除线。 即使文件输出是rtf格式也可以。如何解决? 到目前为止的努力。
感谢 Stackoverflow,我了解了 pyenchant 库。 我正在寻找通过附魔使用的德语词典“de_DE”,但找不到。我在哪里可以得到它,我应该把它放在哪个目录以便 pyenchant 可以
我在 Python 中使用 pyenchant 包进行拼写检查。我能够成功地使用英语、法语、德语等语言。 另外,我想为意大利语和西类牙语做这件事。我使用 enchant.list_languages(
我得到了 PyEnchant包含多种语言的文件:en_US、en_AU、de_DE、fr_FR。现在我调用字典列表,只看到小集合:'en'、'en_US'、'en_GB'、'en_CA'。我打电话:
我正在尝试从网络论坛获取大量自然语言,并使用 PyEnchant 更正拼写。这些文本通常是非正式的,并且涉及医疗问题,因此我创建了一个文本文件“test.pwl”,其中包含相关的医学单词、聊天缩写等。
我正在尝试加载 pyenchant 进行某些文本处理,但是在使用 pip install pyenchant 之后,当我尝试导入 pyenchant 时,出现以下错误。有人以前见过这个或者知道如何解决
特别是,我想下载希腊语和德语的。这可能吗? 如果没有,那么据我了解,我必须利用 libreoffice 项目中的相应文件来构建自己的词典。我说得对吗? 最佳答案 如果您使用 Linux,例如乌类图 从
我正在尝试从我使用 PyEnchant 的英语词典创建一本新词典。例如:英语单词-->"new"变为-->"new":1e1n1w(我正在计算字母按字母顺序) 我的问题是我不知道如何访问英语词典的对象
我刚开始使用 PyEnchant 库。 使用 PyEnchant,我想编写自定义代码: 在拼写检查中忽略某些单词,例如“Internet Slangs” - 自定义过滤器可能会有所帮助??? 将“go
import enchant import wx from enchant.checker import SpellChecker from enchant.checker.wxSpellChecke
因此,除了语言词典之外,PyEnchant 还允许您定义正确拼写单词的个人单词列表: d2 = enchant.DictWithPWL("en_US","mywords.txt") 然而,生成的d2检
我正在使用 CentOS 5与 Python 2.7安装。我正在尝试安装 pyenchant图书馆,但在所有情况下都失败了。 二手 pip install pyenchant - 这产生了以下错误 -
似乎 PyEnchant 需要 C enchant 库。我将如何在 Heroku 上安装它,这可能吗? 根据 this question ,我需要为 Heroku 编写自己的构建包,所以我想这是一种方
PyEnchant 包含在 bundle 中的 site-packages.zip 中,但它无法加载任何字典!为什么不?我总是收到“未找到字典”错误。但字典位于 site-packages.zip/e
我正在尝试为附魔库 (pyenchant) 安装 python 绑定(bind),根据自述文件,它应该像运行 python setup.py install 一样简单但是当我尝试这样做时,出现了这个错
我想安装 PyEnchant 进行拼写检查,它需要 enchant安装在我的机器上。但是我能找到的所有 .exe 文件都是针对 win32 系统的。有没有其他方法可以在 Windows 64 位机器上
我正在做文本处理。我需要 PyEnchant 库来验证文本中的特定单词是否是有效的英语单词。但是,它仅适用于 Python 的 32 位安装。我需要 64 位 Python 来处理大型文本文件的内存问
我正在尝试在 Mac OS X Yosemite 上安装 pyenchant。它在 linux 机器上运行良好,但在 mac 上运行不正常,我遇到以下错误: ImportError: The 'enc
我是一名优秀的程序员,十分优秀!