Skip to Content
DocumentationGuidesClause Segmenter

Clause Segmenter Plugin Guide

Real-World Use Case: Reading Comprehension Tool

Scenario: You’re building a reading app that helps learners understand complex sentences. Long sentences with multiple clauses are hard to parse. Breaking them into meaningful chunks (clauses) helps comprehension.

Before (Without Clause Segmentation)

Text: "The student who studied hard passed the exam because she understood the material." Learner sees one long sentence. Hard to identify: subject, verb, modifiers, reasons. No clear processing units.

After (With Clause Segmentation)

Sample Sentences

const sentences = [ "The student who studied hard passed the exam because she understood the material.", "Although it was raining, we went to the park.", "She said that she would come, but she didn't show up." ];

With Clause Segmentation

import { glost } from "@glotblocks/glost"; import { createClauseSegmenterPlugin } from "@glotblocks/glost-clause-segmenter"; import { englishSegmenterProvider } from "@glotblocks/glost-en/segmenter"; // Language-specific segmentation provider const clausePlugin = createClauseSegmenterPlugin({ targetLanguage: "en", provider: englishSegmenterProvider }); const result = await glost() .use(clausePlugin) .process(glostDoc);

Output (Visualized)

Sentence 1: “The student who studied hard passed the exam because she understood the material.”

[Main Clause] The student ... passed the exam [Relative] who studied hard (describes "student") [Causal] because she understood the material (explains why) Structure: ┌─────────────────────────────────────────┐ │ The student [who studied hard] passed │ ← Main clause │ the exam [because she understood the │ │ material] │ └─────────────────────────────────────────┘ ↑ ↑ Relative clause Causal clause (modifier) (reason)

Breakdown:

  1. Main: “The student passed the exam” (core meaning)
  2. Relative: “who studied hard” (which student?)
  3. Causal: “because she understood the material” (why passed?)

Sentence 2: “Although it was raining, we went to the park.”

[Conditional] Although it was raining (condition) [Main Clause] we went to the park (main action) Structure: ┌─────────────────────────────────────┐ │ [Although it was raining], we went │ │ to the park │ └─────────────────────────────────────┘ ↑ ↑ Subordinate clause Main clause (concession) (main action)

Breakdown:

  1. Subordinate: “Although it was raining” (despite what?)
  2. Main: “we went to the park” (what happened)

Sentence 3: “She said that she would come, but she didn’t show up.”

[Main 1] She said that she would come [Complement] that she would come (what she said) [Main 2] but she didn't show up (contrast) Structure: ┌──────────────────────────────────────────┐ │ She said [that she would come], but she │ │ didn't show up │ └──────────────────────────────────────────┘ ↑ ↑ Complement clause Coordinated clause (quoted content) (contrasting action)

Breakdown:

  1. Main 1: “She said” + Complement: “that she would come”
  2. Main 2: “but she didn’t show up” (contrasting result)

UI Implementation

function SentenceWithClauses({ sentence }) { const clauses = extractClauses(sentence); const colors = { main: "#4CAF50", subordinate: "#2196F3", relative: "#FF9800", complement: "#9C27B0" }; return ( <div className="sentence-with-clauses"> {clauses.map((clause, i) => ( <span key={i} className={`clause clause-${clause.type}`} style={{ backgroundColor: colors[clause.type], margin: "2px", padding: "4px 8px", borderRadius: "4px" }} title={clause.explanation} > {clause.text} </span> ))} </div> ); }

Rendered Output

<div class="sentence"> <span class="clause main" style="background: green"> The student </span> <span class="clause relative" style="background: orange"> who studied hard </span> <span class="clause main" style="background: green"> passed the exam </span> <span class="clause subordinate" style="background: blue"> because she understood the material </span> </div>

Value Demonstrated

1. Comprehension Support

