Ejemplo n.º 1
0
    def __init__(self, config):
        labeled_demos = [
            LabeledDemonstration.from_oracle_programs(
                [[
                    WeightedProgram(
                        ClickToken(LikeToken(FieldsValueSelectorToken(1))), 1)
                ],
                 [
                     WeightedProgram(
                         ClickToken(LikeToken(StringToken(u"Forward"))), 1)
                 ],
                 [
                     WeightedProgram(
                         FocusAndTypeToken(InputElementsToken(),
                                           FieldsValueSelectorToken(0)), 1)
                 ],
                 [WeightedProgram(ClickToken(LikeToken(StringToken(u""))), 1)]
                 ],  # TODO: Remove this hack
                "Find the email by Harmonia and forward that email to Eleanore.",
                Fields({
                    "by": "Harmonia",
                    "to": "Eleanore"
                }))
        ]

        super(EmailInboxForwardOracleProgramPolicy,
              self).__init__(labeled_demos, config)
Ejemplo n.º 2
0
    def __init__(self, config):
        labeled_demos = [
            LabeledDemonstration.from_oracle_programs(
                [[
                    WeightedProgram(
                        ClickToken(LikeToken(FieldsValueSelectorToken(1))), 1)
                ],
                 [
                     WeightedProgram(
                         ClickToken(LikeToken(StringToken(u"Reply"))), 1)
                 ],
                 [
                     WeightedProgram(
                         FocusAndTypeToken(InputElementsToken(),
                                           FieldsValueSelectorToken(0)), 1)
                 ],
                 [WeightedProgram(ClickToken(LikeToken(StringToken(u""))), 1)]
                 ],  # TODO: Remove this hack
                "Find the email by Harmonia and reply to them with the text \"hello\".",
                Fields({
                    "by": "Harmonia",
                    "message": "hello"
                }))
        ]

        super(EmailInboxReplyOracleProgramPolicy,
              self).__init__(labeled_demos, config)
Ejemplo n.º 3
0
    def __init__(self, config):
        labeled_demos = [
            LabeledDemonstration.from_oracle_programs([
                [
                    WeightedProgram(
                        FocusAndTypeToken(
                            NearToken(LikeToken(StringToken(u"Username"))),
                            UtteranceSelectorToken(4, 5)), 1)
                ],
                [
                    WeightedProgram(
                        FocusAndTypeToken(
                            NearToken(LikeToken(StringToken(u"Password"))),
                            UtteranceSelectorToken(10, 11)), 1)
                ],
                [
                    WeightedProgram(
                        ClickToken(LikeToken(StringToken(u"Login"))), 1)
                ]
            ], "Enter the username \"blah\" and the password \"blah\" into the text fields and press login.",
                                                      Fields({
                                                          "username": "******",
                                                          "password": "******"
                                                      }))
        ]

        super(LoginUserOracleProgramPolicy,
              self).__init__(labeled_demos, config)
Ejemplo n.º 4
0
    def __init__(self, config):
        # Appears on first page
        labeled_demos = [
            LabeledDemonstration.from_oracle_programs([[
                WeightedProgram(
                    ClickToken(LikeToken(UtteranceSelectorToken(12, 13))), 1)
            ]], "Switch between the tabs to find and click on the link \"x\".",
                                                      Fields({"target": "x"}))
        ]
        labeled_demos += [
            LabeledDemonstration.from_oracle_programs([[
                WeightedProgram(ClickToken(LikeToken(StringToken(u"Tab #2"))),
                                1)
            ]], "Switch between the tabs to find and click on the link \"x\".",
                                                      Fields({"target": "x"}))
        ]

        super(ClickTabMediumOracleProgramPolicy,
              self).__init__(labeled_demos, config)
Ejemplo n.º 5
0
    def __init__(self, config):
        labeled_demos = [
            LabeledDemonstration.from_oracle_programs([[
                WeightedProgram(
                    ClickToken(LikeToken(UtteranceSelectorToken(4, 5))), 1)
            ]], "Switch between the tabs to find and click on the link \"x\".",
                                                      Fields({"target": "x"}))
        ]

        super(ClickButtonOracleProgramPolicy,
              self).__init__(labeled_demos, config)
Ejemplo n.º 6
0
    def _sample_program(self, state, cursor):
        """Returns a WeightedProgram sampled at the current cursor. The program
        in the WeightedProgram may be None, indicating a skip action.

        Args:
            state (MiniWoBState): concrete state
            cursor (int): index of the current demo state
        Returns:
            WeightedProgram: If the WeightedProgram is None, no programs
            were available for sampling.
        """
        weighted_programs, probs = self._programs_and_probs(cursor)
        if not weighted_programs:  # No programs available for sampling.
            return WeightedProgram(TerminateToken(), 0.)

        weighted_program = np.random.choice(weighted_programs, p=probs)
        return weighted_program
