Sort your training sentences


#1

With lot of training sentences in your intent, adding some over time, it become hard to know if you ever add same one, have some like the new one, etc.

Here is a little hack to get your training sorted alphabetically in your intent.

You first need a working python environement.

Create a folder with three files:

  • sentences.txt
  • sentencesOrdered.txt
  • sentenceSorter.py

Then:

  • On your intent, export training sentence, ctrlA+ctrlC
  • Past them in sentences.txt
  • Run the python script
  • ctrlA+ctrlC sentencesOrdered.txt
  • On the console, delete all training sentences, import, ctrlV

Here is the python script:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys, os
import io

with io.open('sentences.txt', 'rt', newline='') as f:
    sentences = f.readlines()

sentences.sort()

newFile = ''
for sent in sentences:
	sent = sent.replace("\r\n", "\n")
	newFile += sent

open('sentencesOrdered.txt', 'w').write(newFile)

:kissing_smiling_eyes:


#2

This functionality will be part of an upcoming console release, coming soon. :slight_smile:

(I realise your post is about a workaround, but as soon as we add support for this in the console itself, it won’t be needed anymore)


#3

Thanks, actualy I make the job with openoffice and many copy paste and export import …


#4

No problem, just a workaround.

Sorting dynamically in the console would be a lot better of course. alpha, counter alpha, pet slot etc…