def test_span_overlap_fraction(self):
     # pylint: disable=protected-access
     utterance = self.tokenizer.tokenize("what is the name in english of mersin?")
     field = KnowledgeGraphField(self.graph, self.utterance, self.token_indexers, self.tokenizer)
     entity = 'fb:row.row.name_in_english'
     entity_text = field._entity_text_map[entity]
     feature_values = [field._span_overlap_fraction(entity, entity_text, token, i, utterance)
                       for i, token in enumerate(utterance)]
     assert feature_values == [0, 0, 0, 1, 2/3, 1/3, 0, 0, 0]
 def test_span_overlap_fraction(self):
     # pylint: disable=protected-access
     utterance = self.tokenizer.tokenize("what is the name in english of mersin?")
     field = KnowledgeGraphField(self.graph, self.utterance, self.token_indexers, self.tokenizer)
     entity = 'fb:row.row.name_in_english'
     entity_text = field._entity_text_map[entity]
     feature_values = [field._span_overlap_fraction(entity, entity_text, token, i, utterance)
                       for i, token in enumerate(utterance)]
     assert feature_values == [0, 0, 0, 1, 1, 1, 0, 0, 0]
    def test_span_overlap_fraction(self):

        utterance = self.tokenizer.tokenize(
            "what is the name in english of mersin?")
        field = KnowledgeGraphField(self.graph, self.utterance,
                                    self.token_indexers, self.tokenizer)
        entity = "string_column:name_in_english"
        entity_text = field._entity_text_map[entity]
        feature_values = [
            field._span_overlap_fraction(entity, entity_text, token, i,
                                         utterance)
            for i, token in enumerate(utterance)
        ]
        assert feature_values == [0, 0, 0, 1, 1, 1, 0, 0, 0]