Skip to content

Commit

Permalink
Merge branch 'production' into isolate-icon-table
Browse files Browse the repository at this point in the history
  • Loading branch information
yceballost authored Oct 30, 2024
2 parents 394ed56 + b023094 commit 8218ec2
Show file tree
Hide file tree
Showing 433 changed files with 403 additions and 204 deletions.
110 changes: 110 additions & 0 deletions .github/keywords/keywords-generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import os
import json
import subprocess
from openai import OpenAI
from dotenv import load_dotenv

# Load environment variables from the .env file
load_dotenv()

# Set up the OpenAI API key
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))

# Path to the main folder (the "icons" folder)
main_folder = "./icons"

# JSON file where synonyms will be stored
synonyms_json_file = "./icons/icons-keywords.json"

# Load the JSON file if it already exists
if os.path.exists(synonyms_json_file):
with open(synonyms_json_file, "r", encoding="utf-8") as f:
synonyms_dictionary = json.load(f)
else:
synonyms_dictionary = {}

# Remove common style indicators from the filename and return
def preprocess_filename(filename):
return filename.replace("-filled.svg", "").replace("-light.svg", "").replace("-regular.svg", "")

# Function to recursively list all unique SVG filenames without their paths
def list_concepts(folder):
concepts = set() # Use a set to avoid duplicates
for root, dirs, files in os.walk(folder):
# Filter and preprocess SVG filenames before adding to the set
for file in files:
if file.endswith('.svg') and not file.startswith('.'):
processed_file = preprocess_filename(file)
concepts.add(processed_file)
return list(concepts) # Convert set to list before returning

# Function to generate synonyms using GPT
def generate_synonyms(concept):
prompt = f"Generate 12 synonyms for the concept '{concept}' mixing English, Spanish, Portuguese, and German (in this order). Return them as a plain list of words, without quotes, numbering, or separation by language. the order of the synonyms should be English, Spanish, Portuguese, and German. For example: alert lamp cross, warning light plus, signal illumination cross, luz de alarma cruz, luz de advertencia plus, iluminación de señal cruz, Alarmleuchte Kreuz, Warnlicht plus, Signalbeleuchtung Kreuz"

response = client.chat.completions.create(model="gpt-4",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
],
max_tokens=100,
temperature=0.7)

# Get the generated response
raw_synonyms = response.choices[0].message.content.strip()

# Clean the output, removing unnecessary characters and convert it to a list
synonyms = [synonym.strip(' "[]') for synonym in raw_synonyms.split(',')]

return synonyms

# Get concepts from the icons folder
concepts = set(list_concepts(main_folder)) # Convert to set for efficiency

# Counter to know how many new concepts have been processed
new_concepts = 0

# Remove entries in synonyms_dictionary that no longer have corresponding icons
keys_to_remove = [key for key in synonyms_dictionary if key not in concepts]
for key in keys_to_remove:
del synonyms_dictionary[key]
print(f"Concept removed: {key}")

# Update the JSON file only with new concepts
for concept in concepts:
if concept not in synonyms_dictionary:
print(f"Generating synonyms for: {concept}")
try:
# Generate synonyms using GPT
generated_synonyms = generate_synonyms(concept)
# Save the synonyms in the dictionary
synonyms_dictionary[concept] = generated_synonyms
new_concepts += 1
print(f"Concept generated: {concept} - Synonyms: {generated_synonyms}")
except Exception as e:
print(f"Error generating synonyms for {concept}: {e}")
# In case of error, save generic synonyms to avoid leaving it empty
synonyms_dictionary[concept] = ["synonym1", "synonym2", "synonym3"]
print(f"Concept generated with generic synonyms: {concept}")

