Add test run
Browse files- test_run.py +33 -0
test_run.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from gr_nlp_toolkit import Pipeline
|
2 |
+
|
3 |
+
# Use this file only for testing purposes
|
4 |
+
|
5 |
+
nlp_pos_ner_dp = Pipeline(
|
6 |
+
"pos,ner,dp"
|
7 |
+
) # Instantiate the Pipeline with the DP, POS and NER processors
|
8 |
+
doc_pos_ner_dp = nlp_pos_ner_dp(
|
9 |
+
"Η Αργεντινή κέρδισε το Παγκόσμιο Κύπελλο το 2022"
|
10 |
+
) # Apply the pipeline to a sentence in Greek
|
11 |
+
|
12 |
+
|
13 |
+
# Iterate over the generated tokens
|
14 |
+
for token in doc_pos_ner_dp.tokens:
|
15 |
+
print(
|
16 |
+
f"Text: {token.text},"
|
17 |
+
f" NER: {token.ner}," # Print the NER value of the token
|
18 |
+
f" UPOS: {token.upos}, " # UPOS
|
19 |
+
f" Morphological Features: {token.feats}, Head: {token.head},"
|
20 |
+
f" Deprel: {token.deprel}"
|
21 |
+
"\n---"
|
22 |
+
)
|
23 |
+
|
24 |
+
|
25 |
+
nlp_g2g = Pipeline("g2g") # Instantiate the Pipeline with the G2G processor
|
26 |
+
|
27 |
+
doc_g2g = nlp_g2g(
|
28 |
+
"h thessaloniki einai mia poli sti boreia ellada"
|
29 |
+
) # Apply the pipeline to a sentence in Greek
|
30 |
+
for token in doc_g2g.tokens:
|
31 |
+
# Gather all the token.text values and join them with a space
|
32 |
+
transliterated_text = " ".join([token.text for token in doc_g2g.tokens])
|
33 |
+
print(transliterated_text) # Print the transliterated text
|