示例#1
0
文件: vote.py 项目: WEB3-GForce/VOTE
def _initialize_decision(decision, member, bill):
    """Initializes a decision object with information about the member and bill.
    Extracts stances for the member based on the bill and the member's 
    relations.

     Arguments:
        decision: the decision object to initialize
        member: a Member object corresponding to the member who will vote
        bill: a Bill object of the bill to be voted on.
    """

    logger.LOGGER.info("Initializing decision...")

    decision.member = member._id
    decision.bill = bill._id

    if not member.stances:
        member_analyze.extract_voting_stances(member)

    if not member.pro_rel_stances:
        member_analyze.infer_relations_stances(member)

    logger.LOGGER.info("Analyzing alternative positions...")

    decision.for_stances = member_analyze.match_stances(member, bill, outcomes.FOR)
    decision.agn_stances = member_analyze.match_stances(member, bill, outcomes.AGN)

    logger.LOGGER.info("Initialization complete.")
示例#2
0
    def test_infer_relations_stances(self):
        """ Verifies all group stances are extracted."""
        member_analyze.infer_relations_stances(self.member)

        # Stances from friends of the member should be in pro_rel_stances
        self.assertEqual(len(self.member.pro_rel_stances), len(self.group1.stances))
        for stance1, stance2 in zip(self.member.pro_rel_stances, self.group1.stances):
            self.assertTrue(stance1.total_match(stance2))

        # Stances from enemies of the member should be in con_rel_stances
        self.assertEqual(len(self.member.con_rel_stances), len(self.group2.stances))
        for stance1, stance2 in zip(self.member.con_rel_stances, self.group2.stances):
            self.assertTrue(stance1.total_match(stance2))