Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Final assignment #3

Open
wants to merge 47 commits into
base: sybille
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5e80120
update README
Sib007 May 2, 2023
ba16fa4
update tutorial
Sib007 May 2, 2023
793b45a
Update README.md
Sib007 May 2, 2023
6da366e
update README
Sib007 May 8, 2023
47df909
Update README.md
Sib007 May 8, 2023
12a3cad
Add files via upload
Sib007 May 8, 2023
229d6db
Update README.md
Sib007 May 9, 2023
d473471
Update README.md
Sib007 May 9, 2023
3612e11
Add files via upload
Sib007 May 19, 2023
e2ee48c
Add files via upload
Sib007 May 19, 2023
7d8cefc
Add files via upload
Sib007 May 19, 2023
cda27d5
Presentation 23-05
Sib007 May 22, 2023
b75a20c
Cleaning up repository
Sib007 Jun 2, 2023
dac993f
Cleaning up repository
Sib007 Jun 2, 2023
766d863
Cleaning up repository
Sib007 Jun 2, 2023
ab372aa
Cleaning up repository
Sib007 Jun 2, 2023
94eb734
Cleaning up repository
Sib007 Jun 2, 2023
13698b7
Cleaning up repository
Sib007 Jun 2, 2023
d27a617
first script final assignment
Sib007 Jun 2, 2023
4fd92f9
update translator, revisor and status validation
Sib007 Jun 2, 2023
fdca814
adding argparse to the script, attempt 1
Sib007 Jun 2, 2023
183b52d
adding the TM generator tool
Sib007 Jun 2, 2023
69f30d7
revisor -> reviewer, internal lowercase
Sib007 Jun 3, 2023
c715751
Adding a Freelancer class, attempt 1
Sib007 Jun 3, 2023
db81406
update argparse
Sib007 Jun 11, 2023
bd0cc63
solving conflicts
Sib007 Jun 11, 2023
18e955f
arguments separate lines
Sib007 Jun 11, 2023
7a46a5a
print variables argparse
Sib007 Jun 11, 2023
0fcf15e
validation start and deadline
Sib007 Jun 11, 2023
9fbb7dd
Linking classes, attempt 2
Sib007 Jun 12, 2023
a0331e9
Deleting presentation files
Sib007 Jun 18, 2023
aca8780
Deleting presentation files
Sib007 Jun 18, 2023
27ff0d1
Deleting presentation files
Sib007 Jun 18, 2023
fefca57
Deleting presentation files
Sib007 Jun 18, 2023
9744a1d
Deleting presentation files
Sib007 Jun 18, 2023
f6b241f
Deleting presentation files
Sib007 Jun 18, 2023
09fa561
Deleting draft files
Sib007 Jun 18, 2023
3d7b0d4
Deleting draft files
Sib007 Jun 18, 2023
9b84b9c
Deleting draft files
Sib007 Jun 18, 2023
f09dee4
Deleting draft files
Sib007 Jun 18, 2023
58f2ff7
Deleting draft files
Sib007 Jun 18, 2023
39285c5
Deleting draft files
Sib007 Jun 18, 2023
4ea8c53
Deleting draft files
Sib007 Jun 18, 2023
c9c4048
Deleting draft files
Sib007 Jun 18, 2023
d062efd
Deleting draft files
Sib007 Jun 18, 2023
f0d258b
Uploading final files
Sib007 Jun 18, 2023
dabaa07
Deleting superfluous file
Sib007 Jun 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
802 changes: 802 additions & 0 deletions Demo-notebook.ipynb

Large diffs are not rendered by default.

