zoukankan      html  css  js  c++  java
  • python自然语言处理——2.3 更多关于python:代码重用

    微信公众号:数据运营人
    本系列为博主的读书学习笔记,如需转载请注明出处。

    第二章 获取文本预料和词汇资源

    2.3 更多关于python:代码重用函数及函数的调用

    2.3 更多关于python:代码重用

    函数及函数的调用
     1def plural(word):                                                     
    2    if word.endswith("y"):                                             
    3        return word[:-1]+"ies"                                        
    4    elif word[-1in 'sx' or word[-2:] in ['sh','ch']:                
    5        return word +'es'                                             
    6    elif word.endswith('an'):                                          
    7        return word[:-2] + 'en'                                       
    8    else:                                                             
    9        return word +"s"                                              
    10print(plural("fairy"))                                                
    11print(plural("women"))    
  • 相关阅读:
    java_list<String> string[]拼接json
    java_method_删除事务回滚
    java_jdk_JDK版本切换批处理脚本
    java_js_检查是否全为数字
    java_method_stringUtils
    java_method_下拉框成json
    java_method_下载导入模版
    java_js_json_日期格式化
    java_js从字符串中截取数字
    gulp+tp5配置
  • 原文地址:https://www.cnblogs.com/ly803744/p/10082891.html
Copyright © 2011-2022 走看看