获取文本文件中单词列表的字典定义的最简单方法

发布于 2024-08-08 15:03:36 字数 430 浏览 12 评论 0原文

File1:

hello
world

我不知道从文本文件中提取单词列表、找到它们的定义并将它们粘贴到输出文本文件中的最佳方法。我一直在考虑使用 WordNet - 但不知道如何自动化该过程。

有谁有任何想法(也许是谷歌/API/linux应用程序)可以用来查找单词的定义,然后将它们粘贴到文本文件中?

文件2:

an expression of greeting; "every morning they exchanged polite hellos" 
universe: everything that exists anywhere; "they study the evolution of the universe"; "the biggest tree in existence"

File1:

hello
world

I don't know the best method to extract a list of words from a text file, find their definitions and paste them into an output textfile. I've been thinking of using WordNet - but don't know how to automate the process.

Does anyone have any ideas (perhaps google/APIs/linux applications) that one could use to find the definitions of words with, and then paste them into a text file?

File2:

an expression of greeting; "every morning they exchanged polite hellos" 
universe: everything that exists anywhere; "they study the evolution of the universe"; "the biggest tree in existence"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心是晴朗的。 2024-08-15 15:03:36

尽管 API 或库可能是可行的方法(此处'一些 Perl 的东西),下面的 Bash 脚本非常可能会给你一些想法:

saveIFS="$IFS"
for w in hello goodbye bicycle world
do
    echo
    echo "------- $w -------"
    def=$(wn $w -over)
    IFS=

如果你在文件中有一个单词列表,一个单词到一行,改变第一个 for 和上面脚本的最后 done 行:

while read -r w
    # . . .
done < wordlist
\n' for line in $def do echo -e "\t${line}" IFS="$saveIFS" if [[ $line =~ ^[[:digit:]]*\. ]] then for word in $line do echo -e "\t\t${word%*[,;]}" done fi done IFS="$saveIFS" done

如果你在文件中有一个单词列表,一个单词到一行,改变第一个 for 和上面脚本的最后 done 行:

Although an API or library is probably the way to go (here's some Perl stuff), the Bash script below, which is very rough might give you some ideas:

saveIFS="$IFS"
for w in hello goodbye bicycle world
do
    echo
    echo "------- $w -------"
    def=$(wn $w -over)
    IFS=

If you have a list of words in a file, one word to a line, change the first for and last done lines of the script above to:

while read -r w
    # . . .
done < wordlist
\n' for line in $def do echo -e "\t${line}" IFS="$saveIFS" if [[ $line =~ ^[[:digit:]]*\. ]] then for word in $line do echo -e "\t\t${word%*[,;]}" done fi done IFS="$saveIFS" done

If you have a list of words in a file, one word to a line, change the first for and last done lines of the script above to:

余生再见 2024-08-15 15:03:36

请参阅字典 API 或库了解多种解决方案。

See Dictionary API or Library for several solutions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文