0x333333 / wiki-infobox-parser

A Wikipedia Infobox Parser
https://www.npmjs.com/package/wiki-infobox-parser
MIT License
19 stars 5 forks source link

Infobox parsing module #2

Open dijs opened 8 years ago

dijs commented 8 years ago

I am the developer of wikijs.

I have a favor to ask, I love the problem this module is solving... Is there any way you could export the parser of this module so I could use JUST the parsing functionality?

I already have the infobox request part, but I would like to use your library for the parsing.

Thanks,

0x333333 commented 8 years ago

Hi @dijs ,

Thanks for your suggestion, if you only want the parser, I can change the interface of current lib like this:

var wikiParser = require('wiki-infobox-parser');

/* Previous interface */
wikiParser('france', function(err, result) {
  if (err) {
    console.error(err.message);
  } else {
    console.log(result);
  }
});

/* New interface */
let config = {
  'keyword': 'france',
  'wikitext': '=== A sample of original wiki text. ==='
};
/* If wikitext is not null, I will use the text directly without calling Wiki API. */
wikiParser(config, function(err, result) {
  if (err) {
    console.error(err.message);
  } else {
    console.log(result);
  }
});

Does this work for you?

dijs commented 8 years ago

I was hoping to not have the request dependency. Since this will be bundled. Is there any way the parsing code can be a completely different module? On Mon, May 23, 2016 at 4:56 AM Zhipeng JIANG notifications@github.com wrote:

Hi @dijs https://github.com/dijs ,

Thanks for your suggestion, if you only want the parser, I can change the interface of current lib like this:

var wikiParser = require('wiki-infobox-parser');

/* Previous interface /wikiParser('france', function(err, result) { if (err) { console.error(err.message); } else { console.log(result); } }); / New interface /let config = { 'keyword': 'france', 'wikitext': '=== A sample of original wiki text. ===' };/ If wikitext is not null, I will use the text directly without calling Wiki API. */wikiParser(config, function(err, result) { if (err) { console.error(err.message); } else { console.log(result); } });

Does this work for you?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/zp-j/wiki-infobox-parser/issues/2#issuecomment-220937337

dijs commented 8 years ago

So, a follow up to this. My wikijs is not able to be bundled as a browser app b/c your library uses request. That is why I was hoping the parser itself could be it's own module. If you can't, no problem. I can externalize it. And if I do that, do you mind if I use your code?

0x333333 commented 8 years ago

Hi @dijs, sorry for the late reply, I'm OOO this week. I can extract the parser out of this lib, hopefully I can publish it tomorrow. By the way, if you want to use the code directly, feel free to play with it :D

0x333333 commented 8 years ago

Hi @dijs , I've publish the first version of the parser, you can check it out here: + wiki-infobox-parser-core@0.0.1. More tests will be added.

dijs commented 8 years ago

Thank you so much! On Sun, May 29, 2016 at 9:36 AM Zhipeng JIANG notifications@github.com wrote:

Hi @dijs https://github.com/dijs , I've publish the first version of the parser, you can check it out here: + wiki-infobox-parser-core@0.0.1 https://www.npmjs.com/package/wiki-infobox-parser-core. More tests will be added.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zp-j/wiki-infobox-parser/issues/2#issuecomment-222363920, or mute the thread https://github.com/notifications/unsubscribe/ABsTXhc9WAMCZj37g-euiAz9ltUij5C5ks5qGaRQgaJpZM4IkDWO .

dijs commented 8 years ago

Awesome. I threw it in here: https://github.com/dijs/wiki/pull/23

Could we not always console log when parsing? Or maybe use the debug module if necessary.

0x333333 commented 8 years ago

Thanks @dijs , I will fix them as soon as possible.