Ejemplo n.º 7
0
    def __init__(self, config):
        submit = lambda: [
            WeightedProgram(ClickToken(LikeToken(StringToken(u"Submit"))), 1)
        ]
        check_field = lambda i: [
            WeightedProgram(
                ClickToken(SameRowToken(LikeToken(FieldsValueSelectorToken(i)))
                           ), 1)
        ]

        def demo(num_boxes, randomize_order):
            programs_sequence = [check_field(i + 1) for i in range(num_boxes)]

            if randomize_order:
                random.shuffle(programs_sequence)

            programs_sequence.append(submit())

            utt, fields = {
                0: ("Click nothing then submit", Fields({"button": "submit"})),
                1: ("Click a then submit",
                    Fields({
                        "target 0": "a",
                        "button": "submit"
                    })),
                2: ("Click a,b then submit",
                    Fields({
                        "target 0": "a",
                        "target 1": "b",
                        "button": "submit"
                    })),
                3: ("Click a,b,c then submit",
                    Fields({
                        "target 0": "a",
                        "target 1": "b",
                        "target 2": "c",
                        "button": "submit"
                    })),
                4: ("Click a,b,c,d then submit",
                    Fields({
                        "target 0": "a",
                        "target 1": "b",
                        "target 2": "c",
                        "target 3": "d",
                        "button": "submit"
                    })),
                5: ("Click a,b,c,d,e then submit",
                    Fields({
                        "target 0": "a",
                        "target 1": "b",
                        "target 2": "c",
                        "target 3": "d",
                        "target 4": "e",
                        "button": "submit"
                    })),
                6: ("Click a,b,c,d,e,f then submit",
                    Fields({
                        "target 0": "a",
                        "target 1": "b",
                        "target 2": "c",
                        "target 3": "d",
                        "target 4": "e",
                        "target 5": "f",
                        "button": "submit"
                    })),
            }[num_boxes]

            return LabeledDemonstration.from_oracle_programs(
                programs_sequence, utt, fields)

        # randomize = True
        # num_samples = 100
        randomize = False
        num_samples = 1

        labeled_demos = []
        for i in range(7):
            demos_for_i = [demo(i, randomize) for _ in range(num_samples)]
            labeled_demos.extend(demos_for_i)

        super(ClickCheckboxesOracle, self).__init__(labeled_demos, config)
Ejemplo n.º 8
0
    def __init__(self, config):
        labeled_demos = [
            # block
            LabeledDemonstration.from_oracle_programs(
                [
                    # More
                    [
                        WeightedProgram(
                            ClickToken(
                                NearToken(LikeToken(
                                    FieldsValueSelectorToken(1)),
                                          classes="more")), 1)
                    ],
                    # Block
                    [
                        WeightedProgram(
                            ClickToken(LikeToken(StringToken(u"Block"))), 1)
                    ]
                ],
                "For the user @jess, click on the \"Block\" button.",
                Fields({
                    "user": "******",
                    "button": "block"
                })),

            # reply
            LabeledDemonstration.from_oracle_programs(
                [
                    # reply
                    [
                        WeightedProgram(
                            ClickToken(
                                NearToken(LikeToken(
                                    FieldsValueSelectorToken(1)),
                                          classes="reply")), 1)
                    ],
                ],
                "For the user @jess, click on the \"Reply\" button.",
                Fields({
                    "user": "******",
                    "button": "reply"
                })),

            # like
            LabeledDemonstration.from_oracle_programs(
                [
                    # like
                    [
                        WeightedProgram(
                            ClickToken(
                                NearToken(LikeToken(
                                    FieldsValueSelectorToken(1)),
                                          classes="like")), 1)
                    ],
                ],
                "For the user @jess, click on the \"Like\" button.",
                Fields({
                    "user": "******",
                    "button": "like"
                })),

            # share via DM
            LabeledDemonstration.from_oracle_programs(
                [
                    # More
                    [
                        WeightedProgram(
                            ClickToken(
                                NearToken(LikeToken(
                                    FieldsValueSelectorToken(1)),
                                          classes="more")), 1)
                    ],
                    # share
                    [
                        WeightedProgram(
                            ClickToken(LikeToken(StringToken(u"share"))), 1)
                    ]
                ],
                "For the user @jess, click on the \"share\" button.",
                Fields({
                    "user": "******",
                    "button": "share"
                })),

            # copy
            LabeledDemonstration.from_oracle_programs(
                [
                    # More
                    [
                        WeightedProgram(
                            ClickToken(
                                NearToken(LikeToken(
                                    FieldsValueSelectorToken(1)),
                                          classes="more")), 1)
                    ],
                    # copy
                    [
                        WeightedProgram(
                            ClickToken(LikeToken(StringToken(u"copy"))), 1)
                    ]
                ],
                "For the user @jess, click on the \"Copy\" button.",
                Fields({
                    "user": "******",
                    "button": "copy"
                })),

            # embed
            LabeledDemonstration.from_oracle_programs(
                [
                    # More
                    [
                        WeightedProgram(
                            ClickToken(
                                NearToken(LikeToken(
                                    FieldsValueSelectorToken(1)),
                                          classes="more")), 1)
                    ],
                    # embed
                    [
                        WeightedProgram(
                            ClickToken(LikeToken(StringToken(u"embed"))), 1)
                    ]
                ],
                "For the user @jess, click on the \"Embed\" button.",
                Fields({
                    "user": "******",
                    "button": "embed"
                })),

            # mute
            LabeledDemonstration.from_oracle_programs(
                [
                    # More
                    [
                        WeightedProgram(
                            ClickToken(
                                NearToken(LikeToken(
                                    FieldsValueSelectorToken(1)),
                                          classes="more")), 1)
                    ],
                    # mute
                    [
                        WeightedProgram(
                            ClickToken(LikeToken(StringToken(u"mute"))), 1)
                    ]
                ],
                "For the user @jess, click on the \"Mute\" button.",
                Fields({
                    "user": "******",
                    "button": "mute"
                })),

            # report
            LabeledDemonstration.from_oracle_programs(
                [
                    # More
                    [
                        WeightedProgram(
                            ClickToken(
                                NearToken(LikeToken(
                                    FieldsValueSelectorToken(1)),
                                          classes="more")), 1)
                    ],
                    # embed
                    [
                        WeightedProgram(
                            ClickToken(LikeToken(StringToken(u"report"))), 1)
                    ]
                ],
                "For the user @jess, click on the \"Report\" button.",
                Fields({
                    "user": "******",
                    "button": "report"
                })),

            # retweet
            LabeledDemonstration.from_oracle_programs(
                [
                    # like
                    [
                        WeightedProgram(
                            ClickToken(
                                NearToken(LikeToken(
                                    FieldsValueSelectorToken(1)),
                                          classes="retweet")), 1)
                    ],
                ],
                "For the user @jess, click on the \"Retweet\" button.",
                Fields({
                    "user": "******",
                    "button": "retweet"
                })),
        ]

        super(SocialMediaOracle, self).__init__(labeled_demos, config)
