Physikerwelt has submitted this change and it was merged. Change subject: Extract mtext features ......................................................................
Extract mtext features Extract mi mo and mtext elements from MathML elements. Change-Id: Ie7052db8665a5ef048cc54c26bb0816295478044 --- M MathObject.php M MathSearch.php 2 files changed, 27 insertions(+), 6 deletions(-) Approvals: Physikerwelt: Verified; Looks good to me, approved diff --git a/MathObject.php b/MathObject.php index b0b4ef6..5daad86 100644 --- a/MathObject.php +++ b/MathObject.php @@ -1,6 +1,6 @@ <?php -class MathObject extends MathLaTeXML { +class MathObject extends MathMathML { protected $anchorID = 0; protected $pageID = 0; @@ -145,8 +145,10 @@ } public function updateObservations( $dbw = null ) { + global $wgMathUpdateObservations; + if ( $wgMathUpdateObservations ) $this->updateObservations(); $this->readFromDatabase(); - preg_match_all( "#<(mi|mo)( ([^>].*?))?>(.*?)</\\1>#u", $this->mathml, $rule, PREG_SET_ORDER ); + preg_match_all( "#<(mi|mo|mtext)( ([^>].*?))?>(.*?)</\\1>#u", $this->getMathml(), $rule, PREG_SET_ORDER ); if ( $dbw == null ) { $dbgiven = false; $dbw = wfGetDB( DB_MASTER ); @@ -158,12 +160,12 @@ foreach ( $rule as $feature ) { $dbw->insert( "mathobservation", array( "mathobservation_inputhash" => $this->getInputHash(), - "mathobservation_featurename" => utf8_encode( $feature[ 4 ] ), + "mathobservation_featurename" => utf8_encode( trim( $feature[ 4 ] ) ), "mathobservation_featuretype" => utf8_encode( $feature[ 1 ] ), ) ); - if ( !$dbgiven ) { - $dbw->commit(); - } + } + if ( !$dbgiven ) { + $dbw->commit(); } } public static function cloneFromRenderer(MathRenderer $renderer){ @@ -285,4 +287,21 @@ Parser::extractTagsAndParams( array( 'math' ), $wikiText, $matches ); return $matches; } + + public static function updateStatistics(){ + $dbw = wfGetDB( DB_MASTER ); + $dbw->query( 'TRUNCATE TABLE `mathvarstat`' ); + $dbw->query("INSERT INTO `mathvarstat` (`varstat_featurename` , `varstat_featuretype`, `varstat_featurecount`)\n" + . "SELECT `mathobservation_featurename` , `mathobservation_featuretype` , count( * ) AS CNT\n" + . "FROM `mathobservation`\n" + . "JOIN mathindex ON `mathobservation_inputhash` = mathindex_inputhash\n" + . "GROUP BY `mathobservation_featurename` , `mathobservation_featuretype`\n" + . "ORDER BY CNT DESC"); + $dbw->query( 'TRUNCATE TABLE `mathpagestat`' ); + $dbw->query( 'INSERT INTO `mathpagestat`(`pagestat_featureid`,`pagestat_pageid`,`pagestat_featurecount`) ' + . 'SELECT varstat_id, mathindex_page_id, count(*) as CNT FROM `mathobservation` ' + . 'JOIN mathindex on `mathobservation_inputhash` = mathindex_inputhash ' + . 'JOIN mathvarstat on varstat_featurename = `mathobservation_featurename` and varstat_featuretype = `mathobservation_featuretype` ' + . 'GROUP by `mathobservation_featurename`, `mathobservation_featuretype`, mathindex_page_id ORDER BY CNT DESC' ); + } } diff --git a/MathSearch.php b/MathSearch.php index 662b4a7..aac812a 100644 --- a/MathSearch.php +++ b/MathSearch.php @@ -30,6 +30,8 @@ $wgMathSearchDB2ConnStr = false; /** @var String URL of MathWebSearch instance */ $wgMathSearchMWSUrl = 'http://localhost:9090/'; +/** @var boolean if true the observation is updated everytime the SpecialPage formulainfo is shown. */ +$wgMathUpdateObservations = false; $dir = dirname( __FILE__ ) . '/'; $wgAutoloadClasses['MathSearchHooks'] = $dir . 'MathSearch.hooks.php'; -- To view, visit https://gerrit.wikimedia.org/r/127444 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie7052db8665a5ef048cc54c26bb0816295478044 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MathSearch Gerrit-Branch: master Gerrit-Owner: Physikerwelt <w...@physikerwelt.de> Gerrit-Reviewer: Physikerwelt <w...@physikerwelt.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits