-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
34 lines (18 loc) · 694 Bytes
/
Copy pathmain.py
File metadata and controls
34 lines (18 loc) · 694 Bytes
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
import crosslang_embed
phrase_list = ['hi', 'hello', 'bon nuit', 'bonjourno', 'boujour', 'bon soir', 'good night',
'good evening']
mph = crosslang_embed.MultilangPhrase()
# translate and embed phrases
mph.process_phrases(phrase_list)
# Show languages and translations for all phrases ---
print(mph.dfmain)
# Find matches for any single phrase ---
print("find_matches_index:","salut")
df = mph.find_matches_index("salut", )
print( df[ df.dist<1.2].head(30) )
print("find_matches_index:","good evening")
df = mph.find_matches_index("good evening",)
print( df[ df.dist<1.2].head(10) )
# Plot phrases to see clustering ---
mph.umap_embeddings()
mph.plot_embeddings()