Guide to Project for Supervisors ITECH1400 Fundamentals of Programming CRICOS Provider No. 00103D Assignment 1, XXXXXXXXXXPage 1 of 6 Assignment 1 – Sonnets and Doublets Overview In this assignment...

1 answer below »
Fondations of programming


Guide to Project for Supervisors ITECH1400 Fundamentals of Programming CRICOS Provider No. 00103D Assignment 1, 2019-17 Page 1 of 6 Assignment 1 – Sonnets and Doublets Overview In this assignment you will have the opportunity to test your Python skills in exploring and manipulating text. Throughout the assignment you are expected to apply the principles of problem solving that we have already discussed in this course. Timelines and Expectations Percentage Value of Task: 20% Due: 5 pm Friday, 30 August 2019 (week 7) Minimum time expectation: 20 hours Learning Outcomes Assessed The following course learning outcomes are assessed by completing this assessment: Knowledge: K1. Identify and use the correct syntax of a common programming language. K2. Recall and use typical programming constructs to design and implement simple software solutions. K4. Explain the importance of programming style concepts (documentation, mnemonic names, indentation). Skills: S1. Utilise pseudocode and/or algorithms as a major program design technique. S2. Write and implement a solution algorithm using basic programming constructs. S4. Describe program functionality based on analysis of given program code. Application of knowledge and skills: A1. Develop self-reliance and judgement in adapting algorithms to diverse contexts. A2. Design and write program solutions to identified problems using accepted design constructs. CRICOS Provider No. 00103D ITECH1400 Assig 1, Sem 2 2019 PARTNER.docx Page 2 of 6 Assessment Details Part 1 Sonnets - Background Sonnets are poems which have the following form1 (Shakespeare's sonnet 116): Let me not to the marriage of true minds (A) Admit impediments, love is not love (B) Which alters when it alteration finds, (A) Or bends with the remover to remove. (B) O no, it is an ever fixèd mark (C) That looks on tempests and is never shaken; (D) It is the star to every wand'ring bark, (C) Whose worth's unknown although his height be taken. (D) Love's not time's fool, though rosy lips and cheeks (E) Within his bending sickle's compass come, (F) Love alters not with his brief hours and weeks, (E) But bears it out even to the edge of doom: (F) If this be error and upon me proved, (G) I never writ, nor no man ever loved. (G) There are 3 quatrains (group of 4 lines) and a couplet (2 lines) making a total of 14 lines. The rhyming pattern is shown with the letters at the end of each line. Each line is in iambic pentameter2 (weak-strong). A standard line of iambic pentameter is five iambic feet in a row: da DUM da DUM da DUM da DUM da DUM but SOFT | what LIGHT | through YON | der WIN | dow BREAKS Shakespeare has written some 154 sonnets together with many plays – doubt (Craig & Kinney, 2009; Holmes & Kardos, 2003; James & Rubinstein, 2006; Jarmusch et al., 2013; Rubbo et al., 2008) exists as to whether, the person known to be called Shakespeare, was the actual author of all the work presented under this name. There is a considerable prize still to be claimed by anyone who can prove or disprove this3. 1 Adapted from: https://en.wikipedia.org/wiki/Sonnet#17th_century 2 For those of you who are curious about computers that can scan poetry there is an excellent text (with Python code): Hartman, C. O., & ProQuest (Firm). (1996). Virtual muse experiments in computer poetry. In Wesleyan poetry (pp. 152 p.). Retrieved from https://ebookcentral.proquest.com/lib/unimelb/detail.action?docID=776845 Connect to ebook (University of Melbourne only) 3 Calvin Hoffman Bequest: http://www.marlowe-society.org/the-hoffman-prize/ https://en.wikipedia.org/wiki/Sonnet_116 https://en.wikipedia.org/wiki/Sonnet#17th_century https://ebookcentral.proquest.com/lib/unimelb/detail.action?docID=776845 http://www.marlowe-society.org/the-hoffman-prize/ CRICOS Provider No. 00103D ITECH1400 Assig 1, Sem 2 2019 PARTNER.docx Page 3 of 6 Your Task – explore possible authorship Even though we have just become familiar with Python, there are three very simple tests that we can apply to authorship - and we have the means, with lists and strings in Python, to implement them: 1. Count the occurrences of each letter4 in the text. 2. Print the number of one-letter, two-letter, three-letter words and so on. 3. Print the number of occurrences of each different word in the text. The first pass might be to see if there is consistency across all the sonnets. Use the text from the sonnets and apply these three metrics. (We shall leave the actual plan and algorithm up to you – discuss it with your lecturer/tutor if you wish) Three possible authors who might have written under Shakespeare’s name are: Francis Bacon, Ben Jonson and Christopher Marlowe. Their works are readily available online. Part 2: Doublets Doublets (or word ladders) are often found in magazines and newspapers together with cryptic crosswords and other puzzles. The idea is very simple: you might be given two words – often they are antonyms – and your task is to create a ladder of words with these two words at the top and bottom of the ladder. For example: 4 You should find that the letter ‘e’ is the most common letter (There is a novel called ‘Gadsby’ https://www.gutenberg.org/ebooks/47342 It is a complete novel which does not have one single letter ‘e’ in it – yet, is quite readable.) HEAD HEAL TEAL TELL TALL TAIL https://www.gutenberg.org/ebooks/47342 CRICOS Provider No. 00103D ITECH1400 Assig 1, Sem 2 2019 PARTNER.docx Page 4 of 6 The aim is to make the number of words joining HEAD and TAIL as few as possible. In this assignment you are given a file5 of some 5700 words together with the pairs of words below (to use as a start and end); you are asked to use your Python skills to find the fewest words that will link them. Use the following pairs of words: i. FLOUR-BREAD ii. CHAOS-PEACE iii. TEARS-SMILE iv. WITCH-FAIRY v. BLACK-WHITE vi. SLEEP-DREAM vii. RIVER-SHORE Then, choose 3 different pairs of words from the file and use these as well. Submission You must supply your program source code files and your documentation as a single zip file named as follows:_.zip e.g. Aravind_ADIGA_30331237 You may supply your word processed documentation in either Microsoft Word or LibreOffice/OpenOffice formats only – no proprietary Mac specific formats, please. Assignments will be marked on the basis of fulfilment of the requirements and the quality of the work. In addition to the marking criteria, marks may be deducted for failure to comply with the assignment requirements, including (but not limited to): • Incomplete implementation(s), and • Incomplete submissions (e.g. missing files), and • Poor spelling and grammar. You might be asked to demonstrate and explain your work. 5 WordList.txt CRICOS Provider No. 00103D ITECH1400 Assig 1, Sem 2 2019 PARTNER.docx Page 5 of 6 Submit your assignment (all program source files plus your word processed document) to the Assignment 1 Upload location on Moodle before the deadline of Friday of week 7 at 5 pm. Marking Criteria/Rubric Sonnets Item Mark Algorithm in pseudo-code 10 Implementation of algorithm into Python code 10 Demonstration that code works correctly using representative samples 15 Correct Output and Discussion6 10 Doublets Algorithm in pseudo-code 10 Implementation of algorithm into Python code 10 Demonstration that code works correctly using representative samples 15 Correct Output and Discussion 10 Report7 10 TOTAL 100 FINAL MARK /20 6 Discussion means that you show that you follow the six steps of problem solving e.g. which possible solutions did you think of, which one did you choose and why, how did you implement it in Python and so on. 7 This link gives you the layout of the assignment: margins, fonts, how to label diagrams and so on as well as how to use references and the content of the report: abstract, introduction, conclusion and the like. https://federation.edu.au/current-students/learning-and-study/online-help-with/guides-to-your-assessments https://federation.edu.au/current-students/learning-and-study/online-help-with/guides-to-your-assessments CRICOS Provider No. 00103D ITECH1400 Assig 1, Sem 2 2019 PARTNER.docx Page 6 of 6 Feedback Feedback will be provided in lectures and labs as well as on Moodle Plagiarism: Plagiarism is the presentation of the expressed thought or work of another person as though it is one's own without properly acknowledging that person. You must not allow other students to copy your work and must take care to safeguard against this happening. More information about the plagiarism policy and procedure for the university can be found at http://federation.edu.au/students/learning-and- study/online-help-with/plagiarism. This is an INDIVIDUAL ASSIGNMENT – and while you may discuss it with your fellow students, you must not share designs or code or you will be in breach of the
Answered Same DayAug 28, 2021ITECH1400

Answer To: Guide to Project for Supervisors ITECH1400 Fundamentals of Programming CRICOS Provider No. 00103D...

Neha answered on Aug 29 2021
124 Votes
43796-fxfpd5gj/43796/1.Sonnet.py
# Count the occurrences of each letter in the text
with open("sonnets.txt") as f:
freqs = {}
for line in f:
for char in line:
if char in freqs:
freqs[char] += 1
else:
freqs[char] = 1
print ("The frequency of each letter in the poem is:")
print(freqs)
#to get one letter word, two letter word and so on in the file
def word_count(fname):
with open(fname) as f:
data = f.read()
return {x:[len([c for c in w ]) for w in data.split()].count(x) for
x in [len([c for c in w ]) for w in data.split()] }
print("Number of letters and thier corresponding number of words : ")
print(word_count("sonnets.txt"))

#to get total number of words available in the file
with open("sonnets.txt") as f:
data = f.read().splitlines()
f.close()
number_of_words=len(data)
print("Total number of words: " + str(number_of_words))
43796-fxfpd5gj/43796/2nd_question_word_ladder.py
#In this code we have to reach to the opposite of
#first word by using 1 word difference.
from __future__ import division
from collections import defaultdict
#this method is to find whether two words have only 1 letter difference
def one_letter_diff(w1, w2):
diff = 0
if len(w1) != len(w2): return False
for i in range(len(w1)):
if w1[i] != w2[i]: diff += 1
if diff > 1: return False
return diff == 1
# To solve this problem we have to build a graph. We need to
#find the shortest path using Dijkstra's algorithm.
#and then find whether it hae only one letter difference
def word_ladder(start, end, words):
links = defaultdict(list)
allwords = list(set(words) | set([start,end]))
n = len(allwords)
for i in range(n):
for j in range(i+1,n):
if one_letter_diff(allwords[i], allwords[j]):
links[allwords[i]].append(allwords[j])
links[allwords[j]].append(allwords[i])

print ('\n'.join([k+': '+str(v) for k,v in links.items()]))

# Dijkstra's algorithm
queue = set(allwords)
dist = dict((w, float('inf')) for w in allwords)
dist[start] = 0
prev = {}
while queue:
word = min(queue, key=lambda x:dist[x])
queue.remove(word)
if dist[word] == float('inf'): break
for w in links[word]:
alt_dist = dist[word] + 1
if alt_dist < dist[w]:
dist[w] = alt_dist
prev[w] = word
#distance between root and the word using vertex of trees
print (dist)
return dist[end]
### Find all transformation, but not necessarily shortest
def word_ladder_II1(start, end, words):
links = defaultdict(list)
allwords = list(set(words) | set([start,end]))
n = len(allwords)
for i in range(n):
for j in range(i+1,n):
if one_letter_diff(allwords[i], allwords[j]):
links[allwords[i]].append(allwords[j])
links[allwords[j]].append(allwords[i])
#print '\n'.join([k+': '+str(v) for k,v in links.items()])

for path in BFS(start, end, links, set()):
print [start] + path
def BFS(start, end, links, visited):
if start == end:
yield []
else:
for next in links[start]:
if next in visited: continue
for p in BFS(next, end, links, visited | set([next])):
yield [next] + p
# tTo find all the shortest transformation available
def word_ladder_II2(start, end, words):
links = defaultdict(list)
allwords = list(set(words) | set([start,end]))
n = len(allwords)
for i in range(n):
for j in range(i+1,n):
if one_letter_diff(allwords[i], allwords[j]):
links[allwords[i]].append(allwords[j])
links[allwords[j]].append(allwords[i])

dist = dict((w,float('inf')) for w in allwords)
dist[start] = 0

prev = dict((w,[]) for w in allwords)
queue = set(allwords)
while queue:
word = min(queue, key=lambda x:dist[x])
queue.remove(word)
for w in links[word]:
alt_dist = dist[word]+1
if alt_dist < dist[w]:
dist[w] = alt_dist
prev[w] = [word]
elif alt_dist == dist[w]: # key!
prev[w].append(word)

paths = [path+[end] for path in recover_paths(end, prev)]
print (paths[0])
return paths
def recover_paths(end, prev):
if len(prev[end]) == 0: yield []
else:
for word in prev[end]:
for prev_path in recover_paths(word, prev):
yield prev_path + [word]
#main function to call the method
if __name__ == '__main__':
with open("list.txt") as f:
data = f.read().splitlines()
f.close()
word_ladder_II2("flour", "bread", data)
word_ladder_II2("chaos", "peace", data)
word_ladder_II2("tears", "smile", data)
word_ladder_II2("sleep", "dream", data)
word_ladder_II2("river", "shore", data)

43796-fxfpd5gj/43796/Dobblets.docx
To build ladder of words with 1 letter difference
Open file
Read file
N=Len(all words)
For i in n
For j in range(i+1,n)
Find one letter difference
Len of word1 = len of word 2
For each character in words
If word1 and word 2 = difference(1)
Return true
Set all words in a queue
dist = dict((w, float('inf')) for w in allwords)
while queue:
word = min(queue, key=lambda x:dist[x])
queue.remove(word)
if dist[word] == float('inf'): break
for w in links[word]:
alt_dist = dist[word] + 1
if alt_dist < dist[w]:
dist[w] = alt_dist
prev[w] = word
print word
return
for word in previous
for previous path
yield previous path +...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here