diff --git a/PHPSkills/FactorGraphs/Message.php b/PHPSkills/FactorGraphs/Message.php index f64178a..47d217e 100644 --- a/PHPSkills/FactorGraphs/Message.php +++ b/PHPSkills/FactorGraphs/Message.php @@ -3,14 +3,12 @@ namespace Moserware\Skills\FactorGraphs; class Message { - private $_nameFormat; - private $_nameFormatArgs; + private $_name; private $_value; - public function __construct($value = null, $nameFormat = null, $args = null) + public function __construct($value = null, $name = null) { - $this->_nameFormat = $nameFormat; - $this->_nameFormatArgs = $args; + $this->_name = $name; $this->_value = $value; } @@ -21,7 +19,7 @@ class Message public function __toString() { - return $this->_nameFormat; //return (_NameFormat == null) ? base.ToString() : String.Format(_NameFormat, _NameFormatArgs); + return $this->_name; } } diff --git a/PHPSkills/TrueSkill/Factors/GaussianFactor.php b/PHPSkills/TrueSkill/Factors/GaussianFactor.php index e2d02d1..d9d7567 100644 --- a/PHPSkills/TrueSkill/Factors/GaussianFactor.php +++ b/PHPSkills/TrueSkill/Factors/GaussianFactor.php @@ -34,7 +34,7 @@ abstract class GaussianFactor extends Factor return parent::createVariableToMessageBindingWithMessage($variable, new Message( GaussianDistribution::fromPrecisionMean(0, 0), - "message from {0} to {1}", $this)); + sprintf("message from %s to %s", $this, $variable))); } } diff --git a/PHPSkills/TrueSkill/Factors/GaussianGreaterThanFactor.php b/PHPSkills/TrueSkill/Factors/GaussianGreaterThanFactor.php index d9468d3..ba9623b 100644 --- a/PHPSkills/TrueSkill/Factors/GaussianGreaterThanFactor.php +++ b/PHPSkills/TrueSkill/Factors/GaussianGreaterThanFactor.php @@ -22,7 +22,7 @@ class GaussianGreaterThanFactor extends GaussianFactor public function __construct($epsilon, Variable &$variable) { - parent::__construct("{0} > {1:0.000}"); + parent::__construct(\sprintf("%s > %.2f", $variable, $epsilon)); $this->_epsilon = $epsilon; $this->createVariableToMessageBinding($variable); } diff --git a/PHPSkills/TrueSkill/Factors/GaussianLikelihoodFactor.php b/PHPSkills/TrueSkill/Factors/GaussianLikelihoodFactor.php index 614b1d9..be2e41e 100644 --- a/PHPSkills/TrueSkill/Factors/GaussianLikelihoodFactor.php +++ b/PHPSkills/TrueSkill/Factors/GaussianLikelihoodFactor.php @@ -20,7 +20,7 @@ class GaussianLikelihoodFactor extends GaussianFactor public function __construct($betaSquared, Variable &$variable1, Variable &$variable2) { - parent::__construct("Likelihood of {0} going to {1}"); + parent::__construct(sprintf("Likelihood of %s going to %s", $variable2, $variable1)); $this->_precision = 1.0/$betaSquared; $this->createVariableToMessageBinding($variable1); $this->createVariableToMessageBinding($variable2); diff --git a/PHPSkills/TrueSkill/Factors/GaussianPriorFactor.php b/PHPSkills/TrueSkill/Factors/GaussianPriorFactor.php index 1bb0c0a..8d38520 100644 --- a/PHPSkills/TrueSkill/Factors/GaussianPriorFactor.php +++ b/PHPSkills/TrueSkill/Factors/GaussianPriorFactor.php @@ -21,11 +21,10 @@ class GaussianPriorFactor extends GaussianFactor public function __construct($mean, $variance, Variable &$variable) { - parent::__construct("Prior value going to {0}"); + parent::__construct(sprintf("Prior value going to %s", $variable)); $this->_newMessage = new GaussianDistribution($mean, sqrt($variance)); $newMessage = new Message(GaussianDistribution::fromPrecisionMean(0, 0), - "message from {0} to {1}", - $this, $variable); + sprintf("message from %s to %s", $this, $variable)); $this->createVariableToMessageBindingWithMessage($variable, $newMessage); } diff --git a/PHPSkills/TrueSkill/Factors/GaussianWithinFactor.php b/PHPSkills/TrueSkill/Factors/GaussianWithinFactor.php index d16d20c..91edf59 100644 --- a/PHPSkills/TrueSkill/Factors/GaussianWithinFactor.php +++ b/PHPSkills/TrueSkill/Factors/GaussianWithinFactor.php @@ -22,6 +22,7 @@ class GaussianWithinFactor extends GaussianFactor public function __construct($epsilon, Variable &$variable) { + parent::__construct(sprintf("%s <= %.2f", $variable, $epsilon)); $this->_epsilon = $epsilon; $this->createVariableToMessageBinding($variable); }