Skip to content

Aycode01/go-reloaded

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This project is a text processing tool written in Go. It reads a text file, applies several automatic corrections and formatting rules, and writes the corrected text to another file.

The goal is to simulate a simple text editor / auto-correction engine.

The program processes the input text and performs transformations such as:

  • Converting binary and hexadecimal numbers to decimal
  • Changing text case (uppercase, lowercase, capitalized)
  • Fixing punctuation spacing
  • Correcting single quotes spacing
  • Replacing "a" with "an" when necessary

How It Works

The program is executed with two arguments:

go run . input.txt output.txt
  • input.txt → file containing the original text
  • output.txt → file where the corrected text will be saved

Example:

go run . sample.txt result.txt

Features

1. Hexadecimal Conversion

If (hex) appears after a word, the previous word is treated as a hexadecimal number and converted to decimal.

Example:

Input:
1E (hex) files were added

Output:
30 files were added

2. Binary Conversion

If (bin) appears after a word, the previous word is treated as a binary number and converted to decimal.

Example:

Input:
It has been 10 (bin) years

Output:
It has been 2 years

Case Conversions

The program can modify text case using special commands.

Uppercase

(up)

Converts the previous word to uppercase.

Example:

go (up)
→ GO

Lowercase

(low)

Converts the previous word to lowercase.

Example:

HELLO (low)
→ hello

Capitalize

(cap)

Capitalizes the previous word.

Example:

bridge (cap)
→ Bridge

Case Conversion with Numbers

Commands can also modify multiple words.

Syntax:

(up, N)
(low, N)
(cap, N)

Where N is the number of previous words to modify.

Example:

Input:
This is so exciting (up, 2)

Output:
This is SO EXCITING

Punctuation Formatting

The program fixes spacing around punctuation marks:

. , ! ? : ;

Rules:

  • No space before punctuation
  • One space after punctuation

Example:

Input:
I was sitting over there ,and then BAMM !!

Output:
I was sitting over there, and then BAMM!!

Quote Formatting

Single quotes ' must wrap words without spaces inside.

Example:

Input:
'I am awesome '

Output:
'I am awesome'

Multiple words inside quotes are also handled correctly.

Example:

Input:
' I am the best developer '

Output:
'I am the best developer'

Article Correction

The program replaces "a" with "an" when the next word begins with:

a e i o u h

Example:

Input:
There is a amazing rock.

Output:
There is an amazing rock.

Project Structure

text-tool/
│
├── main.go        # Program entry point
├── functions.go   # All text processing functions
└── README.md      # Project documentation

Main Processing Steps

The program processes text in the following order:

  1. Convert hexadecimal numbers
  2. Convert binary numbers
  3. Apply case modifications
  4. Fix punctuation spacing
  5. Fix quotes spacing
  6. Correct "a/an" usage

Each step is implemented as a separate function to keep the code clean and maintainable.


Example

Input (input.txt)

it (cap) was the best of times , it was the worst of times (up)

Run

go run . sample.txt result.txt

Output (output.txt)

It was the best of times, it was the worst of TIMES

Allowed Packages

The project only uses Go standard library packages, such as:

  • fmt
  • os
  • strings
  • strconv

Learning Objectives

This project helps practice:

  • File reading and writing in Go
  • String manipulation
  • Working with slices
  • Error handling
  • Writing clean and modular code

Author

Omitogun Ayobami Rasheed

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages