Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"input": "grade_level",
"output": "rubric",
"source_path": "rubric-grade-3.txt",
"sha256": "3ddacd7b3c80f1f8e85bfcddd01db945813fcf814d893e719f5ae48babdaf11f",
"sha256": "a62c8f64c951b909bb8f3e2b69bec1c794c797dd1cad14d0b8db7939200e8966",
"condition": { "input": "grade_level", "in": ["3"] },
"implementation": {
"python": {
Expand All @@ -59,7 +59,7 @@
"input": "grade_level",
"output": "rubric",
"source_path": "rubric-grade-4.txt",
"sha256": "851c6afa4cd8a0ff0f599a38e96c96516dc2cccf0a4a7e945c982efebc89b6b7",
"sha256": "082c29146c24c654a51658cb97ca49355b90e8961470ffdabcd32d440a1ac733",
"condition": { "input": "grade_level", "in": ["4"] },
"implementation": {
"python": {
Expand All @@ -80,7 +80,7 @@
"input": "grade_level",
"output": "rubric",
"source_path": "rubric-grades-5-12.txt",
"sha256": "ae8ac191a5c8c0168e3866d0682c01f987a1b583272a0f6674e3881a84dccfab",
"sha256": "458bae4c6996aee6eb9f27a82f37d51289b508cec671ba4fdcbf7c88731fb3a2",
"condition": { "input": "grade_level", "in": ["5", "6", "7", "8", "9", "10", "11", "12"] },
"implementation": {
"python": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,17 @@
"]\n",
"\n",
"\n",
"def features_to_json(features: dict, decimals: int = 1, cast_to_int: bool = True) -> str:\n",
"def features_to_json(features: dict, decimals: int = 1, cast_to_int: bool = True, floor_values: bool = False) -> str:\n",
" import math\n",
" payload = {}\n",
" for key in FEATURE_COLS:\n",
" value = features.get(key)\n",
" if value is None:\n",
" payload[key] = None\n",
" continue\n",
" if floor_values:\n",
" payload[key] = math.floor(value)\n",
" continue\n",
" value = round(value, decimals)\n",
" payload[key] = int(value) if cast_to_int else value\n",
" return json.dumps(payload, indent=2)"
Expand Down Expand Up @@ -367,7 +371,7 @@
" try:\n",
" analysis = run_sentence_analysis(text)\n",
" features = add_engineered_features(analysis[\"formatted_output\"])\n",
" features_json = features_to_json(features)\n",
" features_json = features_to_json(features, floor_values=True)\n",
" classification = run_classify_complexity(features_json, grade_level, text)\n",
" return {\n",
" \"analysis\": analysis,\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
**Slightly Complex:**
* **Description:** The text consists of simple, straightforward language and sentence structures.
* **Statistical Guidelines:** The text is likely "Slightly Complex" if it meets at least TWO of the following criteria:
* **Sentence Type:** Primarily simple sentences. (`percent_simple_sentences` is typically > 60%).
* **Sentence Length:** Short sentences. (`avg_sentence_length` is typically < 12 words).
* **Sentence Type:** Primarily simple sentences. (`percent_simple_sentences` is typically >= 60%).
* **Sentence Length:** Short sentences. (`avg_words_per_sentence` is typically < 12 words).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@slee430 - To confirm, the code was already sending avg_words_per_sentence, but the rubric was referencing avg_sentence_length. The model was inferring on this own, and silently resolving this bug?

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.

@adnanrhussain Yes, the code was already sending avg_words_per_sentence, but the grade 3 and 4 rubrics referenced avg_sentence_length. The model may have inferred the connection, but we cannot confirm that it did so consistently. This fix makes the reference explicit.

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.

Regarding your alternative approach, I’ll keep the current implementation for comparison and test your proposal in a separate branch across Python, TypeScript, and the notebook. I’ll keep the feature-name fix in both versions and make the rubric boundary changes explicit.
Then I’ll rerun the tests and compare the baseline, the current PR, and your proposal using the same extracted features. I’ll check the grade 4 results closely, since accuracy decreased there in the previous comparison. We can review the results before deciding which approach to use in this PR.

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.

Hi @adnanrhussain @slee430 -- I've looked at the code and also viewed Seung Yeon's tests. Just to confirm my understanding: Adnan's approach means that the issue Seung Yeon was originally aiming to fix (i.e. some variables such as percentages get truncated) will not be resolved, to keep things consistent with the SDK. Is that understanding correct?

On my end, I'm fine with this for now and I think it's something we should flag for fixing later on.

* **Subordination:** Very low use of clauses. (`percent_sentences_with_subordinate` is typically < 25%).

**Moderately Complex:**
* **Description:** The text shows a mix of simple and more complex sentences, introducing some variety in structure without being overly demanding.
* **Statistical Guidelines:** If the text is not "Slightly Complex", consider "Moderately Complex" if it generally aligns with these ranges:
* **Sentence Type:** A balanced mix of sentence types. (`percent_simple_sentences` is typically between 40% and 60%).
* **Sentence Length:** Medium length sentences. (`avg_sentence_length` is typically between 12 and 16 words).
* **Subordination:** A moderate use of clauses. (`percent_sentences_with_subordinate` is typically between 25% and 45%).
* **Sentence Type:** A balanced mix of sentence types. (`percent_simple_sentences` is typically >= 40% and < 60%).
* **Sentence Length:** Medium length sentences. (`avg_words_per_sentence` is typically >= 12 and < 16 words).
* **Subordination:** A moderate use of clauses. (`percent_sentences_with_subordinate` is typically >= 25% and < 45%).

**Very Complex:**
* **Description:** The text features more elaborate sentences with multiple clauses and ideas, requiring more effort from the reader to parse. This is often the default category for grade-level text that isn't simple or exceptionally difficult.
* **Statistical Guidelines:** If the text is more complex than "Moderately" but does not meet the "Exceedingly" criteria, it is likely "Very Complex". Key indicators include:
* **Sentence Type:** Complex structures are common. (`percent_simple_sentences` is a minority, typically < 40%).
* **Sentence Length:** Longer sentences are frequent. (`avg_sentence_length` is typically between 16 and 19 words).
* **Subordination:** Subordinate clauses are a key feature. (`percent_sentences_with_subordinate` is typically > 45%).
* **Sentence Length:** Longer sentences are frequent. (`avg_words_per_sentence` is typically >= 16 and < 19 words).
* **Subordination:** Subordinate clauses are a key feature. (`percent_sentences_with_subordinate` is typically >= 45%).

**Exceedingly Complex:**
* **Description:** The text is dense with very long, intricate sentences and a high degree of subordination, making it exceptionally challenging for this grade level.
* **Statistical Guidelines:** The text is "Exceedingly Complex" if it shows an extreme combination of sentence length and structural density. It should meet at least **TWO** of the following criteria, including at least **ONE** from the "Structural Density" group.
* **Structural Density Indicators:**
* High Subordination: `percent_sentences_with_subordinate` is extensive (typically > 50%).
* Multiple Subordinates: `percent_sentences_with_multiple_subordinates` is consistently present (typically > 12%).
* High Syntactic Complexity: `percent_compound_complex_sentences` is significant (typically > 15%).
* High Subordination: `percent_sentences_with_subordinate` is extensive (typically >= 50%).
* Multiple Subordinates: `percent_sentences_with_multiple_subordinates` is consistently present (typically >= 12%).
* High Syntactic Complexity: `percent_compound_complex_sentences` is significant (typically >= 15%).
* **Length Indicators:**
* Extreme Sentence Length: `avg_sentence_length` is very long (typically > 19 words).
* Extreme Sentence Length: `avg_words_per_sentence` is very long (typically >= 19 words).
* Low Simplicity: `percent_simple_sentences` is very low (typically < 30%).
* Concentrated Length: `percent_very_long_sentences` is notable (typically > 10%).
* Concentrated Length: `percent_very_long_sentences` is notable (typically >= 10%).
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@
**Slightly Complex:**
* **Description:** The text uses clear, direct language with basic sentence structures appropriate for developing readers.
* **Statistical Guidelines:** The text is likely "Slightly Complex" if it meets at least TWO of the following criteria:
* **Sentence Type:** Dominated by simple sentences. (`percent_simple_sentences` is typically > 55%).
* **Sentence Length:** Short to medium sentences. (`avg_sentence_length` is typically < 13 words).
* **Sentence Type:** Dominated by simple sentences. (`percent_simple_sentences` is typically >= 55%).
* **Sentence Length:** Short to medium sentences. (`avg_words_per_sentence` is typically < 13 words).
* **Subordination:** Infrequent use of clauses. (`percent_sentences_with_subordinate` is typically < 30%).

**Moderately Complex:**
* **Description:** The text contains a variety of sentence structures, including compound and complex sentences, but remains accessible.
* **Statistical Guidelines:** If the text is not "Slightly Complex", consider "Moderately Complex" if it generally aligns with these ranges:
* **Sentence Type:** A healthy mix of sentence types. (`percent_simple_sentences` is typically between 40% and 55%).
* **Sentence Length:** Medium length sentences. (`avg_sentence_length` is typically between 13 and 17 words).
* **Subordination:** A moderate number of clauses. (`percent_sentences_with_subordinate` is typically between 30% and 50%).
* **Sentence Type:** A healthy mix of sentence types. (`percent_simple_sentences` is typically >= 40% and < 55%).
* **Sentence Length:** Medium length sentences. (`avg_words_per_sentence` is typically >= 13 and < 17 words).
* **Subordination:** A moderate number of clauses. (`percent_sentences_with_subordinate` is typically >= 30% and < 50%).

**Very Complex:**
* **Description:** The text is characterized by longer sentences and the regular use of dependent clauses, requiring readers to track multiple ideas. This is the default for challenging, on-grade-level texts.
* **Statistical Guidelines:** If the text is more complex than "Moderately" but does not meet the "Exceedingly" criteria, it is likely "Very Complex". Key indicators include:
* **Sentence Type:** Simple sentences are a clear minority. (`percent_simple_sentences` is typically < 40%).
* **Sentence Length:** Sentences are consistently long. (`avg_sentence_length` is typically between 17 and 22 words).
* **Subordination:** Subordination is a major feature. (`percent_sentences_with_subordinate` is typically > 50%).
* **Multiple Subordination:** Sentences with multiple clauses appear more often. (`percent_sentences_with_multiple_subordinates` is typically > 8%).
* **Sentence Length:** Sentences are consistently long. (`avg_words_per_sentence` is typically >= 17 and < 22 words).
* **Subordination:** Subordination is a major feature. (`percent_sentences_with_subordinate` is typically >= 50%).
* **Multiple Subordination:** Sentences with multiple clauses appear more often. (`percent_sentences_with_multiple_subordinates` is typically >= 8%).

**Exceedingly Complex:**
* **Description:** The text's structure is highly sophisticated and dense, marked by extensive use of embedded clauses and long, flowing sentences that are well above grade-level expectations.
* **Statistical Guidelines:** A text is "Exceedingly Complex" if its structure is highly sophisticated and dense. It should meet at least **TWO** of the following criteria, including at least **ONE** from the "Structural Density" group.
* **Structural Density Indicators:**
* High Subordination: `percent_sentences_with_subordinate` is very high (typically > 60%).
* Multiple Subordinates: `percent_sentences_with_multiple_subordinates` is high and consistent (typically > 15%).
* High Syntactic Complexity: `percent_compound_complex_sentences` is a notable feature (typically > 20%).
* High Subordination: `percent_sentences_with_subordinate` is very high (typically >= 60%).
* Multiple Subordinates: `percent_sentences_with_multiple_subordinates` is high and consistent (typically >= 15%).
* High Syntactic Complexity: `percent_compound_complex_sentences` is a notable feature (typically >= 20%).
* **Length Indicators:**
* Extreme Sentence Length: `avg_sentence_length` is exceptionally long (typically > 22 words).
* Extreme Sentence Length: `avg_words_per_sentence` is exceptionally long (typically >= 22 words).
* Low Simplicity: `percent_simple_sentences` is very low (typically < 25%).
* Concentrated Length: `percent_very_long_sentences` is significant (typically > 15%).
* Concentrated Length: `percent_very_long_sentences` is significant (typically >= 15%).
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

**Slightly Complex:** A text is in the Slightly Complex bucket if it has at least 50% simple sentences. If it doesn't, the text is a higher level of complexity. If the % of simple sentences is >= 50% and the % of compound sentences is >= 20%, the text is Moderately Complex, otherwise, the text is Slightly Complex. Slightly Complex texts NEVER have advanced complex sentences — the presence of an advanced complex sentence always leads to a higher level of complexity than Slightly.
**For Moderately Complex:** These texts can take on any distribution of sentence types as long as there aren't more than 2 advanced complex sentences and as long as there aren't so many simple sentences that the text becomes Slightly Complex. That means Moderately Complex texts may have many simple sentences (although not so many that the text is Slightly Complex), compound sentences, and/or basic complex sentences. It's also possible for a moderately complex text to contain one or two advanced complex sentences, as long as there aren't more than 2. If there are more than 2, then the text is either Very or Exceedingly complex.
**Very Complex:** These texts contain 3 or more advanced complex sentences (unless the percentage of advanced complex sentences is >= 65)%, in which case the text becomes Exceedingly Complex). They may still contain many simple, compound, and basic complex sentences, but a text is not Very Complex unless there are 3 or more advanced complex sentences.
**Exceedingly Complex:** These texts have 65%+ of their sentences being advanced complex sentences.
**Slightly Complex:** A text is in the Slightly Complex bucket if it has >= 50% simple sentences. If it doesn't, the text is a higher level of complexity. If the % of simple sentences is >= 50% and the % of compound sentences is >= 20%, the text is Moderately Complex, otherwise, the text is Slightly Complex. Slightly Complex texts NEVER have advanced complex sentences — the presence of an advanced complex sentence always leads to a higher level of complexity than Slightly.
**For Moderately Complex:** These texts can take on any distribution of sentence types as long as there are < 3 advanced complex sentences and as long as there aren't so many simple sentences that the text becomes Slightly Complex. That means Moderately Complex texts may have many simple sentences (although not so many that the text is Slightly Complex), compound sentences, and/or basic complex sentences. It's also possible for a moderately complex text to contain one or two advanced complex sentences, as long as there are < 3. If there are >= 3, then the text is either Very or Exceedingly complex.
Comment thread
aychi1 marked this conversation as resolved.
Resolved
**Very Complex:** These texts contain >= 3 advanced complex sentences (unless the percentage of advanced complex sentences is >= 65)%, in which case the text becomes Exceedingly Complex). They may still contain many simple, compound, and basic complex sentences, but a text is not Very Complex unless there are >= 3 advanced complex sentences.
**Exceedingly Complex:** These texts have >= 65% of their sentences being advanced complex sentences.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading