0% found this document useful (0 votes)
25 views

Criterion C - Development

The document summarizes a computer science project that developed a Python application using Tkinter to scan Latin poetry. The application fills in missing macrons, organizes Latin text, and allows the user to save and retrieve texts. It contains 4 modules that interact - the primary module houses CSV file functions, secondary module is the parent, and other modules handle macronization and scanning logic. Data structures like arrays and CSV files are used. Key algorithms include Latin macronization using a text file of words, Latin scanning using meter rules, and saving text to a CSV file. Considerations are given for the GUI design to make the program easy to use.

Uploaded by

Farhan Mukit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Criterion C - Development

The document summarizes a computer science project that developed a Python application using Tkinter to scan Latin poetry. The application fills in missing macrons, organizes Latin text, and allows the user to save and retrieve texts. It contains 4 modules that interact - the primary module houses CSV file functions, secondary module is the parent, and other modules handle macronization and scanning logic. Data structures like arrays and CSV files are used. Key algorithms include Latin macronization using a text file of words, Latin scanning using meter rules, and saving text to a CSV file. Considerations are given for the GUI design to make the program easy to use.

Uploaded by

Farhan Mukit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Criterion C - Development

Introduction:

For my computer science IA project, I used the Python programming language, along
with the Tkinter library, to develop an application that would be able to seamlessly scan Latin
poetry for long/short vowels, fill in missing macrons in latin sentences, and save and organize
Latin text in a coherent manner. I used Tkinter to create the GUI for the application, along with
other libraries to allow for different features such as saving text.

The product was designed to help Mr.Chan create, organize, and distribute Latin Text
Packets for his students without having to go through the monotonous and time-consuming
tasks of macronizing and scanning each line himself.

Word Count: 109

Summary of All Techniques:

- Creation of Functions
- Use of parameters in functions
- For loop
- Nested Loops
- Searching
- Saving to a file
- GUI tabs
- GUI Windows
- Using CSV files
- Arrays
- Lists
- Use of pandas package (handles CSV)
- Opening file
- Making an array of objects
- Indexing
- Parsing through txt/string files
- Error Handling
- Dataframes
- Logical operators
- dataframes

Word Count: 0 (bulleted list)


Structure of the Program:

In this program, there are a total of 4 python modules that interact with each other, as
well as a large .txt file that acts as a library of all Latin words, which is essential to the
functioning of the program. The PrimaryUI module is the one that the user will run to begin using
the program and houses all functions to read, write (to), and interpret CSV files. The
SecondaryUI module is the parent module of the Dactylic and Macronizer modules. The Dactylic
module houses logic that is used for the function of scanning Latin texts. The Macronizer
module reads a .txt file of all Latin words, and accordingly uses user-input from SecondaryUI to
return output to Secondary UI. The SecondaryUI module feeds user-input into both and shows
the user the returned outputs in a Text Box within the first GUI page. Due to the nature of
imports in python, the first GUI the user will be presented with is the one housed in the
SecondaryUI module. I made use of the ability to import one’s own files in python (Just as you
would Tkinter or any other library) in order to facilitate useful relationships between the modules.
This includes inheriting functions, input data, output data, etc.

Word Count: 208

Data Structures Used:

Arrays:

For my program, Arrays are a primary component that is necessary for the processes of
many of the functions in my operative modules (Macronizer, Dactylic, Primary UI). The dynamic
and highly configurable nature of Arrays in Python through baked-in functions such as
.append(), .join(), del, .join(), etc, allow for the easy creation of return outputs from functions
without much friction. Furthermore, indexing proved to be an immensely valuable tool in the
creation of this program, both in GUI and logic creation. There was the consideration of using
dictionaries, however, the implementation of string values with dictionaries is not as fluid as it is
with the use of arrays.
* above are a couple of examples of the use of lists, which there are many more of in my
program

Reading and Writing to CSV:

CSV files are essential in how my line-saving feature functions. Due to the fact that
attributes of a Latin Poetry may include values such as Title, book number, line number, and so
on, CSV files allows the program to compartmentalize saved texts based upon those values and
allow for its easy retrieval in the case that the client may wish to use it again. The cell structure
and indexing properties of CSV files make this possible, in coherence with lists. I used the
Pandas import library (pd.) in python to read and write to CSV files.

*here we use the .loc[] function to create a new cell of data based on user input.

Word Count: 220

Key Algorithms:

This program can be divided into 3 components, Latin Scansion, Latin Macronization,
and Saving Texts.

Latin Macronization:

This algorithm will take a Latin text string from the user, and then output the same string
with the accurate long syllables marked via a macron (i.e, a to ā) These long syllables are often
not marked in online texts, due to the fact that macronized letters are special characters, which
is why this function is useful.
To achieve this, I employed the use of a large text file I found online that houses all Latin
words and their coinciding natural macrons. Natural macrons are inherent to each Latin word in
which they reside, and are relatively impossible to determine if not given a library of them.

The Macronizer function, housed under the Macronizer module, is divided into two parts,
find+replace, and formatting:

Find+ replace:

Line 1 - 3:

- The Function takes in the parameter ‘kj’, which in this scenario would be the user’s input
of a Latin sentence/text.
- The lists ‘scanned’ and ‘scan’ are also created so that an output can be built and
returned to the user.

Lines 5-10:

- A list, ‘words’, is created using the .split() function, which takes a string and splits it by a
parameter (by default it is ‘ ‘ (space), so no parameters were given). This allows the
input, kj, to be split into a list of words that can be operated upon.
- Our first ‘for loop’ is utilized, and is able to apply conditions to each word in the input.
The variable x is created as a hypothetical checkbox for a condition. (1 = yes, 0 = no)
- The if condition created checks if the word in loop ends in ’que’, a frequent conjunction
in Latin poetry, which may interfere with the process of finding that word in the text file. If
the condition is fulfilled, x = 1, and ‘que’ is removed from the word using .split().

Line 11-17:

- Open the library of Latin vocabulary using the open() function, set as variable
‘macronslist’.

*sample of formatting of the txt file, important for next operations, the file has a total of
812587 lines formatted in this manner. Vowels with an underscore next to them are ‘macronized’

- Use a for loop to iterate through each row of the txt file
- Split each row into separate words in a list using .split(), assign to linesplit variable.
- For each split row, use indexing to check:
- If the word is the same as the first word in the current column,
- The word is not already in the output list
- If conditions are fulfilled, it appends the fourth value of the row into the ‘scanned’ list.
- If the previous checkbox (x) = 1, add que back to the end of the new word to preserve
the sentence
- After all, words have been through this loop, take the final array, ‘scanned’, convert it to a
string, then assign it to the ‘unformatted’ variable.
Part 2:

This part seeks to take the unformatted string with the underscored (macronized) vowels and
replace them with the special characters with macrons.

Line 22-25:

- Formatted list created, this will be our output. List of vowels created, list of macronized
special characters created

Lines 26-49:
- Iterate through previously formed string ‘unformatted’ using for loop
- Iterate through each character of each word
- If the last character = ‘^’, delete the character
- If the last character is an underscore, check if the character before is is a vowel,
- If the 2nd to last character = ‘a’, delete the underscore from the list and replace ‘a’ with
‘ā’
- Repeat for all vowels.
- Return string of formatted list
Latin Scansion:

This code, housed under the Dactylic module, aims to correctly identify and assign long
and short syllables based upon the semi-standard rules of meter in Latin Poetry, particularly
those of Dactylic Hexameter. I used logical operands in conjunction with list indexing to achieve
this, with a for loop to iterate through the input parameter (x)
The details of Latin scansion are outside the scope of this document, however, a general
rulebook/cheatsheet can be found here:

http://www.thelatinlibrary.com/satire/scansion.pdf

I took these processes and applied them to the program with the python programming language
using loops and conditional statements, indexing the input letter by letter.

Saving texts:
I used Tkinter in accordance with the pandas import library to save outputs of either
scansion or macronizing functions to a CSV file alongside some defining attributes such as the
title of work, book number, line number, etc.

\
Function insertxt():
60-65:
- Retrieve all values from entry and Text Boxes
- Count rows for indexing purposes
67-72:
- Insert all of the data to the corresponding cells in the ‘texts’ dataframe
- Save ‘texts’ data frame into csv file: ‘latintexts.csv’

Function outputtxt():
75-80:
- Retrieve all values from tkinter entry and Text boxes
81-87:
- Iterate through all entries in the ‘texts’ dataframe using a for loop
- Check if all values given by user match any saved text
- If so, insert text into ‘showcase’ text box

Word Count: 1085

Considerations for User Interface:


The GUI was created in order to make the program easy-to-use for my client. For each
text field, there is a label above it to indicate what the user should input. Text boxes were used
for all inputs of latin to preserve the formatting of latin and to accommodate for larger passages
to be scanned.

* The ‘Save Line(s)’ button leads the user to the 2nd UI screen (on the right)
Word Count: 71
Software Tool Used:

To create the program I used the PyCharm Python IDE because of its ease of use with
libraries, imports, debugging tools, file navigation, and OOP.

Word Count: 25

You might also like