Created
April 7, 2022 03:34
-
-
Save davidbegin/3f73bfc48aed70b484e81240b5617faf to your computer and use it in GitHub Desktop.
Text to Frank script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"strings" | |
"github.com/alwindoss/morse" | |
) | |
func main() { | |
input := flag.String("input", "I only love frank", "What you would like to convert to frank speech.") | |
flag.Parse() | |
userInput := string(*input) | |
fmt.Printf("\n\t Original: %s\n", userInput) | |
h := morse.NewHacker() | |
morseCode, _ := h.Encode(strings.NewReader(userInput)) | |
fmt.Printf("\nMorse Code: %s\n", morseCode) | |
result := strings.ReplaceAll(string(morseCode), ".", "frank") | |
second := strings.ReplaceAll(result, "-", "FRANK") | |
final := strings.ReplaceAll(second, "/", "") | |
fmt.Printf("\n\n\tResult: %s", final) | |
} |
FRANKfrank frankfrank FRANKfrankFRANKfrank frank frankFRANKfrankFRANKfrankFRANK frankFRANKfrankFRANKfrankFRANK frankFRANKfrankFRANKfrankFRANK
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Go is so verbose. Ruby version, with multiline support on stdin, to translate full text files etc.: