wooorm / retext-visit

DEPRECATED in favour of unist-util-visit
0 stars 0 forks source link

How to use deprecated module in Package.json? #2

Closed molinto closed 8 years ago

molinto commented 8 years ago

Hi Titus, we still use this package. How do I still use in Package.json please?

Sharry

molinto commented 8 years ago

Tried (but failing):

"retext-visit": "git://github.com/wooorm/retext-visit/tree/4fd0c018175b2a5c387c76d5cabcfc5c2c70c455"
"retext-visit": "git://https://github.com/wooorm/retext-visit/tree/4fd0c018175b2a5c387c76d5cabcfc5c2c70c455.zip"
"retext-visit": "https://github.com/wooorm/retext-visit/archive/4fd0c018175b2a5c387c76d5cabcfc5c2c70c455.tar.gz"
wooorm commented 8 years ago

You can specify retext-visit@0.2.5 in your package.json file. This will not show a deprecation message.

If that doesn’t work, could you show me your package.json file, the command you execute to install, and the output you get?

molinto commented 8 years ago

Works now using:

    "retext-visit": "https://github.com/wooorm/retext-visit/archive/4fd0c018175b2a5c387c76d5cabcfc5c2c70c455.tar.gz",

Another error now lol:

/home/sharry/Development/Projects/bh/bh-contacts/node_modules/retext-visit/index.js:73
    parentPrototype = TextOM.Parent.prototype;
                            ^
TypeError: Cannot read property 'Parent' of undefined
    at plugin (/home/sharry/Development/Projects/bh/bh-contacts/node_modules/retext-visit/index.js:73:29)
    at Of.use (/home/sharry/Development/Projects/bh/bh-contacts/node_modules/retext/node_modules/unified/node_modules/attach-ware/index.js:120:21)
    at Processor.use (/home/sharry/Development/Projects/bh/bh-contacts/node_modules/retext/node_modules/unified/index.js:111:23)
    at Object.<anonymous> (/home/sharry/Development/Projects/bh/bh-contacts/index.js:31:23)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
molinto commented 8 years ago

Only want the sentiment of a single sentence (comment):

Just using:

    var Retext = require('retext'),
    sentiment = require('retext-sentiment'),
    visit = require('retext-visit');

    var rt = new Retext().use(visit).use(sentiment);

Do I need to include others packages to use this module? Sorry, been a while since I used this.

function getCommentSentiment(comment, cb) {
    rt.parse(comment, function (err, tree) {
        if (err) {
            return cb(err);
        }
        if (tree.length === 0) {
            return cb(new Error('Error loading the comment data!'));
        }

        var sentiment;
        tree.visit(tree.SENTENCE_NODE, function (node) {
            sentiment = node.data.valence;
        });

        cb(null, tree, sentiment);
    });
}
wooorm commented 8 years ago

I’m guessing you’re on retext@1.0.0? The reason retext-visit is deprecated is because everything changes in retext-land, meaning, retext-visit is no longer applicable because that’s no longer how retext works.

Either pin all your retext-dependencies down to before 1.0.0, or update to 1.0.0 and change your code.

molinto commented 8 years ago

Yep, v1.0.0

  "dependencies": {
    "amqplib": "^0.4.0",
    "crypto-js": "^3.1.6",
    "express": "^4.13.3",
    "http": "0.0.0",
    "lodash": "^3.10.1",
    "moment": "^2.10.6",
    "mongoose": "^4.1.10",
    "mongoose-simple-random": "^0.3.3",
    "mongoose-timestamp": "^0.4.0",
    "random-id": "0.0.2",
    "retext": "^1.0.0",
    "retext-sentiment": "^1.0.0",
    "retext-visit": "https://github.com/wooorm/retext-visit/archive/4fd0c018175b2a5c387c76d5cabcfc5c2c70c455.tar.gz",
    "validator": "^4.1.0",
    "when": "^3.7.3",
    "winston": "^2.1.1",
    "winston-loggly": "^1.2.0"
  }
wooorm commented 8 years ago

Then, either update your code, or downgrade the version numbers to 0.6.0, 0.4.2, 0.2.5, respectively.

molinto commented 8 years ago

Thanks, think I'll have to move to another module as all existing code/examples build use rt.parse() which doesn't exist anymore. Thanks anyway dude

wooorm commented 8 years ago

:+1: