jenkins-bot has submitted this change and it was merged.

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(-)

Approvals:
  Physikerwelt: Looks good to me, approved
  jenkins-bot: Verified



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: merged
Gerrit-Change-Id: I11e138ab838d0a45b1bf9d70782818fb007deda3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MathSearch
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>
Gerrit-Reviewer: Dyiop <[email protected]>
Gerrit-Reviewer: Hcohl <[email protected]>
Gerrit-Reviewer: Physikerwelt <[email protected]>
Gerrit-Reviewer: Whyameri <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to