MCPcopy Index your code
hub / github.com/pytorch/tutorials / readVocs

Function readVocs

beginner_source/chatbot_tutorial.py:348–356  ·  view source on GitHub ↗
(datafile, corpus_name)

Source from the content-addressed store, hash-verified

346
347# Read query/response pairs and return a voc object
348def 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
359def filterPair(p):

Callers 1

loadPrepareDataFunction · 0.85

Calls 2

VocClass · 0.85
normalizeStringFunction · 0.70

Tested by

no test coverage detected