# Only save if there are new concepts or if concepts have been removed
if new_concepts > 0 or keys_to_remove:
# Save the updated and alphabetically sorted dictionary in the JSON file
with open(synonyms_json_file, "w", encoding="utf-8") as f:
json.dump(synonyms_dictionary, f, ensure_ascii=False, indent=4, sort_keys=True)
print(f"{new_concepts} new concepts have been generated.")
print(f"{len(keys_to_remove)} obsolete concepts have been removed.")
else:
print("No new concepts or obsolete concepts found.")

# Run Prettier to format the JSON file
try:
subprocess.run(["npx", "prettier", "--write", synonyms_json_file], check=True)
print(f"The file {synonyms_json_file} has been formatted with Prettier.")
except subprocess.CalledProcessError as e:
print(f"Error formatting the file with Prettier: {e}")

# Count the total number of concepts
total_concepts = len(concepts)
print(f"Total concepts processed: {total_concepts}")
print("Process completed. The icons-keywords.json file has been updated and sorted alphabetically.")
6 changes: 6 additions & 0 deletions .github/workflows/auto-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ jobs:

- run: sudo python3 .github/md-generator/generate_markdown.py icons

- name: Check for changes
id: git_status
run: |
git diff --exit-code || echo "changes"
- name: Commit & Push in ${{ env.GITHUB_REF_SLUG_URL }}
if: steps.git_status.outputs.result == 'changes'
run: |
git add .
git config user.name "github-actions"
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/keywords-generator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Keywords autogenerated

on:
workflow_dispatch:
pull_request:
branches:
- production
paths:
- "icons/**"

jobs:
generate-keywords:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Checkout branch or create new one
run: |
git fetch
if git branch -a | grep origin/import-figma-icons; then
git checkout import-figma-icons
else
git checkout -b import-figma-icons
fi
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"

- name: Upgrade pip, setuptools, and wheel
run: |
pip install --upgrade pip setuptools wheel
# Paso 3: Instalar dependencias de Python
- name: Install dependencies
run: |
pip install openai python-dotenv --use-pep517
- name: Install prettier
run: npm install -g prettier

- name: Run keywords generator
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: python3 .github/keywords/keywords-generator.py

- name: Commit & Push
env:
GITHUB_TOKEN: ${{ secrets.NOVUM_PRIVATE_REPOS }}
run: |
git config user.name "github-actions"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Icons keywords autogenerated"
git push origin import-figma-icons
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ o2-new-filled.json
#figma-export-icons
o2-new-regular.json
#figma-export-icons
o2-new-light.json
o2-new-light.json

5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ Mística-icons is built to grow, that means that If you need a new icon, you hav
1. Check If mistica-icons doesn't cover your need in [this list](https://github.com/Telefonica/mistica-icons/blob/production/README.md)
2. Read [Brand Factory](https://brandfactory.telefonica.com/hub/134) icons guidelines by brand
3. Create a new icon following the guidelines and **with 3 weights!** _(light / regular / filled)_
4. Provide 3 synonyms for this icon. [Keywords file](icons/icons-keywords.json)
5. Create an issue [here](https://github.com/Telefonica/mistica-design/issues/new?assignees=&labels=fundamentals%3A+icons%2Crequest+%E2%9C%A8&template=icon_request.yml&title=Title)
6. That's all! We will review If your icon have all the needs to add it to mistica-icons
4. Create an issue [here](https://github.com/Telefonica/mistica-design/issues/new?assignees=&labels=fundamentals%3A+icons%2Crequest+%E2%9C%A8&template=icon_request.yml&title=Title)
5. That's all! We will review If your icon have all the needs to add it to mistica-icons

# Report an icon bug

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Telefonica
<img src='https://dummyimage.com/1x8/0066FF/000&text=+' alt='All Equivalence'><img src='https://dummyimage.com/56x8/EAC344/000&text=+' alt='Some Equivalence'><img src='https://dummyimage.com/90x8/59C2C9/000&text=+' alt='Unique'><img src='https://dummyimage.com/253x8/D1D5E4/000&text=+' alt='Missing'>

O2
<img src='https://dummyimage.com/1x8/0066FF/000&text=+' alt='All Equivalence'><img src='https://dummyimage.com/112x8/EAC344/000&text=+' alt='Some Equivalence'><img src='https://dummyimage.com/287x8/D1D5E4/000&text=+' alt='Missing'>
<img src='https://dummyimage.com/1x8/0066FF/000&text=+' alt='All Equivalence'><img src='https://dummyimage.com/111x8/EAC344/000&text=+' alt='Some Equivalence'><img src='https://dummyimage.com/288x8/D1D5E4/000&text=+' alt='Missing'>

O2-New
<img src='https://dummyimage.com/1x8/0066FF/000&text=+' alt='All Equivalence'><img src='https://dummyimage.com/112x8/EAC344/000&text=+' alt='Some Equivalence'><img src='https://dummyimage.com/1x8/59C2C9/000&text=+' alt='Unique'><img src='https://dummyimage.com/286x8/D1D5E4/000&text=+' alt='Missing'>
Expand All @@ -39,7 +39,7 @@ Vivo-New
<img src='https://dummyimage.com/1x8/0066FF/000&text=+' alt='All Equivalence'><img src='https://dummyimage.com/6x8/EAC344/000&text=+' alt='Some Equivalence'><img src='https://dummyimage.com/7x8/59C2C9/000&text=+' alt='Unique'><img src='https://dummyimage.com/386x8/D1D5E4/000&text=+' alt='Missing'>

Blau
<img src='https://dummyimage.com/1x8/0066FF/000&text=+' alt='All Equivalence'><img src='https://dummyimage.com/7x8/EAC344/000&text=+' alt='Some Equivalence'><img src='https://dummyimage.com/1x8/59C2C9/000&text=+' alt='Unique'><img src='https://dummyimage.com/391x8/D1D5E4/000&text=+' alt='Missing'>
<img src='https://dummyimage.com/1x8/0066FF/000&text=+' alt='All Equivalence'><img src='https://dummyimage.com/6x8/EAC344/000&text=+' alt='Some Equivalence'><img src='https://dummyimage.com/1x8/59C2C9/000&text=+' alt='Unique'><img src='https://dummyimage.com/392x8/D1D5E4/000&text=+' alt='Missing'>


| <sub><sup>ICON SET</sup></sub> | <sub><sup>CONCEPTS (611)</sup></sub> | <sub><sup>TOTAL (3245)</sup></sub> | <sub><sup>ALL EQUIVALENCE</sup></sub> | <sub><sup>SOME EQUIVALENCE</sup></sub> | <sub><sup>UNIQUE</sup></sub> | <sub><sup>MISSING</sup></sub> |
Expand Down
6 changes: 5 additions & 1 deletion icons/icons-keywords.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@
"dartboard": ["darts target", "bullseye board", "throwing game", "tablero de dardos", "alvo de dardos", "Dartbrett"],
"data": ["information", "facts", "data points", "datos", "informações", "Daten"],
"data-10-gb": ["10 gigabytes of data", "data plan", "data allocation", "10 gigabytes de datos", "plano de dados", "10 Gigabyte Daten"],
"data-30-gb": ["30 gigabytes of data", "data plan", "data allocation", "30 gigabytes de datos", "plano de dados", "30 Gigabyte Daten"],
"data-100-gb": ["100 gigabytes of data", "large data plan", "huge data allocation", "100 gigabytes de datos", "plano de datos grande", "100 Gigabyte Daten"],
"data-30-gb": ["30 gigabytes of data", "data plan", "data allocation", "30 gigabytes de datos", "plano de dados", "30 Gigabyte Daten"],
"data-alert": ["data warning", "usage alert", "data notification", "advertencia de datos", "alerta de uso", "Datenbenachrichtigung"],
"data-bonus": ["extra data", "bonus allocation", "additional data", "datos adicionales", "alocação de bônus", "zusätzliche Daten"],
"data-centre": ["data center", "server farm", "information hub", "centro de datos", "centro de servidores", "Datenzentrum"],
Expand Down Expand Up @@ -367,6 +367,9 @@
"menu": ["list of options", "navigation", "dropdown", "menú", "menu", "Menü"],
"microchip": ["integrated circuit", "electronic chip", "microcircuit", "microchip integrado", "chip eletrônico", "integrierter Schaltkreis"],
"microphone": ["mic", "audio input", "sound sensor", "micrófono", "microfone", "Mikrofon"],
"microphone-aura": ["microphone vibe", "microphone energy", "microphone atmosphere", "aura de microfono", "energía de microfono", "atmosfera de microfono", "vibe do microfone", "energia do microfone", "atmosfera do microfone", "Mikrofon Aura", "Mikrofon Energie", "Mikrofon Atmosphäre"],
"microphone-aura-disabled": ["microphone-aura-off", "microphone-halo-deactivated", "microphone-glow-disabled", "micrófono-aura-desactivado", "micrófono-halo-apagado", "micrófono-brillo-desactivado", "microfone-aura-desativado", "microfone-halo-desativado", "microfone-brilho-desativado", "Mikrofon-Aura-deaktiviert", "Mikrofon-Halo-abgeschaltet", "Mikrofon-Glow-deaktiviert"],
"microphone-disabled": ["microphone-off", "microphone-muted", "microphone-shut", "micrófono-desactivado", "micrófono-silenciado", "micrófono-apagado", "microfone-desativado", "microfone-mudo", "microfone-desligado", "Mikrofon-deaktiviert", "Mikrofon-stumm", "Mikrofon-ausgeschaltet"],
"millennials": ["generation y", "gen y", "digital natives", "millennials", "millennials", "Millennials"],
"mms": ["multimedia message service", "mms", "servicio de mensajes multimedia", "serviço de mensagens multimídia", "Multimedia-Nachrichtendienst"],
"mobile-add-user": ["add user on mobile", "mobile user addition", "phone user inclusion", "agregar usuario en el móvil", "adicionar usuário móvel", "Benutzer auf dem Handy hinzufügen"],
Expand Down Expand Up @@ -580,6 +583,7 @@
"user-support": ["user assistance", "customer support", "help for users", "soporte de usuario", "suporte ao cliente", "Benutzerunterstützung"],
"video": ["visual", "clip", "footage", "video", "vídeo", "Video"],
"video-camera": ["camcorder", "video recorder", "movie camera", "videocámara", "câmera de vídeo", "Videokamera"],
"video-camera-disabled": ["video-camera-off", "video-camera-inactive", "video-camera-unavailable", "cámara-de-video-inhabilitada", "cámara-de-video-desactivada", "cámara-de-video-indisponible", "câmera-de-vídeo-desativada", "câmera-de-vídeo-inativa", "câmera-de-vídeo-indisponível", "Videokamera-deaktiviert", "Videokamera-inaktiv", "Videokamera-nicht-verfügbar"],
"video-chat": ["video call", "visual communication", "face-to-face call", "videollamada", "chamada de vídeo", "Videoanruf"],
"video-disabled": ["no video", "video turned off", "camera disabled", "video desactivado", "vídeo desativado", "Video deaktiviert"],
"video-surveillance-security": ["security video surveillance", "cctv security", "monitoring system", "vigilancia de seguridad con video", "segurança CCTV", "Videoüberwachungssicherheit"],
Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions icons/o2-new/filled/video-camera-disabled-filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
1 change: 1 addition & 0 deletions icons/o2-new/light/video-camera-disabled-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
1 change: 1 addition & 0 deletions icons/o2-new/regular/video-camera-disabled-regular.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/telefonica/filled/dna-filled.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion icons/telefonica/filled/dna-filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/telefonica/filled/email-filled.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion icons/telefonica/filled/email-filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/telefonica/filled/exchange-filled.pdf
Binary file not shown.
Loading

0 comments on commit 8218ec2

Please sign in to comment.