# hitesh05/comment-generation architecture

> Architecture diagram of the GitHub repository hitesh05/comment-generation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hitesh05/comment-generation
- Repository: https://github.com/hitesh05/comment-generation

## Overview

##### Project type and purpose
- This is a research‐oriented, machine‐learning pipeline for code‐comment relevance classification and automated comment generation.
- The README describes two main tasks:
a. Train a classifier on code‐comment relevance datasets (“Relevant” vs. “Non-relevant”).
b. Use insights from the classifier task to train a text-generation model that generates comments for code.

##### File structure
- Top-level directories/modules:
- Auto_comments (code2seq + deepcom): Implements the deep learning comment‐generation pipeline, Java/C# feature extraction, data preprocessing, model training and inference.
- Comment classifier: Contains notebooks and scripts to train and evaluate different classification models (TF-IDF baseline, BERT, RoBERTa, Siamese networks).
- adamo: Experiment orchestration for translation‐style comment generation on different datasets, with slurm job scripts, logs and result files.
- Scripts & utilities: python scripts (`extract.py`, `bleu_score.py`), shell scripts (`preprocess.sh`, `train.sh`, `t2t.sh`), multi‐BLEU scoring, Jupyter notebooks.
- Data and model files: under `data/`, `adamo/data/`, preprocessed archives, results (`adamo/results`).

