# notesjor/cooccurrencefieldsampler architecture

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

- Interactive diagram: https://gitdiagram.com/notesjor/cooccurrencefieldsampler
- Repository: https://github.com/notesjor/cooccurrencefieldsampler

## Overview

##### Project type and purpose
- This is a command-line tool (CLI) written in C# (.NET 10.0) named “CooccurrenceFieldSampler.” Its purpose is to read corpora in various formats, compute co-occurrence statistics on a specified layer, and write results in the chosen export format. There is no GUI or web frontend—this is a standalone console application designed for batch processing of text corpora.

##### File structure
- Top-level:
- .gitignore, LICENSE, README.md
- CooccurrenceFieldSampler/
– CooccurrenceFieldSampler.csproj
– Program.cs
– publish/ (contains the packaged binaries and a published README)
- There is a single project; no submodules or multiple services.
- Build/deployment artifacts under publish/ indicate a simple “dotnet publish” workflow.

##### README for additional insights
- Supported import/export formats (>30 formats)
- Various parameters control input folder, output file, filtering thresholds, number of rounds
- Runtime requirement: .NET 10.0 (for non-x64 architectures use “dotnet cfs.dll”)

##### Main components and interactions
a. Main Components
- CLI Interface / Argument Parser
- Input Format Handlers (one per supported format)
- Co‐occurrence Sampling Engine
- Significance and Frequency Filter
- Output Formatter / Writer
- Logger / Round-by-round tracker
b. Relationships & Data Flow
1. User invokes “cfs.exe” (or “dotnet cfs.dll”) with parameters
2. CLI Interface parses arguments and routes to Input Format Handler
3. Input Handler reads files from the input folder and produces a uniform internal representation (e.g., token streams)
4. Sampling Engine iterates through tokens/contexts, computes co-occurrence counts per round
5. Filter applies minFrequency, minSignificance, minChangeRate thresholds after each round
6. Logger records intermediate results; Writer serializes final co-occurrence data to the chosen export format
c. Architectural Patterns & Principles
- Modular “Strategy” pattern for format handlers (easy to add new formats)
- Single‐responsibility: each module (parsing, sampling, filtering, writing) is separate
- Pipeline pattern: data flows in stages from raw input to final output
d. Key Technologies
- .NET 10 console application
- System.CommandLine (or similar) for argument parsing
- Custom libraries or classes for each format adapter

##### Essential details to capture
- Iteration loop: Sampling Engine ↔ Filtering Module (multiple rounds)
- Where logging happens (before/after each round)
- Input and output folder paths as contextual notes

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% .NET Runtime
    RT((“.NET Runtime”)):::runtime

    %% CLI Layer
    CLI["CLI Interface / Argument Parser"]:::cli
    CSProj[".NET Project Configuration"]:::config

    %% Input Format Handlers (plugin interface)
    subgraph "Input Format Handlers"
        style InputFormatHandlers stroke-dasharray: 5 5
        CEC["CEC Handler"]:::handler
        CoNLL["CoNLL Handler"]:::handler
        JSONH["JSON Handler"]:::handler
    end

    %% Core Pipeline
    SE["Sampling Engine"]:::engine
    FM["Filtering Module"]:::filter
    OW["Output Formatter / Writer"]:::writer
    Logger["Logger / Tracker"]:::logger

    %% Data Flow
    RT -->|"hosts"| CLI
    CLI -->|“parsed args”| CEC
    CLI -->|“parsed args”| CoNLL
    CLI -->|“parsed args”| JSONH
    CEC -->|“uniform data stream”| SE
    CoNLL -->|“uniform data stream”| SE
    JSONH -->|“uniform data stream”| SE
    SE -->|“counts”| FM
    FM -->|“filtered results”| OW
    SE -->|“round results”| Logger
    FM -->|“after filter”| Logger
    FM -->|loops back| SE

    %% Contextual notes
    Note_Input["Input Folder Path"]:::note
    Note_Output["Output File Path"]:::note
    Note_Input -.-> CEC
    Note_Output -.-> OW

    %% Build/Deployment
    Publish["Build/Deployment Artifacts"]:::deployment

    CLI -->|"references"| CSProj
    CSProj -->|"publishes to"| Publish

    %% Click Events
    click CLI "https://github.com/notesjor/cooccurrencefieldsampler/blob/main/CooccurrenceFieldSampler/Program.cs"
    click CSProj "https://github.com/notesjor/cooccurrencefieldsampler/blob/main/CooccurrenceFieldSampler/CooccurrenceFieldSampler.csproj"
    click Publish "https://github.com/notesjor/cooccurrencefieldsampler/tree/main/CooccurrenceFieldSampler/publish/"

    %% Styles
    classDef runtime fill:#e0f7fa,stroke:#006064,color:#006064;
    classDef cli fill:#bbdefb,stroke:#0d47a1,color:#0d47a1;
    classDef config fill:#c8e6c9,stroke:#2e7d32,color:#2e7d32;
    classDef handler fill:#c8e6c9,stroke:#2e7d32,color:#2e7d32;
    classDef engine fill:#ffe0b2,stroke:#e65100,color:#e65100;
    classDef filter fill:#fff9c4,stroke:#f57f17,color:#f57f17;
    classDef writer fill:#eceff1,stroke:#37474f,color:#37474f;
    classDef logger fill:#f3e5f5,stroke:#6a1b9a,color:#6a1b9a;
    classDef deployment fill:#d7ccc8,stroke:#4e342e,color:#4e342e;
    classDef note fill:#ffffff,stroke:#9e9e9e,color:#616161,stroke-dasharray: 2 2;
```
