Skip to main content

成语与成语接龙查询工具

Project description

成语与成语接龙查询工具(无声调版)

pypi python_vesion

用于成语接龙。

关于

特性

  1. 用于玩转成语接龙的种种方法。

安装

$ pip install China-idiom-without-tone

升级

$ pip install -U China-idiom-without-tone

依赖库

pandas>=0.23.4

使用示例

首先导入库

import china_idiom as idiom

1. 判断一个词是否是成语。

idiom.is_idiom('一心一意')
>>> True

2. 搜索成语

功能说明:

search_idiom(word, position=0, count=1, is_detail=False)
    :param word: str,关键词
    :param position: int, 所在位置,默认为:0
    :param count: int ,返回最大数量 默认为: 1
    :param is_detail: bool,是否返回详细内容(包括:拼音,拼音缩写,解释,来源,造句)
    :return: list

实用式例 1:简单查询

idiom.search_idiom(word='猪')
>>> ['指猪骂狗']

实用式例 2:查询成语第 2 个字是『心』的成语,最大查询数量为 2, 返回详细内容。

idiom.search_idiom(word='心', position=2, count=2, is_detail=True)
>>> 
[{'word': '热心快肠',
  'pinyin': 'rè xīn kuài cháng',
  'abbreviation': 'rxkc',
  'explanation': '形容热情直爽。',
  'derivation': '柯岩《奇异的书简·东方的明珠三》也许因为是她热心快肠,群众有事爱找她拿主意,帮个忙。”',
  'example': '无'},
 {'word': '人心大快',
  'pinyin': 'rén xīn dà kuài',
  'abbreviation': 'rxdk',
  'explanation': '快痛快。指坏人坏事受到惩罚或打击,使大家非常痛快。',
  'derivation': '明·沈德符《万历野获编·立枷》东山受恩反噬,其罪盖浮于诸龙光。当时人心大快,佐以此得缙绅闻声,然亦不云立枷。”',
  'example': '无'}]

3. 成语接龙

功能说明:

def next_idioms_solitaire(word, count=1, heteronym=True, ignoreTone=True , smaller=False):
    """
    :param word: str, 成语
    :param count: int, 返回数量
    :param heteronym: bool,是否可以使用同音字
    :param ignoreTone: bool,是否忽略声调,前提:heteronym=True。默认为 True。
    :param smaller: bool, 是否选择尽可能的少的后续
    :return: list
    """

式例代码 1 :

idiom.next_idioms_solitaire('一生一世')
>>> ['逝将去汝']

式例代码 2 :

idiom.next_idioms_solitaire('一生一世', count=3, heteronym=False, ignoreTone=False)
>>> ['世态炎凉', '世代书香', '世上无难事']

代码说明:获取可接『一生一世』的成语。返回最大数量为 3。不能用于同音字。

4. 判断两个成语是否能接龙。

示例代码:

idiom.is_idiom_solitaire('一生一世', '逝将去汝', heteronym=False, ignoreTone=False)
>>> True

idiom.is_idiom_solitaire('一生一世', '生生世世', heteronym=False, ignoreTone=False)
>>> False

5. 自动接龙模式。

输入一个汉字或者成语,程序自动输出一组成语接龙的结果。

功能说明:

def auto_idioms_solitaire(word, max_count=10, heteronym=True, ignoreTone=True):
    """
    自动接龙模式 - 输入一个汉字或者成语,程序自动输出一组成语接龙的结果。
    :param word: str 起始汉字或者成语。
    :param max_count: int, 最大长度。默认最大长度:20。
    :param heteronym: bool, 是否可以用同音字。默认 True。
    :param ignoreTone: bool, 是否忽略声调,前提:heteronym=True。默认为 True。
    :return: list
    """

示例代码:

idiom.auto_idioms_solitaire('一生一世')
>>>
["一生一世", "适心娱目", "目兔顾犬", "犬马之力", "立时三刻", "刻意经营", "蝇粪点玉", "鬻驽窃价", "驾轻就熟", "熟路轻辙"]

资源文件

Lincese

MIT License

Copyright (c) 2019  Thunder Bouble
Copyright (c) 2025 tangwei-dev

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

china_idiom_without_tone-0.1.0.tar.gz (4.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

china_idiom_without_tone-0.1.0-py3-none-any.whl (4.4 MB view details)

Uploaded Python 3

File details

Details for the file china_idiom_without_tone-0.1.0.tar.gz.

File metadata

File hashes

Hashes for china_idiom_without_tone-0.1.0.tar.gz
Algorithm Hash digest
SHA256 58e05c141524c5a8c3bf721d733f4237c713782579236f3a349c137ef8e0c22e
MD5 9a3752462f1c451a6148677b7cc77016
BLAKE2b-256 a5ef881cd28c397dade42745ec2b28840fd8db9cc04eb510e392c6d8208de56f

See more details on using hashes here.

File details

Details for the file china_idiom_without_tone-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for china_idiom_without_tone-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f73ad59ec0ed9f921abf5f6ca87e085ee844a6285191843e8b0a4614edfc10cb
MD5 81a6bc5914104009428432f838d8038e
BLAKE2b-256 beb27d5fe2d112ee3fcb5e53c24efd275e66710c68a8ea3f3866a26890556167

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page