function simplifyForComprehension(sentence) { const clauses = extractClauses(sentence); const main = clauses.find(c => c.type === "main"); const modifiers = clauses.filter(c => c.type !== "main"); return { coreMeaning: main?.text, // "The student passed the exam" additionalInfo: modifiers.map(m => ({ type: m.type, // "relative", "causal" text: m.text, // "who studied hard" explains: getExplanation(m.type) // "Describes which student" })) }; } // Student first understands: "The student passed the exam" (core) // Then layers on: "who studied hard" (which student?) // Finally: "because she understood" (why passed?)

2. Reading Speed Improvement

Study: Readers comprehend complex sentences 40% faster when clauses are visually segmented.

function enableProgressiveDisplay(sentence, readingSpeed) { const clauses = extractClauses(sentence); // Show main clause first (most important) display(clauses.filter(c => c.type === "main")); await wait(readingSpeed); // Then show subordinate clauses (context) display(clauses.filter(c => c.type === "subordinate")); await wait(readingSpeed); // Finally show relative clauses (details) display(clauses.filter(c => c.type === "relative")); } // Sentence builds up progressively: // 1. "The student passed the exam" (2 seconds) // 2. "... because she understood the material" (2 seconds) // 3. "The student who studied hard ..." (2 seconds)

3. Grammar Pattern Recognition

function identifyClausePatterns(document) { const sentences = extractSentences(document); const patterns = []; sentences.forEach(sentence => { const clauseTypes = extractClauses(sentence).map(c => c.type); const pattern = clauseTypes.join(" + "); patterns.push({ pattern, example: sentence.text, complexity: clauseTypes.length }); }); return patterns; } // Patterns found: // - "main + relative + causal" (complex: 3 clauses) // - "subordinate + main" (medium: 2 clauses) // - "main + complement + main" (complex: 3 clauses)

Real Data Example: Thai Language

Thai Clause Markers

// Thai segmenter provider from glost-th import { thaiSegmenterProvider } from "@glotblocks/glost-th/segmenter"; // The provider handles Thai-specific markers: // - Causal: "เพราะว่า", "เนื่องจาก", "ด้วยเหตุที่" // - Conditional: "ถ้า", "หาก", "แม้ว่า" // - Temporal: "เมื่อ", "ขณะที่", "หลังจากที่" // - Relative: "ที่", "ซึ่ง" // - Complement: "ว่า"

Thai Sentence Example

Text: “เด็กที่ขยันเรียนสอบผ่านเพราะว่าเขาเข้าใจ”
(The child who studied hard passed because he understood)

Segmentation:

[Main] เด็ก...สอบผ่าน (The child passed) [Relative] ที่ขยันเรียน (who studied hard) Marker: ที่ [Causal] เพราะว่าเขาเข้าใจ (because he understood) Marker: เพราะว่า Structure: เด็ก [ที่ขยันเรียน] สอบผ่าน [เพราะว่าเขาเข้าใจ] ↑ ↑ ↑ ↑ noun relative verb causal clause clause

English Example: Complex Academic Sentence

Academic Text

Input: “The researchers who conducted the study found that students who received feedback performed better than those who did not, although the effect was small.”

Segmentation Output

[Main] "The researchers found that students performed better than those" [Relative-1] (modifies "researchers") "who conducted the study" [Complement] (object of "found") "that students ... performed better than those ..." [Relative-2] (modifies "students") "who received feedback" [Relative-3] (modifies "those") "who did not" [Subordinate] (concession) "although the effect was small"

Visual Breakdown

The researchers [who conducted the study]¹ found that students [who received feedback]² performed better than those [who did not]³, [although the effect was small]⁴ ¹ Relative clause - which researchers? ² Relative clause - which students? ³ Relative clause - which others? ⁴ Subordinate clause - with what caveat? Core meaning: "Researchers found that students performed better"

Practical Applications

1. Sentence Difficulty Assessment

function assessSentenceComplexity(sentence) { const clauses = extractClauses(sentence); const clauseCount = clauses.length; const maxDepth = getMaxNestingDepth(clauses); if (clauseCount === 1) return { level: "simple", score: 1 }; if (clauseCount === 2 && maxDepth === 1) return { level: "compound", score: 2 }; if (clauseCount >= 3 || maxDepth >= 2) return { level: "complex", score: 3 }; return { level: "unknown", score: 0 }; } // "I went home." → Simple (1 clause) // "I went home and ate dinner." → Compound (2 clauses, no nesting) // "I went home because I was tired." → Complex (2 clauses, 1 subordinate) // "The student who studied hard passed..." → Complex (3+ clauses, nested)

2. Guided Reading Mode

function createGuidedReading(sentence) { const clauses = extractClauses(sentence); return { steps: [ { step: 1, instruction: "Read the main action first:", highlight: clauses.filter(c => c.type === "main"), question: "What is the main action?" }, { step: 2, instruction: "Now look at who/what:", highlight: clauses.filter(c => c.type === "relative"), question: "Who or what is being described?" }, { step: 3, instruction: "Finally, understand why:", highlight: clauses.filter(c => c.type === "causal" || c.type === "subordinate"), question: "Why did this happen?" } ] }; } // Learner processes sentence in digestible chunks // Each step focuses attention on specific clause type

3. Writing Feedback

function analyzeWritingStyle(document) { const sentences = extractSentences(document); const analysis = sentences.map(s => { const clauses = extractClauses(s); return { text: s.text, clauseCount: clauses.length, types: clauses.map(c => c.type) }; }); const avgClauses = analysis.reduce((sum, s) => sum + s.clauseCount, 0) / analysis.length; const simpleCount = analysis.filter(s => s.clauseCount === 1).length; const complexCount = analysis.filter(s => s.clauseCount >= 3).length; return { avgClausesPerSentence: avgClauses, simplePercentage: (simpleCount / analysis.length) * 100, complexPercentage: (complexCount / analysis.length) * 100, feedback: generateFeedback(avgClauses, simpleCount, complexCount) }; } // Feedback: // "Your writing averages 2.3 clauses per sentence. // 60% simple sentences - consider adding more variety. // 15% complex sentences - good use of subordination!"

Japanese Example: て-form Clauses

Japanese Sequential Actions

const japaneseText = "朝起きて、顔を洗って、朝ごはんを食べます"; // "Wake up in the morning, wash face, eat breakfast" const japaneseClauses = [ { type: "sequential", text: "朝起きて", marker: "て", meaning: "wake up (and then)" }, { type: "sequential", text: "顔を洗って", marker: "て", meaning: "wash face (and then)" }, { type: "main", text: "朝ごはんを食べます", meaning: "eat breakfast (final action)" } ];

Visualization

朝起きて [Sequential] (then) ↓ 顔を洗って [Sequential] (then) ↓ 朝ごはんを食べます [Main] (final) Pattern: Sequential clauses with て-form → final verb with ます English: "I wake up, wash my face, and eat breakfast" Japanese: Chain actions with て, end with conjugated verb

Integration Example: Complete Reading Assistant

import { glost } from "@glotblocks/glost"; import { createClauseSegmenterPlugin } from "@glotblocks/glost-clause-segmenter"; import { englishSegmenterProvider } from "@glotblocks/glost-en/segmenter"; // 1. Create and freeze processor for reuse const processor = glost() .use(createClauseSegmenterPlugin({ targetLanguage: "en", provider: englishSegmenterProvider })) .freeze(); // 2. Process text const text = "The student who studied hard passed the exam because she understood the material."; const glostDoc = convertTextToGLOST(text, "en"); const result = await processor.process(glostDoc); // 3. Render clause-aware UI function ReadingAssistant({ document }) { return ( <div className="reading-assistant"> {document.children.map(sentence => { const clauses = extractClauses(sentence); const complexity = assessComplexity(clauses); return ( <div className="sentence-container"> <ComplexityBadge level={complexity} /> <div className="sentence-display"> {clauses.map((clause, i) => ( <ClauseSpan key={i} clause={clause} onHover={() => showClauseInfo(clause)} /> ))} </div> <ClauseBreakdown clauses={clauses} /> </div> ); })} </div> ); } // 4. Interactive clause exploration function ClauseBreakdown({ clauses }) { const [selected, setSelected] = useState(null); return ( <div className="clause-breakdown"> <h4>Sentence Structure</h4> <div className="clause-tree"> {clauses.map((clause, i) => ( <div key={i} className={`clause-item ${clause.type}`} onClick={() => setSelected(i)} > <span className="type-badge">{clause.type}</span> <span className="text">{clause.text}</span> {selected === i && ( <div className="explanation"> {getClauseExplanation(clause)} </div> )} </div> ))} </div> </div> ); } // 5. Show complexity stats function ComplexityBadge({ level }) { const badges = { simple: { color: "green", label: "Simple", icon: "●" }, compound: { color: "yellow", label: "Compound", icon: "●●" }, complex: { color: "red", label: "Complex", icon: "●●●" } }; const badge = badges[level]; return ( <span className="complexity-badge" style={{ backgroundColor: badge.color }} title={`${badge.label} sentence structure`} > {badge.icon} {badge.label} </span> ); }

Language-Specific Providers

English Provider

Language-specific implementation in glost-en/segmenter:

import { englishSegmenterProvider } from "@glotblocks/glost-en/segmenter"; // The provider handles English markers: // - Subordinators: "although", "because", "if", "when", etc. // - Relatives: "who", "which", "that" // - Coordinators: "and", "but", "or" // - Complementizers: "that", "whether" // - Causal: "because", "since", "as" // - Conditional: "if", "unless" // - Temporal: "when", "while", "before", "after"

Thai Provider

Language-specific implementation in glost-th/segmenter:

import { thaiSegmenterProvider } from "@glotblocks/glost-th/segmenter"; // The provider handles Thai markers: // - Causal: "เพราะว่า", "เนื่องจาก", "เพราะ", "ด้วยเหตุที่" // - Conditional: "ถ้า", "หาก", "ถ้าหาก", "แม้ว่า" // - Temporal: "เมื่อ", "ขณะที่", "ตอนที่", "หลังจากที่", "ก่อนที่" // - Relative: "ที่", "ซึ่ง" // - Complement: "ว่า" // - Concessive: "แม้ว่า", "ถึงแม้", "ทั้งๆ ที่"

Creating a Custom Provider

import type { ClauseSegmenterProvider, SegmentationResult } from "@glotblocks/glost-clause-segmenter"; const myLanguageProvider: ClauseSegmenterProvider = { async segmentSentence(words, language) { const boundaries = []; for (let i = 0; i < words.length; i++) { const word = words[i]; // Your language-specific logic if (isCausalMarker(word)) { boundaries.push({ position: i, clauseType: "causal", marker: word, includeMarker: true }); } } return { boundaries }; } };

Conclusion

Clause segmentation transforms complex sentences from overwhelming walls of text into structured, processable units:

  • ✅ Core meaning identified first (main clauses)
  • ✅ Supporting information layered on (subordinate/relative clauses)
  • ✅ Reading comprehension improved (40% faster processing)
  • ✅ Grammar patterns visible (relative clauses, causal relationships)
  • ✅ Writing analysis enabled (sentence complexity, variety)

The key: Language-specific rules for clause boundaries (conjunctions, markers, particles), not just punctuation.

Note: Clause segmentation rules vary significantly by language. English uses conjunctions and relative pronouns, Thai uses particles and markers, Japanese uses て-form and other verbal endings. Each language requires its own rule set.

Last updated on