GithubHelp home page GithubHelp logo

bug about remove_markup about gensim HOT 2 OPEN

seadog-www avatar seadog-www commented on June 12, 2024
bug about remove_markup

from gensim.

Comments (2)

gojomo avatar gojomo commented on June 12, 2024

Thank you for your report & code-to-reproduce!

In looking over the code, the more basic problem might be that RE_P1 (for REF tags) assumes that any /> ends the tag, as if there'd never be any kind of nested tag – but in your example fragments, the <NOWIKI/> or <BR/> tags do appear. Your suggested fix seems it would only remedy the problem in the few cases you've seen – while the unexpected nesting of any other tags ending /> risk triggering the same problem.

It looks like the RE_P9 (described as "external links"?) and RE_P10 (math) share a similar assumption that any /> must end of the tag-of-interest, rather than some nested tag, and thus might be susceptible to the same issue.

I think it'd be better to tune those regexes to not assume the absence of all nested tags, but that might risk other side-effects, or require other re-ordering of steps – I'm not sure why the existing regexes work the way they do, and processing HTML or Wikipedia's weird wikitext format with regexes is an inherently clunky & hard-to-maintain approach.

It might be most robust to move some form of RE_P11 ("All other tags") up in the process, but narrowed to leave any specific tags of interest.

from gensim.

seadog-www avatar seadog-www commented on June 12, 2024

Thank you for your report & code-to-reproduce!

In looking over the code, the more basic problem might be that RE_P1 (for REF tags) assumes that any /> ends the tag, as if there'd never be any kind of nested tag – but in your example fragments, the <NOWIKI/> or <BR/> tags do appear. Your suggested fix seems it would only remedy the problem in the few cases you've seen – while the unexpected nesting of any other tags ending /> risk triggering the same problem.

It looks like the RE_P9 (described as "external links"?) and RE_P10 (math) share a similar assumption that any /> must end of the tag-of-interest, rather than some nested tag, and thus might be susceptible to the same issue.

I think it'd be better to tune those regexes to not assume the absence of all nested tags, but that might risk other side-effects, or require other re-ordering of steps – I'm not sure why the existing regexes work the way they do, and processing HTML or Wikipedia's weird wikitext format with regexes is an inherently clunky & hard-to-maintain approach.

It might be most robust to move some form of RE_P11 ("All other tags") up in the process, but narrowed to leave any specific tags of interest.

Yes, my suggestion is not perfect. Do you have better method for processing HTML or Wikipedia's weird wikitext format without regexes?

from gensim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.