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

Function extractSentencePairs

beginner_source/chatbot_tutorial.py:199–209  ·  view source on GitHub ↗
(conversations)

Source from the content-addressed store, hash-verified

197
198# Extracts pairs of sentences from conversations
199def extractSentencePairs(conversations):
200 qa_pairs = []
201 for conversation in conversations.values():
202 # Iterate over all the lines of the conversation
203 for i in range(len(conversation["lines"]) - 1): # We ignore the last line (no answer for it)
204 inputLine = conversation["lines"][i]["text"].strip()
205 targetLine = conversation["lines"][i+1]["text"].strip()
206 # Filter wrong samples (if one of the lists is empty)
207 if inputLine and targetLine:
208 qa_pairs.append([inputLine, targetLine])
209 return qa_pairs
210
211
212######################################################################

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected