Physikerwelt has uploaded a new change for review.
https://gerrit.wikimedia.org/r/261647
Change subject: Add definitions to wmc ref script
......................................................................
Add definitions to wmc ref script
Change-Id: I11e138ab838d0a45b1bf9d70782818fb007deda3
---
M maintenance/WmcRefIdentifier.php
1 file changed, 22 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MathSearch
refs/changes/47/261647/1
diff --git a/maintenance/WmcRefIdentifier.php b/maintenance/WmcRefIdentifier.php
index 712af19..3c26758 100644
--- a/maintenance/WmcRefIdentifier.php
+++ b/maintenance/WmcRefIdentifier.php
@@ -35,7 +35,28 @@
foreach ( $res as $row ) {
$md = new MathoidDriver( $row->math_inputtex );
$md->texvcInfo();
- $output[] = (object)array( 'identifiers' =>
$md->getIdentifiers(), $row );
+ $identifiers = array_unique( $md->getIdentifiers() );
+ $fId = "math.{$row->oldId}.{$row->fid}";
+ $mo = MathObject::newFromRevisionText( $row->oldId,
$fId );
+ $relations = array();
+ $rels = $mo->getRelations();
+ $wd = new WikidataDriver();
+ foreach ( $identifiers as $i ) {
+ $relations[$i] = array();
+ if ( isset( $rels[$i] ) ) {
+ foreach ( $rels[$i] as $rel ) {
+ if ( preg_match(
'/\[\[(.*)\]\]/', $rel->definition, $m ) ) {
+ if ( $wd->search( $m[1]
) ){
+ $res =
$wd->getResults();
+
$relations[$i][] = $res;
+ }
+ } else {
+ $relations[$i][] =
$rel->definition;
+ }
+ }
+ }
+ }
+ $output[] = (object)array( 'definitions' => $relations,
'formula' => $row );
}
$this->output( json_encode( $output ) );
}
--
To view, visit https://gerrit.wikimedia.org/r/261647
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I11e138ab838d0a45b1bf9d70782818fb007deda3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MathSearch
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits