-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgemini.py
More file actions
51 lines (38 loc) · 1.66 KB
/
Copy pathgemini.py
File metadata and controls
51 lines (38 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from google import genai
from dotenv import load_dotenv
load_dotenv()
client = genai.Client()
# response = client.models.generate_content(
# model="gemini-2.5-flash-lite", contents="Explain the concept of polymorphism in object-oriented programming."
# )
#
# print(response.text)
def glosses_to_text(glosses):
prompt = f"""You are a specialized translator for German Sign Language (DGS) glosses to English.
Task: Translate the following DGS glosses into fluent, natural English.
Context: DGS glosses are written representations of sign language where:
- Words appear in their base form
- Grammar markers are often omitted
- Word order follows DGS syntax, not English syntax
- Special notation may be used (e.g., POSS for possessive)
Instructions:
1. Translate the meaning, not word-for-word
2. Use proper English grammar and sentence structure
3. Maintain the original meaning and intent
4. Return ONLY the translated English text, nothing else
5. Do not include explanations, notes, or any text besides the translation
6. Use complete, grammatically correct English sentences
DGS Glosses to translate: {glosses}"""
response = client.models.generate_content(
model="gemini-2.5-flash-lite", contents=prompt
)
return response.text
def custom_prompt(prompt):
response = client.models.generate_content(
model="gemini-2.5-flash-lite", contents=prompt
)
return response.text
if __name__ == "__main__":
sample_glosses = "DIENSTAG BESONDERS REGION MEHR FREUNDLICH LANG ABER AUCH DABEI SCHAUER"
translation = glosses_to_text(sample_glosses)
print("Translated Text:", translation)