##### README for additional insights
- The README only outlines the problem statement but does not describe architecture explicitly.
- Look at module readmes (e.g. Auto_comments/README.md, Comment classifier/README.md) for hints on each sub-pipeline.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Ingestion
    subgraph "Data Ingestion"
        direction TB
        RawData["Raw code/comment corpora"]:::data
        AdamoIngest["Adamo ingestion scripts"]:::data
    end

    %% Preprocessing & Feature Extraction
    subgraph "Preprocessing & Feature Extraction"
        direction TB
        JavaAST["Java AST extractor"]:::pre
        CSharpAST["C# AST extractor"]:::pre
        Subtoken["Baseline tokenization"]:::pre
        ASTScripts["AST extraction scripts"]:::pre
        PreprocPipes["Preprocessing pipelines"]:::pre
    end

    %% Classification Pipeline
    subgraph "Classification Pipeline"
        direction TB
        ClassData["Comment-relevance datasets"]:::data
        TFIDF["TF-IDF Featureizer"]:::model
        BERT["BERT Classifier"]:::model
        Siamese["Siamese Network"]:::model
        PretrainedModels["Model definitions & loading"]:::model
        EvalNotebook["cosine_similarity_analysis.ipynb"]:::notebook
        BLEUScore["BLEU & similarity scoring"]:::model
    end

    %% Generation Pipeline
    subgraph "Generation Pipeline"
        direction TB
        Code2SeqCore["code2seq + deepcom core"]:::model
        Seq2SeqTrain["Seq2seq training script"]:::model
        InteractivePred["Interactive predict"]:::model
        T2T["T2T Transformer experiments"]:::model
        SlurmJobs["SLURM job scripts"]:::orches
    end

    %% Orchestration & Infrastructure
    subgraph "Orchestration & Infrastructure"
        direction TB
        ShellScripts["Shell orchestration scripts"]:::orches
        SlurmLogs["SLURM outputs/logs"]:::orches
    end

    %% Outputs & Artifacts
    subgraph "Outputs & Artifacts"
        direction TB
        Hypotheses["Generated hypotheses"]:::output
        Scores["Aggregated scores"]:::output
        ModelArchive["Trained data archive"]:::output
    end

    %% Data Flow
    RawData -->|".java/.cs + comments"| PreprocPipes
    AdamoIngest -->|".java/.cs + comments"| PreprocPipes

    PreprocPipes -->|"AST + tokens"| JavaAST
    PreprocPipes -->|"AST + tokens"| CSharpAST
    PreprocPipes -->|"subtokens"| Subtoken
    PreprocPipes -->|"AST files"| ASTScripts

    JavaAST -->|"features"| ClassData
    CSharpAST -->|"features"| ClassData
    Subtoken -->|"features"| ClassData
    ASTScripts -->|"features"| ClassData

    ClassData --> TFIDF
    ClassData --> BERT
    ClassData --> Siamese

    TFIDF --> PretrainedModels
    BERT --> PretrainedModels
    Siamese --> PretrainedModels

    PretrainedModels --> EvalNotebook
    EvalNotebook --> BLEUScore
    BLEUScore --> Scores

    PreprocPipes --> Code2SeqCore
    Code2SeqCore --> Seq2SeqTrain
    Seq2SeqTrain --> InteractivePred
    Seq2SeqTrain --> Hypotheses
    Hypotheses --> Scores

    T2T --> SlurmJobs
    SlurmJobs --> Hypotheses

    ShellScripts --> PreprocPipes
    ShellScripts --> Seq2SeqTrain
    ShellScripts --> BLEUScore
    SlurmLogs --> Scores

    %% Feedback loop
    BLEUScore -->|"confidence scores"| Seq2SeqTrain

    %% Click Events
    click RawData "https://github.com/hitesh05/comment-generation/tree/main/Auto_comments/data/"
    click AdamoIngest "https://github.com/hitesh05/comment-generation/tree/main/adamo/data/"
    click JavaAST "https://github.com/hitesh05/comment-generation/tree/main/Auto_comments/JavaExtractor/JPredict/"
    click CSharpAST "https://github.com/hitesh05/comment-generation/tree/main/Auto_comments/code2seq_master/CSharpExtractor/CSharpExtractor/Extractor/"
    click Subtoken "https://github.com/hitesh05/comment-generation/tree/main/Auto_comments/code2seq_master/baseline_tokenization/"
    click ASTScripts "https://github.com/hitesh05/comment-generation/blob/main/Auto_comments/code2seq_master/extract_ast.py"
    click ASTScripts "https://github.com/hitesh05/comment-generation/blob/main/Auto_comments/code2seq_master/code2seq_ast_extractor.py"
    click PreprocPipes "https://github.com/hitesh05/comment-generation/tree/main/Auto_comments/preproc/"
    click PreprocPipes "https://github.com/hitesh05/comment-generation/blob/main/Auto_comments/preproc/preprocess.sh"
    click PreprocPipes "https://github.com/hitesh05/comment-generation/blob/main/Auto_comments/code2seq_master/preprocess.sh"
    click PreprocPipes "https://github.com/hitesh05/comment-generation/blob/main/Auto_comments/code2seq_master/preprocess_csharp.sh"
    click ClassData "https://github.com/hitesh05/comment-generation/tree/main/Comment classifier/"
    click PretrainedModels "https://github.com/hitesh05/comment-generation/blob/main/Comment classifier/pretrained_models.py"
    click EvalNotebook "https://github.com/hitesh05/comment-generation/blob/main/Comment classifier/cosine_similarity_analysis.ipynb"
    click BLEUScore "https://github.com/hitesh05/comment-generation/blob/main/Auto_comments/bleu_score.py"
    click Code2SeqCore "https://github.com/hitesh05/comment-generation/tree/main/Auto_comments/code2seq_master/"
    click Seq2SeqTrain "https://github.com/hitesh05/comment-generation/blob/main/Auto_comments/code2seq_master/train.sh"
    click InteractivePred "https://github.com/hitesh05/comment-generation/blob/main/Auto_comments/code2seq_master/interactive_predict.py"
    click T2T "https://github.com/hitesh05/comment-generation/blob/main/adamo/src/t2t.py"
    click SlurmJobs "https://github.com/hitesh05/comment-generation/blob/main/adamo/src/t2t.sh"
    click SlurmJobs "https://github.com/hitesh05/comment-generation/blob/main/adamo/src/t2t_adamo.job"
    click SlurmJobs "https://github.com/hitesh05/comment-generation/blob/main/adamo/src/t2t_noisy.job"
    click SlurmJobs "https://github.com/hitesh05/comment-generation/blob/main/adamo/src/t2t_power.job"
    click SlurmJobs "https://github.com/hitesh05/comment-generation/blob/main/adamo/src/t2t_review.job"
    click ShellScripts "https://github.com/hitesh05/comment-generation/blob/main/Auto_comments/scripts/multi-bleu.perl"
    click ShellScripts "https://github.com/hitesh05/comment-generation/blob/main/Auto_comments/code2seq_master/preprocess.sh"
    click ShellScripts "https://github.com/hitesh05/comment-generation/blob/main/Auto_comments/code2seq_master/train.sh"
    click SlurmLogs "https://github.com/hitesh05/comment-generation/tree/main/adamo/logs/"
    click Hypotheses "https://github.com/hitesh05/comment-generation/tree/main/adamo/results/"
    click Scores "https://github.com/hitesh05/comment-generation/blob/main/adamo/results/scores.csv"
    click ModelArchive "https://github.com/hitesh05/comment-generation/blob/main/Auto_comments/data/data.7z"

    %% Styles
    classDef data fill:#BBDEFB,stroke:#1E88E5,color:#0D47A1;
    classDef pre fill:#B3E5FC,stroke:#039BE5,color:#01579B;
    classDef model fill:#C8E6C9,stroke:#43A047,color:#1B5E20;
    classDef orches fill:#FFE0B2,stroke:#FB8C00,color:#E65100;
    classDef output fill:#E1BEE7,stroke:#8E24AA,color:#4A148C;
    classDef notebook stroke-dasharray: 5 5,fill:#FFF9C4,stroke:#FBC02D,color:#F57F17;
```