259 changes: 259 additions & 0 deletions Final-assignment_trial-and-error.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "cf98a968",
"metadata": {},
"outputs": [],
"source": [
"import datetime #datetime package to convert strings into dates, calculate time periods etc."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "ffae2adb",
"metadata": {},
"outputs": [],
"source": [
"class Translation:\n",
" translator = \"Internal\" # class attribute\n",
" revisor = \"Internal\"\n",
" status = \"created\"\n",
"\n",
" def _is_valid_status(self, status):\n",
" if not status.lower() in [\"created\",\n",
" \"in translation\",\n",
" \"in revision\",\n",
" \"delivered\",\n",
" \"delayed\",\n",
" \"cancelled\",\n",
" \"canceled\"]:\n",
" return \"Please pick a status from the workflow: created, in translation, in revision, delivered, delayed or cancelled.\"\n",
"\n",
" def __init__(self, title, client, source, target, words, start, deadline, price, tm, domain = ''):\n",
" # 'self' represents the object (= class element) itself\n",
" self.title = title\n",
" self.client = client\n",
" self.source = source\n",
" self.target = target\n",
" self.words = words\n",
" self.start = start\n",
" self.deadline = deadline\n",
" self.price = price\n",
" self.tm = tm\n",
" self.domain = domain\n",
" \n",
" today = datetime.date.today() # current date\n",
" self.st = datetime.date.fromisoformat(start) # turns string into date\n",
" self.dl = datetime.date.fromisoformat(deadline) # turns string into date\n",
" self.daysleft = self.dl - today # difference between deadline and current date\n",
" self.length = self.dl - self.st # difference between deadline and start date\n",
" self.rate = self.price/self.words # word rate (price divided by word count)\n",
" self.efficiency = words/self.length.days # words to translate per day (word count divided by project length, see 'length' in explanations above)\n",
"\n",
" def days_left(self):\n",
" # prints a text indicating how many days are left until the project deadline\n",
" if self.dl < datetime.date.today():\n",
" # if the deadline is in the past\n",
" return f\"The deadline has been exceeded already.\"\n",
" else:\n",
" # if the deadline is not in the past\n",
" return f\"There are {self.daysleft.days} days left until the deadline.\"\n",
" \n",
" def length(self):\n",
" return f\"{self.length.days} days\"\n",
" \n",
" def __str__(self):\n",
" # defines the print behaviour: returns a text providing the main information about the project\n",
" sent_1 = f\"{self.title} is a translation for {self.client} from {self.source} into {self.target}.\"\n",
" if self.translator == \"Internal\" and self.revisor == \"Internal\":\n",
" sent_2 = f\"Both the translator and the revisor are agency collaborators.\"\n",
" elif self.translator == \"Internal\" and self.revisor != \"Internal\":\n",
" sent_2 = f\"The translator is an agency collaborator and the revisor is {self.revisor}.\"\n",
" elif self.translator != \"Internal\" and self.revisor == \"Internal\":\n",
" sent_2 = f\"The translator is {self.translator} and the revisor is an agency collaborator.\"\n",
" else:\n",
" sent_2 = f\"The translator is {self.translator} and the revisor is {self.revisor}.\"\n",
" # this if-statement considers whether a domain was added\n",
" if len(self.domain) > 0:\n",
" sent_3 = f\"The domain is: {self.domain}.\"\n",
" else:\n",
" sent_3 = \"The domain is unspecified.\" # if no domain was added, the text mentions it\n",
" sent_4 = f\"It's {self.words} words long, with a rate of {round(self.rate, 2)} € per word.\" #the word rate is rounded to two decimal places to avoid cumbersomely long numbers\n",
" # this if-statement considers whether the deadline is in the past\n",
" if self.dl < datetime.date.today():\n",
" sent_5 = f\"It started on {self.st} and was due on {self.dl}, so {self.length.days} days were foreseen for it. To meet the deadline, {round(self.efficiency)} words needed to be translated or revised per day.\" # the efficiency is rounded to units because you can't translate a fraction of a word anyway\n",
" else:\n",
" sent_5 = f\"It started on {self.st} and is due on {self.dl}, so {self.length.days} days are foreseen for it, of which {self.daysleft.days} left. To meet the deadline, {round(self.efficiency)} words need to be translated or revised per day.\"\n",
" # this if-statement considers whether there is a translation memory for the project\n",
" if self.tm is True:\n",
" sent_6 = f\"There is a translation memory.\"\n",
" else:\n",
" sent_6 = f\"There is no translation memory\"\n",
" sent_7 = f\"The project is currently {self.status}.\"\n",
" # print each sentence in a different line\n",
" return \"\\n\".join([sent_1, sent_2, sent_3, sent_4, sent_5, sent_6, sent_7])"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "086c20b8",
"metadata": {},
"outputs": [],
"source": [
"test = Translation('Guide de Bruxelles', 'Foodies', 'NL', 'FR', 11500, '2023-03-22', '2023-05-06', 1610, False)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "a342339f",
"metadata": {},
"outputs": [],
"source": [
"test.status = \"in translation\""
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "1334e6a5",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'ongoing'"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"test.status"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "f308ff5a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Please pick a status from the workflow: created, in translation, in revision, delivered, delayed or cancelled.'"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"test._is_valid_status(\"ongoing\")"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "e7262ea0",
"metadata": {},
"outputs": [
{
"ename": "TypeError",
"evalue": "'datetime.timedelta' object is not callable",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[22], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mtest\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlength\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
"\u001b[0;31mTypeError\u001b[0m: 'datetime.timedelta' object is not callable"
]
}
],
"source": [
"test.length()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "8a4974ea",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Guide de Bruxelles is a translation for Foodies from NL into FR.\n",
"Both the translator and the revisor are agency collaborators.\n",
"The domain is unspecified.\n",
"It's 11500 words long, with a rate of 0.14 € per word.\n",
"It started on 2023-03-22 and was due on 2023-05-06, so 45 days were foreseen for it. To meet the deadline, 256 words needed to be translated or revised per day.\n",
"There is no translation memory\n",
"The project is currently in translation.\n"
]
}
],
"source": [
"print(test)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "3f06d6c4",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'2023-03-22'"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"test.start"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4c9e596c",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading