# Project export: Goojle Translate

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: Cal Hacks 11.0
- Tagline: Enhancing communication, one emoticon at a time!
- Devpost: https://devpost.com/software/goojle-translate
- GitHub: https://github.com/angiew33/goojle-translate
- Team: 3 GitHub contributor(s) — jeslyn (12 commits), angiew33 (10 commits), placholdercuzidc (8 commits)

## Devpost submission (written by the team)

No Devpost description available.

## README (from the GitHub repository)

# emogi-translate

Welcome to Emogi Translate! 🥰🎊 

Emogi Translate bridges the gap between all humans by translating from written language to the modern practice of hieroglyphics (aka emogis!). With its sleek, minimalist design and user-friendly interface, Emogi Translate makes it fun and easy to communicate visually and impactfully.

Try out Emogi Translate by selecting an input "language" and typing the text or emojis you want translated. Then click "Translate" to receive your emote-ified message. Our application gives you a fun result suitable for all ages and backgrounds to understand! 

--Enhancing communication, one emogi at a time--


## Detected evidence (automated analysis)

Indexed codebase: 4 recognized source files, 6 KB.
- CSS (language) — detected in the code
- HTML (language) — detected in the code
- Python (language) — detected in the code
- Flask (technology) — claimed on Devpost, not found in the code
- JavaScript (language) — claimed on Devpost, not found in the code

## Codebase structure (from repository index)

### Files (4 of 4)

```
emogi.py
README.md
static/styles.css
templates/emogi.html
```

### Dependencies

No dependency index available.

### Recent commits (newest first)

- Rename goojle.html to emogi.html
- Update and rename goojle.py to emogi.py
- Update README.md
- Update README.md
- Update goojle.py
- Update goojle.html
- Update README.md
- Update styles.css
- Update README.md
- Update README.md
- Update README.md
- Update goojle.py
- goojle.py
- goojle.py
- Update goojle.html
- Update goojle.py
- Update goojle.html
- Update goojle.py
- goojle.py
- Delete goojle.html

## Key source files (fetched from GitHub, selected and truncated for size)

### emogi.py

```python
from nltk.stem import PorterStemmer
from nltk.tokenize import word_tokenize
from functools import reduce
 
ps = PorterStemmer()


from flask import Flask, render_template, request

app = Flask(__name__)



import emoji
def emoji_stems():
    stems = {}
    for emote in emoji.EMOJI_DATA.keys():
        s=[]
        for w in emoji.EMOJI_DATA[emote]['en'].replace(':', '').split('_'):
            s.append(ps.stem(w))
        stems[emote]=s
    return stems

def convert(sentence,input_language,limit=5):
    stems = emoji_stems()
    result = ''
    sentence=sentence.split()
    for word in sentence:
        if input_language=='em':
            try:
                result+=emoji.demojize(word).replace(':','').replace('_',' ')+ ' '
            except:
                result+=word+' '
            continue
        elif word=='love' or word=='Love':
            result+=emoji.emojize(':blue_heart:')+' '
            continue
        temp=ps.stem(word)
        i=0
        while i<limit:
            for emote in stems.keys():
                    if i<len(stems[emote]) and temp==stems[emote][i]:
                        result+=(emoji.emojize(emoji.EMOJI_DATA[emote]['en'])) + ' '
                        i=limit
            i+=1
        if i==limit:
            result+=word + ' '
    return result


@app.route('/')
def index():
    return render_template('goojle.html')

@app.route('/', methods=['GET', 'POST'])
def result():
    result = ''
    if request.method == 'POST':
        action = request.form.get('action')
        '''data = request.get_json()
        action = data.get('action')'''
        if action == 'translate':
            input_text = ''.join(request.form.get('input-text'))
            input_language = request.form.get('input-language', 'en')
            result = convert(input_text, input_language)

        elif action == 'clear':
            input_text = ''
            result = ''
        
    return render_template('goojle.html', input=input_text, result=result) 
        


if __name__ == '__main__':
    app.run(host = '0.0.0.0', port = 3000, debug=True)


```

### static/styles.css

```css
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Open Sans", sans-serif;
    background-color: #f9f9f9;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.translate-container {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 500px;
}

.language-selection {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.language-selection select, 
.language-selection button {
    font-size: 16px;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #fffbfb;
    background-color: #f0f0f0;
    color: #333;
    appearance: none;
}

.language-selection button {
    background-color: #f9f7f7;
    cursor: pointer;
}

.translate-box {
    display: flex;
    justify-content: space-between;
}

textarea {
    width: 48%;
    height: 150px;
    padding: 10px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: none;
}

textarea[readonly] {
    background-color: #f0f0f0;
}

.action-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

button {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    background-color: #4285F4;
    color: white;
}

button:hover {
    background-color: #0056b3;
}

```

### templates/emogi.html

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Simple Translate UI</title>
    <link rel="stylesheet" href="static/styles.css">
</head>
<body>
    <form action="/" method="POST"><div class="translate-container">
        <div class="language-selection">
            <select id="input-language">
                <option value="en">English</option>
                <option value="em">Emogi</option>
            </select>
            <button id="swap-languages">⇄</button>
            <select id="output-language">
                <option value="em">Emogi</option>
                <option value="en">English</option>
            </select>
        </div>

        <div class="translate-box">
            <textarea id='input' name="input-text" placeholder="Enter text">{{  input }}</textarea>
            <textarea id='output' name="output-text" placeholder="Translation" readonly>{{ result  }}</textarea>
        </div>

        <div class="action-buttons">
            <button type="submit" name="action" value="translate" id="translate_button">Translate</button>
            <button type="submit" name="action" value="clear" id="clear_button">Clear</button>
            <button type="button" id="copy_button">Copy</button>
            <script>
                const output=document.getElementById('output')
                const copy_button=document.getElementById('copy_button')
                copy_button.onclick= function (){
                    output.select();
                    document.execCommand('Copy')
                }
            </script>
        </div></form>
    </div>

    <script src="script.js"></script>
</body>
</html>

```