https://github.com/mieuxvoter/majority-judgment-library-php
Interface-oriented PHP library to deliberate using majority judgment, using a score-based algorithm for performance.
https://github.com/mieuxvoter/majority-judgment-library-php
election majority-judgment php-library political-science poll
Last synced: over 1 year ago
JSON representation
Interface-oriented PHP library to deliberate using majority judgment, using a score-based algorithm for performance.
- Host: GitHub
- URL: https://github.com/mieuxvoter/majority-judgment-library-php
- Owner: MieuxVoter
- Created: 2020-12-29T17:38:53.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-30T12:43:51.000Z (almost 5 years ago)
- Last Synced: 2024-12-16T14:13:45.205Z (over 1 year ago)
- Topics: election, majority-judgment, php-library, political-science, poll
- Language: PHP
- Homepage: https://mieuxvoter.fr
- Size: 35.2 KB
- Stars: 6
- Watchers: 7
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Majority Judgment PHP Library
Deliberate majority judgment polls ⚖.
## Features
- Majority judgment deliberation from merit profiles
- Score based, efficiency should scale well (algo is parallelizable)
- Interface-oriented, test-driven code
- Extensible to get other judgments (usual, central, etc.)
- Made by [MieuxVoter](https://mieuxvoter.fr)'s volunteers
## Usage example
Require it in your own project, using composer:
composer require mieuxvoter/majority-judgment
Use it:
```php
use MieuxVoter\MajorityJudgment\MajorityJudgmentDeliberator;
use MieuxVoter\MajorityJudgment\Model\Settings\MajorityJudgmentSettings;
use MieuxVoter\MajorityJudgment\Model\Tally\ArrayPollTally;
$tally = new ArrayPollTally([
'Proposal A' => [1, 1, 4, 3, 7, 4, 1], // amount of judgments for each grade
'Proposal B' => [0, 2, 4, 6, 4, 2, 3], // (worst grade to best grade)
]);
$deliberator = new MajorityJudgmentDeliberator();
$result = $deliberator->deliberate($tally);
// $result is a PollResultInterface
foreach($result->getProposalResults() as $proposalResult) {
// … Do something
print($proposalResult->getProposal());
print($proposalResult->getRank());
}
```
## Interface-oriented
Any object implementing `PollTallyInterface` may be used as input.
### Testing
See the tests in `test/`.
composer install --dev
vendor/phpunit/phpunit/phpunit -v test