예제 #1
0
 def answer(self, layer):
     """
     Creates an answer for a what is structure code question
     :param structureCode: structure code, that the client wants to know about
     :return: answer about the structure unit
     """
     json = oisStructuralUnits.getStructuralUnit(
         layer[wt.structureUnitCode][0])
     return "Antud koodi kasutab struktuuriüksus: " + json["name"][
         "et"] + "."
예제 #2
0
 def answer(self, layer):
     """
     Creates answer for email question
     :param structUnits: asked structuralunits
     :return: structuralunits email
     """
     results = []
     structUnits = layer[wt.structureUnitCode]
     for id in structUnits:
         json = oisStructuralUnits.getStructuralUnit(id)
         name = json['name']['et'].split(" ")
         name[-1] = synthesize(name[-1], 'sg g')[0]
         results.append(" ".join(name).capitalize() + "(" + json['code'] +
                        ")" + " email on " + json['email'])
     return "\n".join(results) + "."
예제 #3
0
    def answer(self, layer):
        """
        finds and gives possible links as an answer to the asked question
        :param Layer: Current frame layer
        :return: Structure unit websites
        """
        possibleLinks = set()
        linkMap = {}
        StructUnits = layer[wt.structureUnitCode]
        for unit in StructUnits:
            json = oisStructuralUnits.getStructuralUnit(unit)
            if "webpage_url" in json:
                link = json["webpage_url"]
                if link not in possibleLinks:
                    possibleLinks.add(link)
                    linkMap[json["name"]["et"]] = link

        if len(possibleLinks) == 0:
            return "Sain küsimusest valesti aru või küsitud struktuuriüksusel ei ole veebilehte."
        elif len(possibleLinks) == 1:
            return "Selle struktuuriüksuse veebileht asub aadressil " + linkMap.popitem(
            )[1]
        return "Leidsin mitu erinevat veebilehte. Need on: " + ', '.join(
            possibleLinks)