File size: 1,205 Bytes
74d3a34
 
316353b
 
74d3a34
 
 
316353b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os

from gr_nlp_toolkit import Pipeline

os.environ["TOKENIZERS_PARALLELISM"] = "false"


# Use this file only for testing purposes

nlp_pos_ner_dp = Pipeline(
    "pos,ner,dp"
)  # Instantiate the Pipeline with the DP, POS and NER processors
doc_pos_ner_dp = nlp_pos_ner_dp(
    "Η Αργεντινή κέρδισε το Παγκόσμιο Κύπελλο το 2022"
)  # Apply the pipeline to a sentence in Greek


# Iterate over the generated tokens
for token in doc_pos_ner_dp.tokens:
    print(
        f"Text: {token.text},"
        f" NER: {token.ner},"  # Print the NER value of the token
        f" UPOS: {token.upos}, "  # UPOS
        f" Morphological Features: {token.feats}, Head: {token.head},"
        f" Deprel: {token.deprel}"
        "\n---"
    )


nlp_g2g = Pipeline("g2g")  # Instantiate the Pipeline with the G2G processor

doc_g2g = nlp_g2g(
    "h thessaloniki einai mia poli sti boreia ellada"
)  # Apply the pipeline to a sentence in Greek
for token in doc_g2g.tokens:
    # Gather all the token.text values and join them with a space
    transliterated_text = " ".join([token.text for token in doc_g2g.tokens])
print(transliterated_text)  # Print the transliterated text