python将英语中的复数名词变成单数名词

本文介绍如何使用Python编程,通过自然语言处理规则和nltk库,将英语复数名词转化为单数形式,包括常见构成方式、规则和不规则变化的处理方法,以及WordNetLemmatizer的运用实例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

python将英语中的复数名词变成单数名词

英语复数名词的常见构成方式

  • 元音字母和大多数除s,z,x,sh,ch之外的辅音字母(或字母组合)直接加-s,清辅音后的s读作/s/ ,元音和浊辅音后的s读作/z/。如:bag-bags,biscuit-biscuits,egg-eggs.

当单数名词结尾为se,ze,ge,ce时(其词尾辅音为/s,z,ʃ,ʒ/等),加s后读作/iz/

如vase-vases,fridge-fridges

  • 当单数名词结尾为s,z,x,sh,软音ch时(其词尾辅音为/s,z,ʃ,ʒ/等)加-es(读/iz/), 如:box-boxes, peach-peaches. (o有时也是,但es读音为/z/如hero-heroes)例外:stomach-stomachs(因ch读作/k/)

  • 不规则变化,如:ox-oxen, child-children, man-men,mouse-mice,louse-lice

  • 不变化,如:deer-deer, sheep-sheep以及集体名词people-people,Chinese-Chinese。

  • 在中间加s,用于连词,如:hanger_on-hangers_on,maid_of_honor-maids_of_honor.

  • 可数名词以辅音字母+y结尾,把y去掉再加ies,如:hobby-hobbies,factory-factories.

  • 含有oo的可数名词,把oo变成ee,如:foot- feet,tooth-teeth.

  • 以f或fe结尾的单词,将f或fe去掉,加上ves,如:scarf-scarves,knife-knives

另外,英语有不少词汇借自其它语言,欧洲语言祖先之一的拉丁词汇有不少被完整地引入其中,复数变化规则也没改。

  • 词尾um或on,复数变为a,如album-alba,minimum-minima,phenomenon-phenomena

  • 词尾为us,复数变为i,如radius-radii,narcissus-narcissi

  • 词尾为a,复数加e,如alga-algae,larva-larvae

所有各种形式的复数名词都可以变成单数名词。具体程序如下

from nltk import word_tokenize, pos_tag
from nltk.corpus import wordnet
from nltk.stem import WordNetLemmatizer


# 获取单词的词性
def get_wordnet_pos(tag):
    if tag.startswith('J'):
        return wordnet.ADJ
    elif tag.startswith('V'):
        return wordnet.VERB
    elif tag.startswith('N'):
        return wordnet.NOUN
    elif tag.startswith('R'):
        return wordnet.ADV
    else:
        return None


sentence = 'feet' # 举个例子
tokens = word_tokenize(sentence)  # 分词
tagged_sent = pos_tag(tokens)  # 获取单词词性

wnl = WordNetLemmatizer()
lemmas_sent = []
for tag in tagged_sent:
    wordnet_pos = get_wordnet_pos(tag[1]) or wordnet.NOUN
    lemmas_sent.append(wnl.lemmatize(tag[0], pos=wordnet_pos))  # 词形还原

print(" ".join(lemmas_sent))
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值