selfteaching / selfteaching/selfteaching-python-camp
Day10 如何写出一份上台面的 issue?(供吐槽版)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 151
- Forks
- 875
- PR merge metrics
- No merged PRs in 30d
Description
1. 什么是 ”jieba" ?
"jieba"是一个中文分词 module。
而所谓的中文分词,无非是要折腾明白”一个连续的中文字符串究竟包含了哪些词“。比如,在张小龙的四小时演讲刷屏之际,有人特意统计了张小龙的整场演讲没有用到哪些词,最常用的词又是哪些,并以此作为论据,写出了一篇广为传播的文章。
2. 如何安装 “jieba”?
打开“终端”(Terminal),输入:
pip install jieba
终端返回”Successfuly installed jieba-0.39",示意安装成功。
3. 我们会使用该 module 的哪些分词 method ?
jieba.cut("需要分词的字符串", cut_all=True / False),返回一个分词完毕的”字符串“
jieba.lcut("需要分词的字符串", cut_all=True / False),返回一个分词完毕的”列表“
我们选用 jieba.lcut() ,因为”列表“方便我们进行后续的词频排序。
4. 什么是 “分词模式” ?”jieba" 的 “分词模式” 有哪些?
在不同的使用场景下,我们对“分词功能”的精确度和速度也有着不同的要求。因此,jieba 提供了3种“分词模式”:
1、精确模式
2、全模式
3、搜索引擎模式
5. 代码示例及输出结果
5.1 精确模式
参数 cut_all=False(若为True,则为全模式);不输入参数 cut_all,则默认为精确模式。我们选择后者 jieba.lcut("需要分词的字符串") :
import jieba # 导入 jieba
string = "他来到了网易杭研大厦" # 为变量 string 赋值字符串
seg_list = jieba.lcut(string) # 调用 jieba method 进行分词,将结果赋值给 seg_list
print(seg_list) # 输出 该列表
# 结果: ["他", "来到", "了", "网易", "杭研", "大厦"]
5.2 全模式、搜索引擎模式
6. 直面 Day 10
有了强大的 jieba module,接下来的事儿就好办了。
seg_list = jieba.lcut(string) # 对字符串 string 进行分词,并将结果赋值给 ”seg_list"
seg_dic = dict([(word,seg_list.count(word)) for word in seg_list if len(word)>=2]) # 用“列表推导式(List Comprehension),遍历seg_list,生成词典seg_dic,该词典的”key“长度均 >=2
c = Counter(seg_dic) # 以词典seg_dic为对象创建一个计数器,并赋值给 c
stats = c.most_common(count) # 返回统计结果 stats,该列表包含了“count”数量的最常见元素及它们对应的值
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file, test, or concrete change is named. Start by reviewing the Day 10 tutorial text and the repository’s contribution guidance; completion cannot be determined until an edit or acceptance criterion is specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- content, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100