Skip to content

Fix: locale-aware (words/characters) minimum content length across AI content experiments - #581

Merged
dkotter merged 32 commits into
WordPress:developfrom
hbhalodia:fix/issue-578
Jun 17, 2026
Merged

dkotter merged 32 commits into
WordPress:developfrom
hbhalodia:fix/issue-578

Conversation

@hbhalodia

@hbhalodia hbhalodia commented May 19, 2026

Copy link
Copy Markdown
Contributor

What?

Closes #578, #391, #390

Why?

  • PR uses wordCountType for counting words or characters based on the users locale, standardize across all the experiments.

How?

Use of AI Tools

  • Yes, Claude Code, Opus 4.8,4.7.
  • Used for implementation phase with standardize across the experiments.

Testing Instructions

  1. Change the site language to Japanese.
  2. Open a post.
  3. Copy the following text and paste it multiple times inside a paragraph block: あああああああああああ
  4. Execute the Shorten action
  5. Confirm that no error notice is displayed and word shorten is working as expected.

Screenshots or screencast

Screen.Recording.2026-05-19.at.3.52.39.PM.mov

Changelog Entry

Fixed - Add wordCountType to check for user's locale and update to count character or words and standardize the min content length accross the experiments.

Open WordPress Playground Preview

@github-actions

github-actions Bot commented May 19, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Comment thread src/experiments/content-resizing/components/ContentResizingToolbar.tsx Outdated
@codecov

codecov Bot commented May 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.15%. Comparing base (246680c) to head (3e0143c).

Files with missing lines Patch % Lines
.../Content_Classification/Content_Classification.php 0.00% 4 Missing ⚠️
.../Experiments/Content_Resizing/Content_Resizing.php 0.00% 2 Missing ⚠️
...cludes/Experiments/Summarization/Summarization.php 0.00% 1 Missing ⚠️
includes/helpers.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #581      +/-   ##
=============================================
- Coverage      73.18%   73.15%   -0.03%     
  Complexity      1731     1731              
=============================================
  Files             85       85              
  Lines           7473     7476       +3     
=============================================
  Hits            5469     5469              
- Misses          2004     2007       +3     
Flag Coverage Δ
unit 73.15% <0.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dkotter dkotter linked an issue May 21, 2026 that may be closed by this pull request
6 tasks
@dkotter dkotter modified the milestones: 1.0.1, 1.1.0 May 26, 2026

@dkotter dkotter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Left a few comments but overall this is looking good.

The only other thing I'd flag is this standardizes things for Content Classification, Content Resizing and Summarization but none of the other Features. I still think it would be ideal to standardize everything, which likely means closing out #479 and #545 and handling those in this PR, as well as looking at all other Features and ensure, where needed, they follow the same approach

Comment thread includes/Experiments/Summarization/Summarization.php Outdated
* @param int $min_content_length The minimum number of characters required. Default 100.
*/
$min_content_length = (int) apply_filters( 'wpai_summarization_min_content_length', 100 );
$min_content_length = (int) apply_filters( 'wpai_summarization_min_content_length', get_min_content_length( 'summarization', 100 ) );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So I know 100 was the last value but that was when we looked at characters only. Now we'll look at words if the locale supports it so is 100 words the right length? Seems that may be too long

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not sure on this what number would be the best here. If we go with less then what if locale supports characters, then it would be less either. So may be we can change to 50?

'enabled' => $this->is_enabled(),
'strategy' => $this->get_strategy(),
'maxSuggestions' => $this->get_max_suggestions(),
'minContentLength' => get_min_content_length( 'content-classification', 150 ),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is 150 the right length here or should we lower that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I guess it's good thing to have more. Because if we have words as locale, higher the words AI may provide the better suggestions. For characters as well, it would provide better suggestions.

Here in the comment as well - #581 (comment), I guess we can stick with 100, that's because for words locale higher the words it would provide better summarization? yes?

Comment thread src/experiments/content-resizing/components/ContentResizingToolbar.tsx Outdated
Comment thread src/experiments/content-resizing/components/ContentResizingToolbar.tsx Outdated
Comment thread includes/Experiments/Summarization/Summarization.php
@hbhalodia

Copy link
Copy Markdown
Contributor Author

Left a few comments but overall this is looking good.

The only other thing I'd flag is this standardizes things for Content Classification, Content Resizing and Summarization but none of the other Features. I still think it would be ideal to standardize everything, which likely means closing out #479 and #545 and handling those in this PR, as well as looking at all other Features and ensure, where needed, they follow the same approach

Thanks @dkotter, I am checking those and will update in the PR as needed.