Discourse Coherence: Modeling Text Structure
Module: Natural Language Processing | Difficulty: Advanced
Entity-Based Coherence
Centering Theory
Evaluation
| Metric | Random | Coherent |
|---|---|---|
| Entity Grid | 0.32 | 0.78 |
| Neural | 0.28 | 0.85 |
import numpy as np
def entity_coherence(text, entities):
scores = []
for i in range(len(text) - 1):
overlap = len(set(entities[i]) & set(entities[i+1]))
total = max(len(set(entities[i]) | set(entities[i+1])), 1)
scores.append(overlap / total)
return np.mean(scores)
Research Insight: Discourse coherence is important for text quality assessment and generation. Neural models that track entity mentions across sentences achieve state-of-the-art coherence evaluation. The key insight is that coherent texts maintain entity continuity.