| 197 | |
| 198 | # Extracts pairs of sentences from conversations |
| 199 | def 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 | ###################################################################### |