Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Text Processor in Go

This Go program reads a text file, processes it by converting numbers from hexadecimal or binary, applying text transformations (uppercase, lowercase, capitalization), and fixing punctuation and article usage, and writes the result to an output file.

Structure

text-processor/
├── main.go          # Program logic
├── main_test.go     # Unit tests
├── README.md        # Documentation
├── sample.txt       # Example input text
└── result.txt       # Output after processing sample.txt

Features

Convert hexadecimal numbers to decimal (e.g., 1E (hex) → 30)

Convert binary numbers to decimal (e.g., 10 (bin) → 2)

Transform text:

-Uppercase (up)

-Lowercase (low)

-Capitalize (cap)

Correct article usage (a → an before vowels or 'h')

Normalize punctuation and spacing

Properly format ellipses (...) and quotes

Usage

Cloning the git repository using the command below

git clone https://learn.zone01kisumu.ke/git/mlizlent/go-reloaded
cd go-reloaded

Run

go run . sample.txt result.txt

Then run

cat result.txt

Example

Input (sample.txt):

1E (hex) files were added. Ready, set, go (up) !

Output (result.txt):

30 files were added. Ready, set, GO!

Testing

The project includes unit tests using Go's testing package.

Tests cover:

Hexadecimal and binary conversion

Uppercase, lowercase, and capitalization transformations

Multiple word transformations

Punctuation and ellipsis formatting

Quote formatting

Article (a/an) correction

Run tests with:

go test

Expected output

PASS
ok      mlz/Desktop/go-reloaded 0.002s

Notes

The program uses regular expressions to detect transformations and conversions. Transformations like (up, 2) apply to the last N words before the marker. Punctuation spacing is automatically normalized.

Author

Meroline Lizlent

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages