我知道拼写检查器并不完美,但随着文本数量的增加,它们会变得更加有用。如何拼写检查有数千页的网站?
编辑:由于复杂的服务器端处理,我可以获取页面的唯一方法是通过 HTTP。也不能外包给第三方。
编辑:我有一个我需要检查的网站上所有 URL 的列表。
我知道拼写检查器并不完美,但随着文本数量的增加,它们会变得更加有用。如何拼写检查有数千页的网站?
编辑:由于复杂的服务器端处理,我可以获取页面的唯一方法是通过 HTTP。也不能外包给第三方。
编辑:我有一个我需要检查的网站上所有 URL 的列表。
Lynx 似乎擅长获取我需要的文本(正文内容和替代文本)而忽略我不需要的内容(嵌入的 Javascript 和 CSS)。
lynx -dump http://www.example.com
它还列出了页面中的所有 URL(转换为它们的绝对形式),可以使用 grep 将其过滤掉:
lynx -dump http://www.example.com | grep -v "http"
file://
如果我使用 wget 镜像站点,URL 也可以是本地的 ( )。
我将编写一个脚本,该脚本将使用此方法处理一组 URL,并将每个页面输出到一个单独的文本文件。然后,我可以使用现有的拼写检查解决方案来检查文件(或结合所有小文件的单个大文件)。
这将忽略标题和元元素中的文本。这些可以单独进行拼写检查。
就在我发现Spello 网站拼写检查器的前几天查看。它使用我的 NHunspell(Open office Spell Checker for .NET) libaray。你可以试一试。
如果您可以以文件的形式访问站点的内容,您可以编写一个小的 Unix shell 脚本来完成这项工作。以下脚本将打印文件名、行号和拼写错误的单词。输出的质量取决于系统字典的质量。
#!/bin/sh
# Find HTML files
find $1 -name \*.html -type f |
while read f
do
# Split file into words
sed '
# Remove CSS
/<style/,/<\/style/d
# Remove Javascript
/<script/,/<\/script/d
# Remove HTML tags
s/<[^>]*>//g
# Remove non-word characters
s/[^a-zA-Z]/ /g
# Split words into lines
s/[ ][ ]*/\
/g ' "$f" |
# Remove blank lines
sed '/^$/d' |
# Sort the words
sort -u |
# Print words not in the dictionary
comm -23 - /usr/share/dict/words >/tmp/spell.$$.out
# See if errors were found
if [ -s /tmp/spell.$$.out ]
then
# Print file, number, and matching words
fgrep -Hno -f /tmp/spell.$$.out "$f"
fi
done
# Remove temporary file
rm /tmp/spell.$$.out
我强烈推荐Inspyder InSite,它是商业软件,但他们有试用版,物有所值。我多年来一直使用它来检查客户网站的拼写。它支持自动化/调度,并且可以与 CMS 自定义单词列表集成。这也是链接检查的好方法,可以生成报告。
You could do this with a shell script combining wget with aspell. Did you have a programming environment in mind?
I'd personally use python with Beautiful Soup to extract the text from the tags, and pipe the text through aspell.
If its a one off, and due to the number of pages to check it might be worth considering somthing like spellr.us which would be a quick solution. You can entering in your website url on the homepage to get a feel for how it would report spelling mistakes.
but I'm sure there are some free alternatives.
我们在 ASP.NET 应用程序中使用 Telerik RAD Spell 控件。
You may want to check out a library like jspell.
我在这里用 Ruby 制作了一个仅限英语的拼写检查器:https ://github.com/Vinietskyzilla/fuzzy-wookie
试试看。
它的主要缺陷是缺乏包含每个单词所有形式的完整词典(复数,不仅仅是单数;'has',而不仅仅是'have')。替换你自己的字典,如果你能找到或制作更好的字典,那会非常棒。
除此之外,我认为对单个网页进行拼写检查的最简单方法是按 ctrl+a(或 cmd+a)选择所有文本,然后将其复制并粘贴到网页上的多行文本框中。(例如<html><head></head><body><textarea></textarea></body></html>
。)您的浏览器应在所有拼写错误的单词下划线。
在您的 web 应用程序中使用模板(以及)(如果您正在对网站进行编程,而不仅仅是编写 html),以及一个包含拼写检查的 html 编辑器。Eclipse 确实如此。
如果由于某种原因这不可能......是的,wget 下载完成的页面,如下所示:
@Anthony Roy 我已经完成了你所做的。通过 Pyenchant 将页面通过 Aspell 管道传输。我有英文词典(GB、CA、US)在我的网站https://www.validator.pro/上使用。联系我,我会为你安排一个一次性的工作来检查 1000 页或更多