zoukankan      html  css  js  c++  java
  • shell(3)拼写检查与词典操作

     1:Linux下,在/usr/share/dict下包含了词典文件,检查一个单词是否在词典里:

    #!/bin/bash  
    #文件名:checkout.sh  
    #检查给定的单词是否为词典中的单词  
      
    word=$1;  
    grep "^$1$" /usr/share/dict/words -q  
      
    if [ $? -eq 0 ];then  
        echo "word is a dictionary word"  
    else  
        echo "word is not a dictionary word"  
    fi                    

    其中:grep 语句里,^匹配开头,$匹配结尾  -q 禁止输出,若没有-q,当在词典里时,会先输出单词

    2:通过aspell来检查某个单词是否在词典中

    #!/bin/bash
    #filename:aspellcheck.sh
    #用拼写检查命令aspell来检查某个单词是否在词典中
    
    word=$1;
    #set -x
    output=`echo "$word" ` | aspell list
    
    if [ -z $output ];then
        echo "word is a dictionary"
    else
        echo "word is not a dictionary"
    fi
    ~    

    但是还有点问题:Error: No word lists can be found for the language "en_US". 还未解决

  • 相关阅读:
    django之admin管理工具
    django之中间件
    cookie和session
    day052-53 django框架
    day050 前端Jquery库的使用
    sprint
    Scrum 项目1.0
    【团队项目】3.0
    [读书笔记]
    【团队项目】2.0
  • 原文地址:https://www.cnblogs.com/lemon-le/p/5795664.html
Copyright © 2011-2022 走看看