# chiayewken/span-aste architecture

> Architecture diagram of the GitHub repository chiayewken/span-aste, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chiayewken/span-aste
- Repository: https://github.com/chiayewken/span-aste

## Overview

Span-ASTE extracts aspect–opinion spans and sentiment polarity from sentences, with a scikit-style API for training, prediction, and scoring. The main path converts the API’s triplet format to model input, reads sentences into instances, applies span-based NER and relation extraction, then formats predictions back for users. The README also describes evaluation and ATE/OTE capabilities. Edges reflect README statements or visible references in the supplied excerpts and source index; training configuration and some runtime wiring were not sampled.

Main entry points: [`aste/wrapper.py`](https://github.com/chiayewken/span-aste/blob/main/aste/wrapper.py) (SpanModel API), [`span_model/models/ner.py`](https://github.com/chiayewken/span-aste/blob/main/span_model/models/ner.py) (Span NER), [`span_model/models/relation_proper.py`](https://github.com/chiayewken/span-aste/blob/main/span_model/models/relation_proper.py) (Relation Extractor), [`span_model/models/span_model.py`](https://github.com/chiayewken/span-aste/blob/main/span_model/models/span_model.py) (Span Model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["User API"]
  node_wrapper["SpanModel API<br/>[wrapper.py]"]
end

subgraph group_input["Input Processing"]
  node_triplet_data["Triplet Data<br/>[data_utils.py]"]
  node_document["Document Types<br/>[document.py]"]
  node_reader["Dataset Reader<br/>[span_model.py]"]
end

subgraph group_modeling["Span Model"]
  node_embedder["Text Embedder<br/>[embedder.py]"]
  node_shared["Span Utilities<br/>[shared.py]"]
  node_span_model["Span Model<br/>[span_model.py]"]
  node_ner["Span NER<br/>[ner.py]"]
  node_relation["Relation Extractor<br/>[relation_proper.py]"]
  node_pruner["Entity Beam Pruner"]
end

subgraph group_results["Prediction and Evaluation"]
  node_predictor["Model Predictor<br/>[span_model.py]"]
  node_analysis["Result Analysis<br/>[analysis.py]"]
  node_f1["F1 Calculation<br/>[f1.py]"]
  node_ner_metrics["NER Metrics<br/>[ner_metrics.py]"]
  node_relation_metrics["Relation Metrics"]
end

node_user(("Researcher"))

node_user -->|"uses API"| node_wrapper
node_wrapper -->|"converts data"| node_triplet_data
node_wrapper -->|"trains and predicts"| node_reader
node_reader -->|"reads documents"| node_document
node_document -->|"uses batching"| node_shared
node_span_model -->|"runs NER"| node_ner
node_span_model -->|"runs relations"| node_relation
node_ner -->|"uses span utilities"| node_shared
node_relation -->|"prunes spans"| node_pruner
node_ner -->|"reports metrics"| node_ner_metrics
node_relation -->|"reports metrics"| node_relation_metrics
node_ner_metrics -->|"computes F1"| node_f1
node_relation_metrics -->|"computes F1"| node_f1
node_wrapper -->|"invokes prediction"| node_predictor
node_predictor -->|"returns predictions"| node_wrapper
node_wrapper -->|"scores results"| node_analysis
node_wrapper -.->|"configures embeddings"| node_embedder

click node_wrapper "https://github.com/chiayewken/span-aste/blob/main/aste/wrapper.py"
click node_triplet_data "https://github.com/chiayewken/span-aste/blob/main/aste/data_utils.py"
click node_document "https://github.com/chiayewken/span-aste/blob/main/span_model/data/dataset_readers/document.py"
click node_reader "https://github.com/chiayewken/span-aste/blob/main/span_model/data/dataset_readers/span_model.py"
click node_embedder "https://github.com/chiayewken/span-aste/blob/main/span_model/models/embedder.py"
click node_shared "https://github.com/chiayewken/span-aste/blob/main/span_model/models/shared.py"
click node_span_model "https://github.com/chiayewken/span-aste/blob/main/span_model/models/span_model.py"
click node_ner "https://github.com/chiayewken/span-aste/blob/main/span_model/models/ner.py"
click node_relation "https://github.com/chiayewken/span-aste/blob/main/span_model/models/relation_proper.py"
click node_pruner "https://github.com/chiayewken/span-aste/blob/main/span_model/models/entity_beam_pruner.py"
click node_predictor "https://github.com/chiayewken/span-aste/blob/main/span_model/predictors/span_model.py"
click node_analysis "https://github.com/chiayewken/span-aste/blob/main/aste/analysis.py"
click node_f1 "https://github.com/chiayewken/span-aste/blob/main/span_model/training/f1.py"
click node_ner_metrics "https://github.com/chiayewken/span-aste/blob/main/span_model/training/ner_metrics.py"
click node_relation_metrics "https://github.com/chiayewken/span-aste/blob/main/span_model/training/relation_metrics.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_wrapper toneBlue
class node_triplet_data,node_document,node_reader toneAmber
class node_embedder,node_shared,node_span_model,node_ner,node_relation,node_pruner toneMint
class node_predictor,node_analysis,node_f1,node_ner_metrics,node_relation_metrics toneRose
class node_user toneIndigo
```

## Components

### User API

- [SpanModel API](https://github.com/chiayewken/span-aste/blob/main/aste/wrapper.py): `aste/wrapper.py`

### Input Processing

- [Triplet Data](https://github.com/chiayewken/span-aste/blob/main/aste/data_utils.py): `aste/data_utils.py`
- [Document Types](https://github.com/chiayewken/span-aste/blob/main/span_model/data/dataset_readers/document.py): `span_model/data/dataset_readers/document.py`
- [Dataset Reader](https://github.com/chiayewken/span-aste/blob/main/span_model/data/dataset_readers/span_model.py): `span_model/data/dataset_readers/span_model.py`

### Span Model

- [Text Embedder](https://github.com/chiayewken/span-aste/blob/main/span_model/models/embedder.py): `span_model/models/embedder.py`
- [Span Utilities](https://github.com/chiayewken/span-aste/blob/main/span_model/models/shared.py): `span_model/models/shared.py`
- [Span Model](https://github.com/chiayewken/span-aste/blob/main/span_model/models/span_model.py): `span_model/models/span_model.py`
- [Span NER](https://github.com/chiayewken/span-aste/blob/main/span_model/models/ner.py): `span_model/models/ner.py`
- [Relation Extractor](https://github.com/chiayewken/span-aste/blob/main/span_model/models/relation_proper.py): `span_model/models/relation_proper.py`
- [Entity Beam Pruner](https://github.com/chiayewken/span-aste/blob/main/span_model/models/entity_beam_pruner.py): `span_model/models/entity_beam_pruner.py`

### Prediction and Evaluation

- [Model Predictor](https://github.com/chiayewken/span-aste/blob/main/span_model/predictors/span_model.py): `span_model/predictors/span_model.py`
- [Result Analysis](https://github.com/chiayewken/span-aste/blob/main/aste/analysis.py): `aste/analysis.py`
- [F1 Calculation](https://github.com/chiayewken/span-aste/blob/main/span_model/training/f1.py): `span_model/training/f1.py`
- [NER Metrics](https://github.com/chiayewken/span-aste/blob/main/span_model/training/ner_metrics.py): `span_model/training/ner_metrics.py`
- [Relation Metrics](https://github.com/chiayewken/span-aste/blob/main/span_model/training/relation_metrics.py): `span_model/training/relation_metrics.py`

### Other components

- **Researcher**

## Connections

- Researcher → SpanModel API: uses API (evidence: `README.md`)
- SpanModel API → Triplet Data: converts data (evidence: `aste/wrapper.py`)
- SpanModel API → Dataset Reader: trains and predicts (evidence: `README.md`)
- Dataset Reader → Document Types: reads documents (evidence: `span_model/data/dataset_readers/span_model.py`)
- Document Types → Span Utilities: uses batching (evidence: `span_model/data/dataset_readers/document.py`)
- Span Model → Span NER: runs NER (evidence: `span_model/models/span_model.py`)
- Span Model → Relation Extractor: runs relations (evidence: `span_model/models/span_model.py`)
- Span NER → Span Utilities: uses span utilities (evidence: `span_model/models/ner.py`)
- Relation Extractor → Entity Beam Pruner: prunes spans (evidence: `span_model/models/relation_proper.py`)
- Span NER → NER Metrics: reports metrics (evidence: `span_model/models/ner.py`)
- Relation Extractor → Relation Metrics: reports metrics (evidence: `span_model/models/relation_proper.py`)
- NER Metrics → F1 Calculation: computes F1 (evidence: `span_model/training/ner_metrics.py`)
- Relation Metrics → F1 Calculation: computes F1 (evidence: `span_model/training/relation_metrics.py`)
- SpanModel API → Model Predictor: invokes prediction (evidence: `aste/wrapper.py`)
- Model Predictor → SpanModel API: returns predictions (evidence: `aste/wrapper.py`)
- SpanModel API → Result Analysis: scores results (evidence: `README.md`)
- SpanModel API → Text Embedder: configures embeddings
