コード例 #1
0
    def generate(self, references):

        references = form_choice.variation_bayes(references)

        references = sorted(references, key=lambda x: (x['sentence'], x['pos']))

        prev_references = []
        for reference in references:
            realization = self._realize(prev_references, reference).lower()
            reference['realization'] = realization
            prev_references.append(reference)

        return references
コード例 #2
0
ファイル: reg_main.py プロジェクト: cfh3c/NeuralREG
    def generate(self, references):

        references = form_choice.variation_bayes(references)

        references = sorted(references, key=lambda x: (x['sentence'], x['pos']))

        prev_references = []
        for reference in references:
            try:
                realization = self._realize(prev_references, reference).lower()
            except:
                realization = ' '.join(reference['entity'].replace('\'', '').replace('\"', '').split('_'))
            reference['realization'] = realization
            prev_references.append(reference)

        return references
コード例 #3
0
ファイル: reg_main.py プロジェクト: abevieiramota/CyberTiCC
    def generate(self, template, entitymap, topic=''):
        self.template = template.lower()
        self.entitymap = dict(map(lambda x: (x[0].lower(), x[1]), entitymap.items()))

        references = self._extract_references()
        references = form_choice.variation_bayes(references)

        references = sorted(references, key=lambda x: (x['sentence'], x['pos']))
        prev_references = []
        for reference in references:
            reference['realization'] = self._realize(prev_references, reference, topic).lower()
            prev_references.append(reference)

        for reference in references:
            template = template.replace(reference['tag'], unicode(reference['realization']), 1)

        return template