(datafile, corpus_name)
| 346 | |
| 347 | # Read query/response pairs and return a voc object |
| 348 | def readVocs(datafile, corpus_name): |
| 349 | print("Reading lines...") |
| 350 | # Read the file and split into lines |
| 351 | lines = open(datafile, encoding='utf-8').\ |
| 352 | read().strip().split('\n') |
| 353 | # Split every line into pairs and normalize |
| 354 | pairs = [[normalizeString(s) for s in l.split('\t')] for l in lines] |
| 355 | voc = Voc(corpus_name) |
| 356 | return voc, pairs |
| 357 | |
| 358 | # Returns True if both sentences in a pair 'p' are under the MAX_LENGTH threshold |
| 359 | def filterPair(p): |
no test coverage detected