Skip to content
Snippets Groups Projects

Sc 160/private calls and bugs cleanup

Merged Haak, R. (Romeo) requested to merge SC-160/private_calls_and_bugs_cleanup into master
6 files
+ 73
67
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 41
56
@@ -243,57 +243,36 @@ class Controller:
self._view.display_review(task_names)
def _select_review(self):
""""Select an item from the tree structure in the review window."""
tree = self._view._review._elements['tree']
x = tree.selection()
try:
source, onset_src, shadow, onset_shd, mistake, review = \
tree.item(x)['values']
new_review = self._view._review._elements['mistake_box'].get()
newvals = (source, onset_src, shadow, onset_shd, mistake, new_review)
if x:
tree.item(x, values=newvals)
except ValueError:
pass
"""Change mistake in Treeview"""
tree = self._view.review.elements['tree']
items = tree.selection()
for x in items:
try:
source, onset_src, shadow, onset_shd, mistake, review = \
tree.item(x)['values']
new_review = self._view.review.elements['mistake_box'].get()
newvals = (source,
onset_src,
shadow,
onset_shd,
mistake,
new_review)
if x:
tree.item(x, values=newvals)
except ValueError:
pass
def retrieve_participants(self, entry):
"""Get the list of participants from the model.
"""Get all shadow tasks corresponding to
participant/condition/video code.
Args:
entry: a String object denoting a data entry
entry: the participant/condition/video code
Returns:
participants: A list of String objects, denoting the participants
in an entry
participants: all shadow tasks corresponding to the code.
"""
"""Change mistake in Treeview"""
tree = self._view._review._elements['tree']
selection = tree.selection()
mistake_string = self._view._review._elements['mistake_box'].get()
new_mistake = None
# Mistakes retrieved from Treeview are strings, therefore:
for m in Mistake:
if mistake_string.lower() == m.value:
new_mistake = m
# Change into selected mistake
for item in selection:
source, onset_src, shadow, onset_shd, mistake, review = tree.item(item)['values']
newvals = (source, onset_src, shadow, onset_shd, mistake, new_mistake.name)
tree.item(item, values=newvals)
def retrieve_participants(self, entry):
"""Get all shadow tasks corresponding to participant/condition/video
code.
Args:
entry: the participant/condition/video code
Returns:
participants: all shadow tasks corresponding to the code. """
participants = []
for m in self._model._shadow_tasks:
for m in self._model.shadow_tasks:
if m.participant+"_"+m.condition+m.video == entry:
participants.append(m)
return participants
@@ -301,19 +280,19 @@ class Controller:
def reset_participants(self, participants):
"""Update mistake information according to reviewed mistakes
by recalculating accuracy"""
for m in self._model._shadow_tasks:
for m in self._model.shadow_tasks:
for p in participants:
if m.participant+"_"+m.condition+m.video ==\
p.participant+"_"+p.condition+p.video:
p.results = \
self._model._stats._mistake_counter.\
self._model.stats.mistake_counter.\
calculate_accuracy(p.source, p.shadow)
def insert_participants(self):
"""Insert all shadow tasks/mistakes into the Treeview"""
# Retrieve some necessary values
tree = self._view._review._elements['tree']
entries = self._view._review._entries
tree = self._view.review.elements['tree']
entries = self._view.review.entries
counter = 1
# Insert shadow tasks into the tree
@@ -322,8 +301,8 @@ class Controller:
parts = self.retrieve_participants(e)
for participant in parts:
# Handle source words
for s in participant._source:
if s.shadow is not None and s.mistake is not None:
for s in participant.source:
if s.mistake is not None:
source = s.word
onset_src = round(s.onset, 3)
# Add to tree
@@ -366,8 +345,8 @@ class Controller:
def save_review(self):
"""Change internal data structure to reviewed mistake"""
# Retrieve some necessary values
tree = self._view._review._elements['tree']
entries = self._view._review._entries
tree = self._view.review.elements['tree']
entries = self._view.review.entries
changed = []
# Retrieve string mistake values from tree
@@ -382,7 +361,11 @@ class Controller:
# Mistakes are strings, therefore:
if new_mistake.lower() == m.value:
mistake = m
changed.append([src, onset, shd, onset_shd, mistake])
changed.append([src,
onset,
shd,
onset_shd,
mistake])
parts = self.retrieve_participants(e)
@@ -391,7 +374,8 @@ class Controller:
for s in participant.source:
for c in changed:
if s.word == c[0] and round(s.onset, 3) == float(c[1])\
and (s.shadow is None) and c[2] == "NA":
and (s.shadow is None) \
and c[2] == "NA":
new_mistake = c[4]
# Source mistakes cannot be random
if new_mistake == Mistake.RANDOM:
@@ -420,7 +404,8 @@ class Controller:
elif s.source is not None:
if s.word == c[2] and s.source.word == c[0] \
and round(s.onset, 3) == float(c[3]):
and round(s.onset, 3) \
== float(c[3]):
new_mistake = c[4]
# Mistakes for shadow words cannot be
# skipped, as shadows are not source words
@@ -444,4 +429,4 @@ class Controller:
# Really change internal data structure
self.reset_participants(parts)
self._view._review.update_message('review saved')
self._view.review.update_message('review saved')
Loading