During the Wolfram Research programme I looked into ancient Greek syntax and grammatical structure. There is familiarity with this subject that comes from a four-year period of studying this subject. Using this knowledge and combining it with CS made this project really exciting to work on. The algorithm that was created can recognise parts of speech such as verbs and goes as far as finding the subject in a sentence.

Introduction

The goal of this project was to analyse the complexity of ancient Greek syntax, one I have always been impressed by when studying this subject.The method used was simple and did not involve any machine learning or neural nets, unlike other functions used for this purpose.
​
It was simply done by making use of the process one goes through to determine the syntax of a sentence. My part was translating this into Wolfram Language. Well, a bit different, as the way one would do it, is partially based on what makes sense. When it came to doing the same thing computationally,grammar and syntax rules were more important.
​
A big part of this project was getting data, as the Greek language is not integrated into Wolfram. A lot of that data consists of endings that help classify the words. The second part was writing functions to classify the parts of speech. All of those were created from scratch, which shows how feasible this process can be.

Getting Data

In this section shows the data imported. Some of them are more smoothed out and others less. Many were copied from web pages, even hard coded.This section will also help with understanding how that data was organised.

Verbs

verbData


stem verbs


Participle


Infinitive


Nouns


Articles

In[]:=
articlesdata="ὁ ἡ τὸ τοῦ τῆς τοῦ τῷ τῇ τῷ τὸν τὴν τὸ ὦ οἱ αἱ τὰ τῶν τῶν τῶν τοῖς ταῖς τοῖς τοὺς τὰς τὰ";

Organising it

Verbs

For verbs I decided to make them into an association with the keys being singular and plural and their values the endings that accord to them.
Organising the data as a list while removing unnecessary parts.
In[]:=
noRealData=DeleteCases[​​StringReplace[​​DeleteCases[​​Flatten[​​DeleteCases[​​ verbData[[1]],{"","","","","","","","","","","",""}]],​​ _Real],​​{"Ορ.","Υπ.","Ευκτ.","Πρ.","","","Ορ.","Υπ.","Ευκτ.","Πρ."}->""],​​ ""];
Finding all the parts that include the strings above
In[]:=
singular=Flatten[Position[noRealData,"Εν."]];
In[]:=
weird=Flatten[Position[noRealData,"Δυ."]];
In[]:=
plural=Flatten[Position[noRealData,"Πλ."]];
Taking all those parts
In[]:=
all=Sort[Join[singular,weird,plural,{Length[noRealData]}]];
And using their coordinates to separate the endings accordingly.
In[]:=
keys=Table[Take[noRealData,{all[[x]]+1,all[[x+1]]-1}],{x,1,Length[all]-1}];
Here I am just finding the cases of those strings in my list.
In[]:=
values=Cases[noRealData,"Εν."|"Δυ."|"Πλ."];
Making an association with the keys being the strings above.
In[]:=
association1= PositionIndex[AssociationThread[keys->values]];
Replacing the strings with a letter in parenthesis with two elements. The one using that letter and the other not, so I have all the endings possible.
In[]:=
replacedValues=​​Table[​​DeleteDuplicates[​​Flatten[{StringReplace[Flatten[#],{"(ν)"->"ν","(σ)"->"σ"}],StringReplace[Flatten[#],{"(ν)"->"","(σ)"->""}]}]&/@Values[association1][[i]]],{i,3}];
The keys stay the same.
In[]:=
replacedKeys={"Εν.","Δυ.","Πλ."};
Making the final association (finalPluralityAssociation).
In[]:=
verbEndingsAssociation=​​AssociationThread[replacedKeys,replacedValues];
Looks so cool!
In[]:=
verbEndingsAssociation//Dataset
Out[]=
Εν.
{ω,ω,οιμι,ε,ω,ω,οιμι,ε}
{
…
36
}
{α,ω,αιμι,ον,α,ω,αιμι,ον}
{
…
36
}
{ον,ω,οιμι,ε,ον,ω,οιμι,ε}
29 total ›
Δυ.
{ετον,ητον,οιτον,ετον,ετον,ητον,οιτον,ετον}
{
…
24
}
{ατον,ητον,αιτον,ατον,ατον,ητον,αιτον,ατον}
{
…
24
}
{
…
24
}
28 total ›
Πλ.
{ομεν,ωμεν,οιμεν,ετε,ομεν,ωμεν,οιμεν,ετε}
{
…
36
}
{αμεν,ωμεν,αιμεν,ατε,αμεν,ωμεν,αιμεν,ατε}
{
…
36
}
{
…
36
}
28 total ›
Assigning the verbs to stem verbs while deleting their endings to get only the stem.
In[]:=
stemverbs=Union[StringReplace[cleanedverbs,"ίζω"->"","ύζω"->"","άζω"->"","ώμαι"->"","ομαι"->"","ῶ"->"","ω"->"","έω"->"","ίζομαι"->"","ίζωμαι"->""]];

Participle and Infinitive


Nouns


Articles


Linkers


A glimpse into ancient Greek grammar and syntax

Only the parts needed to understand the rest of this essay will be explained, as one could go on forever explaining this subject.

Verbs

To classify verbs, checking whether the endings correspond to verbs was the logical way to go. However, there was interfering with the endings of nouns. Which meant that nouns were classified as verbs and verbs as nouns. What I came up with, was checking their stem. This made the situation a lot better but the verbs were still getting confused with names. I have not yet fixed this.
​
Important information about verbs in ancient Greek is that, there can only be one in a sentence. Sentences are therefore not separated only with the full stop. This is why, in my code I have it pre-determined that the verb is one. I will not explain how sentences are separated in detail, as I am only analysing the syntax of one in this project.
​
Another classification for verbs was their number. The Εν.(singular) keys in the association are for the singular and the Δυ.(dual) and Πλ.(plural) are for plural endings. This was used to determine the subject.

Nouns and subject

To begin with, there are three categories in which nouns are conjugated . The first one consists of nouns that end in - η (ς), -α (ς) like ποιητ - ής (poet) . The second one, consists of nouns ending in - ος, -ον such as θε - ὸς (god) . And finally, the biggest and most irregular category includes nouns like ἥρως (hero) . The only reason I made this distinction as well as the distinction between singular and plural and first person endings was to determine the subject​In order for a noun to qualify as an object it has to agree with the number of the verb and nominative. To make these tests more efficient, intersection between endings for singular number and plural as well as intersection between nominatives between categories had to be avoided. In fewer words, the only endings acceptable for the subject are those in agreement with the verb and it’s category’s nominative endings. ​Ok, part of that was not true. This rule is generally true, however there are some exceptions listed below.​1. If there is more than one subject and the verb is in plural, the subjects can be in either singular or plural.example: The dog are playing Tom and Anne are playing 2. If there are no noun in the sentence given, the subject is implied. (Verbs always have a subject)3. “Αττική Σύνταξη” this is harder to explain in English as it does not exist. But basically, when a gender nutural noun is in question, it can be in plural even if the verb is in singular.example: “τα παιδία παίζει”​From those, only the last one is actually an exception and I will not include it in this essay.​Another thing to take into consideration is that the subject can even be a sentence or infinitive. However those cases were not covered.

Participle and Infinitive

Those verb forms have different syntax. For example their subject does not have to be in nominative. Generally, syntax becomes more complicated.
If you would like to learn more about this topic click here

Pre-existing wolfram functions

Trying pre-existing wolfram functions

The sample text
Text Structure gives the grammatical structure of some text.
Actual syntax​
'Ως : a proposition that means when. Also means that the sentence talks about the time.
​δ΄: has no structural value. It is originally the word δε and the vowel is not pronounced because the next word starts with a vowel.
​εἰπὼν : i s participle that informs us about the time
​ταῦτα : the subject of εἰπὼν​
​ἐπαύσατο : is the verb
(Meaning: Once he said that, he stopped.)

Developing my own algorithm

A function that picks the largest ending for a given word.
A function that returns True or False when matching the largest ending from the previous function with the endings given.
A function that matches stems to the verbs. This pattern returns True as long as any part from stem verbs is inside a given word.
This is an important function that runs a set of tests to determine what part of speech a given word is. This is done purely from the grammatical structure of the word itself.
A function that outputs singular if the ending of the verb is singular and plural if it is in plural.
A function that gives the category of a noun, also based on it's ending.
The two following function check whether a noun is in nominative. Specifically, based on the number of the verb and the kind of declension the noun belongs in.
For singular endings.
For plural endings.
The three following function show the conditions that have to be met for a noun to be classified as a subject.
If the verb is in singular.
If the verb is in plural and there is only one noun in the sentence.
If the verb is in plural and there is more than one noun in the sentence.
This is the main function of this process. It extracts all the different elements generated from the function checkElements. Then it uses the three functions above for every case. This is the only point where the elements are classified based on those around them. It makes the process much more complicated but it is exactly what syntax is about.
Creates an association with the parts of speech of a given sentence. Then displays the assigned parts of speech as labels.
Example of the process above.
(Meaning: The embassador sent the Spartan leaders)

Future Work

This particular subject has much room for future work. Complicated syntax structures can be further explored. For example, finding the object, adjectives, syntax with participle and infinitive, splitting sentences and much more. Furthermore, the data could be more complete and categorised better. I wish I could have dug deeper into the sentence structure, but this always means that I have something to do with my time if I'm bored!

Conclusion

I hope this was an informative essay and the Greek was not too scary. Special thanks to my mentor Carolyn CJ Applebaum and Sophie, who were really helpful in my writing this project.

Citations

Wolfram Research (2015), TextStructure, Wolfram Language function, https://reference.wolfram.com/language/ref/TextStructure.html (updated 2019) .
Bodoh, J . (n . d .) . Ψηφίδες για την ελληνική γλώσσα . Κατάλογος ρηματικών τύπων της Αρχαίας Ελληνικής του John J . Bodoh . https://www.greek-language.gr/digitalResources/ancient_greek/tools/verb_forms/annex.html
ΑΡΧΑΙΑ ΕΛΛΗΝΙΚΗ ΓΛΩΣΣΑ. Η α’ κλίση στα αρχαία ελληνικά. (n.d.). https://users.sch.gr/ipap/Ellinikos%20Politismos/Yliko/Theoria%20arxaia/a.klisi.oys.htm
Οι σύνδεσμοι της αρχαίας ελληνικής γλώσσας. Φιλολογικό Πούλιος. (2019, January 19). https://kpoulios.gr/protinomena-themata/gimnasio/a-gimnasiou/archea-elliniki-glossa-a-gimnasiou/i-sindesmi-tis-archeas-ellinikis-gl/
Rita, Maria, Ναντια Μαλεσκου, Μαρια, & amp; Papadopoulou, M . P . (2018, January 7) . Ουσιαστικά α΄ β΄ και γ΄ κλίσης . φιλολογικό γυμνάσιο . https://filologikogymn.wordpress.com/

CITE THIS NOTEBOOK

Analysing ancient Greek syntax​
by Danae Dresiou​
Wolfram Community, STAFF PICKS, July 13, 2023
​https://community.wolfram.com/groups/-/m/t/2963294