Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Text Modification Tool (GO)

Go Reloaded

The program reads a text file, applies several formatting and transformation rules and writes the modified text into another file.

This project focuses on:

  • File handling in Go
  • String manipulation
  • Number conversion
  • Text formatting

How It Works

The program takes two arguments:

  1. Input – the file containing the original text [sample.txt]
  2. Output – the file where the modified text will be written[result.txt]
go run . sample.txt result.txt

Features

1. Number Conversions

Hexadecimal to Decimal

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

Example:

1E (hex) files were added

Output:

30 files were added

Binary to Decimal

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

Example:

It has been 10 (bin) years

Output:

It has been 2 years

2. Text Case Modifications

Uppercase (up)

Converts the previous word to uppercase.

Example:

go (up)

Output:

GO

Lowercase (low)

Converts the previous word to lowercase.

Example:

HELLO (low)

Output:

hello

Capitalize (cap)

Capitalizes the first letter of previous word.

Example:

hello (cap)

Output:

Hello

3. Case Modification with Numbers

Syntax:

(up, n)
(low, n)
(cap, n)

Example:

This is amazing (up, 2)

Output:

This IS AMAZING

4. Punctuation Formatting

Punctuation marks:

. , ! ? : ;

Rules:

  • Punctuation attaches to the previous word
  • There must be one space after punctuation

Example:

Hello ,world !

Output:

Hello, world!

5. Punctuation Groups

Groups like:

...
!?

Remain together and attach to the previous word.

Example:

I was thinking ... You were right

Output:

I was thinking... You were right

6. Quote Formatting

Single quotes ' ' should wrap words without spaces inside.

Example:

' awesome '

Output:

'awesome'

Example with multiple words:

' I love Go '

Output:

'I love Go'

7. Article Correction (a → an)

The word a becomes an when the next word starts with:

a, e, i, o, u, h

Example:

A amazing rock

Output:

An amazing rock

Running the Program

  1. Create an input file:
sample.txt
  1. Run the program:
go run . sample.txt result.txt
  1. Check the output:
cat result.txt

About

A Go program that reads a text file, applies formatting and transformation rules (number conversion, case changes, punctuation fixes) and writes the modified result to a new file. Designed to practice file handling and string manipulation.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages