-
Notifications
You must be signed in to change notification settings - Fork 84
/
speech_lex_review.py
executable file
·71 lines (50 loc) · 1.61 KB
/
speech_lex_review.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2013, 2014, 2016, 2017 Guenter Bartsch
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# pick 20 lex entries where sequitur disagrees at random
#
import os
import sys
import logging
import traceback
import locale
import codecs
import random
from optparse import OptionParser
from nltools import misc
LANG = 'de'
INPUTFILE = 'data/dst/speech/%s/sequitur/model-6-all.test' % LANG
NUM_TOKENS = 20
logging.basicConfig(level=logging.DEBUG)
# logging.basicConfig(level=logging.INFO)
random.seed()
with codecs.open(INPUTFILE, 'r', 'utf8', 'ignore') as inf :
tokens = []
for line in inf:
if not 'errors)' in line:
continue
if '(0 errors)' in line:
continue
token = line.split('\t')[0]
tokens.append(token)
picked = set()
while len(picked) < NUM_TOKENS:
picked.add(tokens[random.randint(0, len(tokens)-1)])
for token in sorted(picked):
print token.encode('utf8'),