Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/123519

Change subject: Segmentation: Fix the wrong usage of section types
......................................................................

Segmentation: Fix the wrong usage of section types

Eventhough the sectionTypes array was introduced, openTag handler was
not using it by mistake

Change-Id: I1a5c49102b545a369d48ca74319826e393dd5a9a
---
M segmentation/languages/CXParser.js
M tests/segmentation/SegmentationTests.json
2 files changed, 5 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/19/123519/1

diff --git a/segmentation/languages/CXParser.js 
b/segmentation/languages/CXParser.js
index d3499d5..a57502f 100644
--- a/segmentation/languages/CXParser.js
+++ b/segmentation/languages/CXParser.js
@@ -146,8 +146,7 @@
  * @param {Object} tag
  */
 CXParser.prototype.onopentag = function ( tag ) {
-       var attrName,
-               section = /[ph1-6]|figure|figcaption|ul|div/;
+       var attrName;
 
        if ( this.sectionTypes.indexOf( tag.name ) >= 0 ) {
                if ( this.inSentence ) {
@@ -172,7 +171,7 @@
        }
 
        // Sections
-       if ( tag.name.match( section ) ) {
+       if ( this.sectionTypes.indexOf( tag.name ) >= 0 ) {
                if ( !tag.attributes.id ) {
                        this.print( ' id="' + ( this.segmentCount++ ) + '"' );
                }
@@ -182,7 +181,7 @@
        this.print( '>' );
 
        // Start the first segment of the section
-       if ( tag.name.match( section ) ) {
+       if ( this.sectionTypes.indexOf( tag.name ) >= 0 ) {
                this.print( this.startSentence() );
        }
 };
diff --git a/tests/segmentation/SegmentationTests.json 
b/tests/segmentation/SegmentationTests.json
index 4de98c8..b150841 100644
--- a/tests/segmentation/SegmentationTests.json
+++ b/tests/segmentation/SegmentationTests.json
@@ -34,8 +34,8 @@
                },
                {
                        "desc": "References can appear after period. Example: 
Hydrogen is a gas. [1] It is ...",
-                       "source": "<p>Sentence one. <a href=\"#\">reference</a> 
Starts with reference</p>",
-                       "result": "<p id=\"0\"><span class=\"cx-segment\" 
data-segmentid=\"1\">Sentence one. </span><span class=\"cx-segment\" 
data-segmentid=\"2\"><a class=\"cx-link\" data-linkid=\"3\" 
href=\"#\">reference</a> Starts with reference</span></p>"
+                       "source": "<p>Sentence one. <span 
class=\"reference\"><a href=\"#\">reference</a></span> Starts with 
reference</p>",
+                       "result": "<p id=\"0\"><span class=\"cx-segment\" 
data-segmentid=\"1\">Sentence one. </span><span class=\"cx-segment\" 
data-segmentid=\"2\"><span class=\"reference\"><a class=\"cx-link\" 
data-linkid=\"3\" href=\"#\">reference</a></span> Starts with 
reference</span></p>"
                }
        ],
        "hi": [

-- 
To view, visit https://gerrit.wikimedia.org/r/123519
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a5c49102b545a369d48ca74319826e393dd5a9a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to