Skip to content

Commit

Permalink
Partial fix for #621
Browse files Browse the repository at this point in the history
Frequency counts and pronunciation variants are now correct for each
discourse. However, the "all speakers" window is not showing any
pronunciation variants.
  • Loading branch information
jsmackie committed Nov 29, 2016
1 parent 1cfc102 commit 3d46f5e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions corpustools/corpus/classes/lexicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,7 @@ def __iadd__(self, other):
setattr(sw, a.name, getattr(w, a.name))
sw.wordtokens += w.wordtokens
except KeyError:
self.add_word(w)
self.add_word(copy.copy(w))
if self.specifier is None and other.specifier is not None:
self.set_feature_matrix(other.specifier)

Expand Down Expand Up @@ -2767,7 +2767,7 @@ def find(self, word, ignore_case = False):
except KeyError:
try:
key = '{} (1)'.format(w)
result = [self.wordlist[key]]
result = self.wordlist[key]
return result
except KeyError:
pass
Expand Down
6 changes: 5 additions & 1 deletion corpustools/corpus/classes/spontaneous.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from .lexicon import Transcription, Corpus, Attribute, Word
import os
import wave
import traceback
import random

class Speaker(object):
"""
Expand Down Expand Up @@ -158,6 +158,10 @@ def __init__(self, kwargs):
self.lexicon = Corpus(self.name + ' lexicon')
self.lexicon.has_wordtokens = True

def random_word(self):
word = random.choice(list(self.words.keys()))
return self.words[word]

@property
def attributes(self):
#return [a for a in self._attributes if not a.name in ('spelling', 'transcription')]
Expand Down
1 change: 1 addition & 0 deletions corpustools/corpus/io/textgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ def load_directory_textgrid(corpus_name, path, annotation_types,
stop_check=stop_check,
call_back=call_back)
corpus.add_discourse(d)

if feature_system_path is not None:
feature_matrix = load_binary(feature_system_path)
corpus.lexicon.set_feature_matrix(feature_matrix)
Expand Down
8 changes: 3 additions & 5 deletions corpustools/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,14 @@ def loadCorpus(self):
self.corpus = dialog.corpus
self.inventoryModel = None
if hasattr(self.corpus, 'lexicon'):
# the lexicon attribute is a Corpus object
self.corpus.lexicon = self.compatibility_check(self.corpus.lexicon)
#the lexicon attribute is a Corpus object
if not hasattr(self.corpus.lexicon,'_version') or not self.corpus.lexicon._version == currentPCTversion:
self.corpus.lexicon = self.forceUpdate(self.corpus.lexicon)
# if not hasattr(self.corpus.lexicon,'_version') or not self.corpus.lexicon._version == currentPCTversion:
# self.corpus.lexicon = self.forceUpdate(self.corpus.lexicon)

if hasattr(self.corpus,'discourses'):
self.discourseTree.show()
self.discourseTree.setModel(SpontaneousSpeechCorpusModel(self.corpus))
# self.discourseTree.selectionModel().selectionChanged.connect(self.changeText)
# self.discourseTree.selectionModel().selectionChanged.connect(self.changeLexicon)
self.discourseTree.selectionModel().selectionChanged.connect(self.changeTextAndLexicon)
self.showDiscoursesAct.setEnabled(True)
self.showDiscoursesAct.setChecked(True)
Expand Down

0 comments on commit 3d46f5e

Please sign in to comment.