#9943 : adding some coverage for string
Describe your change:
#9943
- [ ] Add an algorithm?
- [ ] Fix a bug or typo in an existing algorithm?
- [x] Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
- [ ] Documentation change?
Checklist:
- [X] I have read CONTRIBUTING.md.
- [X] This pull request is all my own work -- I have not plagiarized.
- [X] I know that pull requests will not be merged if they fail the automated tests.
- [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
- [X] All new Python files are placed inside an existing directory.
- [X] All filenames are in all lowercase characters with no spaces or dashes.
- [X] All functions and variable names follow Python naming conventions.
- [X] All function parameters and return values are annotated with Python type hints.
- [X] All functions have doctests that pass the automated testing.
- [X] All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
- [X] If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".
documents = ["文档1内容", "文档2内容", "文档3内容"] target_string = "特定字符串" count = 0 for doc in documents: if target_string in doc: count += 1 print(f"{target_string} 在 {count} 篇文档中出现。")
若要增加其覆盖范围,可以通过一些文本处理手段,比如在未出现该字符串的文档中适当添加该字符串等。
for doc in documents: if target_string not in doc: doc += " " + target_string print("处理后:") count = 0 for doc in documents: if target_string in doc: count += 1 print(f"{target_string} 在 {count} 篇文档中出现。")
documents = ["文档1内容", "文档2内容", "文档3内容"] target_string = "特定字符串" count = 0 for doc in documents: if target_string in doc: count += 1 print(f"{target_string} 在 {count} 篇文档中出现。")
若要增加其覆盖范围,可以通过一些文本处理手段,比如在未出现该字符串的文档中适当添加该字符串等。
for doc in documents: if target_string not in doc: doc += " " + target_string print("处理后:") count = 0 for doc in documents: if target_string in doc: count += 1 print(f"{target_string} 在 {count} 篇文档中出现。")
Hello, thanks for reviewing my pull request. However, I am not sure sure to understand the link between the loop you are showing me and the doctest I am adding. Also, I do not speak Chinese so I need replies in English to understand.
Please separate for several PRs - one file per one PR