Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wordcloud): add wordcloud_chineseize #15

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

shenxiangzhuang
Copy link
Owner

@shenxiangzhuang shenxiangzhuang commented Dec 17, 2024

Close #10

Summary by CodeRabbit

  • New Features

    • Introduced a function to configure word clouds with Chinese fonts, enhancing visual representation.
    • Added a new test to verify the correct configuration of Chinese fonts in word clouds.
    • Expanded the public API of the package to include functionality for word cloud visualization.
    • Updated the README to include support for zhplot and list supported frameworks.
  • Chores

    • Updated the changelog to reflect new features and modifications, including support for Chinese display in word clouds.

@shenxiangzhuang shenxiangzhuang added the enhancement New feature or request label Dec 17, 2024
@shenxiangzhuang shenxiangzhuang self-assigned this Dec 17, 2024
Copy link

coderabbitai bot commented Dec 17, 2024

Walkthrough

The pull request introduces support for Chinese font configuration in the word cloud functionality of the zhplot library. A new function wordcloud_chineseize() is added to set the environment variable FONT_PATH with the path to the NotoSansSC-Regular.ttf font. This change enables proper rendering of Chinese characters in word cloud visualizations by specifying the appropriate font file. Additionally, a test function is included to verify the configuration.

Changes

File Change Summary
zhplot/wordcloud.py Added wordcloud_chineseize() function to set Chinese font path
zhplot/__init__.py Imported wordcloud_chineseize and added to __all__
tests/test_wordcloud.py Added test_chinese_font_config() to verify Chinese font configuration
CHANGELOG.md Updated with support for Chinese display in wordcloud and font changes
README.md Added import statement for zhplot and new section for supported frameworks

Assessment against linked issues

Objective Addressed Explanation
Support Chinese wordcloud display [#10]

Poem

🐰 Hop, hop, through code's misty lane,
Chinese characters now dance with glee,
Font path set, no more typographic pain,
Wordcloud blooms, a linguistic spree!
Rabbit's magic makes text display free! 🌈


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/test_wordcloud.py (1)

3-3: Specify the reason for noqa comment.

Please specify which error is being suppressed with the noqa comment. For example: # noqa: F401 for unused import.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 22bbc7f and f464f2c.

📒 Files selected for processing (3)
  • tests/test_wordcloud.py (1 hunks)
  • zhplot/__init__.py (1 hunks)
  • zhplot/wordcloud.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • zhplot/wordcloud.py
🔇 Additional comments (1)
zhplot/__init__.py (1)

2-6: LGTM! Clean and consistent implementation.

The import statement and __all__ list update follow the existing pattern and properly expose the new wordcloud_chineseize function.

tests/test_wordcloud.py Show resolved Hide resolved
tests/test_wordcloud.py Show resolved Hide resolved
Copy link

codecov bot commented Dec 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (22bbc7f) to head (4b97200).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #15   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         3    +1     
  Lines           21        28    +7     
=========================================
+ Hits            21        28    +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shenxiangzhuang shenxiangzhuang merged commit 4c7f8ab into master Dec 17, 2024
16 of 17 checks passed
@shenxiangzhuang shenxiangzhuang deleted the feat/add_wordcloud_chineseize branch December 17, 2024 08:43
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
README.md (1)

42-44: Consider adding a wordcloud usage example.

Since this PR introduces Chinese word cloud support, it would be helpful to add a usage example demonstrating the wordcloud_chineseize functionality, similar to the matplotlib example below it.

Example addition:

### 支持的框架
- [x] [matplotlib](https://github.com/matplotlib/matplotlib)
- [x] [wordcloud](https://github.com/amueller/word_cloud)

+ ### Word Cloud示例
+ ```python
+ import zhplot
+ from wordcloud import WordCloud
+ 
+ # Chinese text example
+ text = "中文 文字 云 示例"
+ wordcloud = WordCloud().generate(text)
+ 
+ # Display the word cloud
+ plt.figure(figsize=(10, 5))
+ plt.imshow(wordcloud, interpolation='bilinear')
+ plt.axis('off')
+ plt.show()
+ ```
CHANGELOG.md (2)

7-7: Fix grammar in changelog entry.

The changelog entry is missing a preposition.

- Support chinese display in `wordcloud`
+ Support for Chinese display in `wordcloud`
🧰 Tools
🪛 LanguageTool

[uncategorized] ~7-~7: Possible missing preposition found.
Context: ... ## [Unreleased] ### Added - Support chinese display in wordcloud ## [0.1.1] - 2...

(AI_HYDRA_LEO_MISSING_TO)


6-8: Consider adding more details to the changelog entry.

The changelog entry could be more specific about what functionality was added.

### Added
- Support chinese display in `wordcloud`
+ ### Added
+ - Added `wordcloud_chineseize()` function to support Chinese text display in word clouds using Noto Sans SC font
🧰 Tools
🪛 LanguageTool

[uncategorized] ~7-~7: Possible missing preposition found.
Context: ... ## [Unreleased] ### Added - Support chinese display in wordcloud ## [0.1.1] - 2...

(AI_HYDRA_LEO_MISSING_TO)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f464f2c and 4b97200.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • README.md (2 hunks)
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md

[uncategorized] ~7-~7: Possible missing preposition found.
Context: ... ## [Unreleased] ### Added - Support chinese display in wordcloud ## [0.1.1] - 2...

(AI_HYDRA_LEO_MISSING_TO)

🔇 Additional comments (1)
README.md (1)

42-44: LGTM! Clear documentation of supported frameworks.

The new section clearly lists the supported frameworks with proper links to their repositories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

支持wordcloud显示中文
1 participant