data_loader.py
def _create_examples(self, texts, intents, slots, set_type):
        """Creates examples for the training and dev sets."""
        examples = []
        for i, (text, intent, slot) in enumerate(zip(texts, intents, slots)):
            guid = "%s-%s" % (set_type, i)
            # 1. input_text
            words = text.split()  # Some are spaced twice
            # 2. intent
            intent_label = self.intent_labels.index(intent) if intent in self.intent_labels else self.intent_labels.index("UNK")
            # 3. slot
            slot_labels = []
            for s in slot.split():
                slot_labels.append(self.slot_labels.index(s) if s in self.slot_labels else self.slot_labels.index("UNK"))
            
            # identify if lengths are not the same
            if len(words) != len(slot_labels):              
                print("index:",i)                           
                print("len(words):",len(words))             
                print("len(slot_labels):",len(slot_labels)) 
                print("words:",words)                       
            assert len(words) == len(slot_labels)
            examples.append(InputExample(guid=guid, words=words, intent_label=intent_label, slot_labels=slot_labels))
        return examples
Creates examples for the training and dev sets.
Creates examples for the training and dev sets.
Creates examples for the training and dev sets .
def _create_examples(self, texts, intents, slots, set_type):
        examples = []
        for i, (text, intent, slot) in enumerate(zip(texts, intents, slots)):
            guid = "%s-%s" % (set_type, i)
            words = text.split()  
            intent_label = self.intent_labels.index(intent) if intent in self.intent_labels else self.intent_labels.index("UNK")
            slot_labels = []
            for s in slot.split():
                slot_labels.append(self.slot_labels.index(s) if s in self.slot_labels else self.slot_labels.index("UNK"))
            if len(words) != len(slot_labels):              
                print("index:",i)                           
                print("len(words):",len(words))             
                print("len(slot_labels):",len(slot_labels)) 
                print("words:",words)                       
            assert len(words) == len(slot_labels)
            examples.append(InputExample(guid=guid, words=words, intent_label=intent_label, slot_labels=slot_labels))
        return examples
def _create_examples ( self , texts , intents , slots , set_type ) : examples = [ ] for i , ( text , intent , slot ) in enumerate ( zip ( texts , intents , slots ) ) : guid = "%s-%s" % ( set_type , i ) words = text . split ( ) intent_label = self . intent_labels . index ( intent ) if intent in self . intent_labels else self . intent_labels . index ( "UNK" ) slot_labels = [ ] for s in slot . split ( ) : slot_labels . append ( self . slot_labels . index ( s ) if s in self . slot_labels else self . slot_labels . index ( "UNK" ) ) if len ( words ) != len ( slot_labels ) : print ( "index:" , i ) print ( "len(words):" , len ( words ) ) print ( "len(slot_labels):" , len ( slot_labels ) ) print ( "words:" , words ) assert len ( words ) == len ( slot_labels ) examples . append ( InputExample ( guid = guid , words = words , intent_label = intent_label , slot_labels = slot_labels ) ) return examples
Creates examples for the training and dev sets.
Creates examples for the training and dev sets .
"""Creates examples for the training and dev sets.""" # 1. input_text # Some are spaced twice # 2. intent # 3. slot # identify if lengths are not the same
self
texts
intents
slots
set_type