Ejemplo n.º 9
0
    def __init__(self, config):
        labeled_demos = [
            LabeledDemonstration.from_oracle_programs(
                [
                    #######
                    # forward

                    # Click name of sender
                    [
                        WeightedProgram(
                            ClickToken(LikeToken(FieldsValueSelectorToken(0))),
                            1)
                    ],
                    # Forward
                    [
                        WeightedProgram(
                            ClickToken(LikeToken(StringToken(u"Forward"))), 1)
                    ],
                    # Type name of recipient
                    [
                        WeightedProgram(
                            FocusAndTypeToken(InputElementsToken(),
                                              FieldsValueSelectorToken(2)), 1)
                    ],
                    # Send button
                    [
                        WeightedProgram(
                            ClickToken(LikeToken(StringToken(u""))), 1)
                    ]
                ],
                "Find the email by A and forward that email to B.",
                Fields({
                    "by": "A",
                    "task": "forward",
                    "to": "B"
                })),
            LabeledDemonstration.from_oracle_programs(
                [
                    #######
                    # reply

                    # Click name of sender
                    [
                        WeightedProgram(
                            ClickToken(LikeToken(FieldsValueSelectorToken(0))),
                            1)
                    ],
                    # Reply
                    [
                        WeightedProgram(
                            ClickToken(LikeToken(StringToken(u"Reply"))), 1)
                    ],
                    # Type message
                    [
                        WeightedProgram(
                            FocusAndTypeToken(InputElementsToken(),
                                              FieldsValueSelectorToken(1)), 1)
                    ],
                    # Send button
                    [
                        WeightedProgram(
                            ClickToken(LikeToken(StringToken(u""))), 1)
                    ]
                ],
                "Find the email by A and reply to them with the text \"B\".",
                Fields({
                    "by": "A",
                    "message": "B",
                    "task": "reply"
                })),
            LabeledDemonstration.from_oracle_programs(
                [
                    #######
                    # trash

                    # Click name of sender
                    [
                        WeightedProgram(
                            ClickToken(
                                SameRowToken(
                                    LikeToken(FieldsValueSelectorToken(0)))),
                            1)
                    ],
                ],
                "Find the email by A and click the trash icon to delete it.",
                Fields({
                    "by": "A",
                    "task": "delete"
                })),
            LabeledDemonstration.from_oracle_programs(
                [
                    #######
                    # star

                    # Click name of sender
                    [
                        WeightedProgram(
                            ClickToken(
                                SameRowToken(
                                    LikeToken(FieldsValueSelectorToken(0)))),
                            1)
                    ],
                ],
                ("Find the email by A and click the star "
                 "icon to mark it as important."),
                Fields({
                    "by": "A",
                    "task": "star"
                })),
        ]
        super(EmailNoScrollOracle, self).__init__(labeled_demos, config)