Git Product home page Git Product logo

Comments (1)

voaneves avatar voaneves commented on June 3, 2024

I've also encountered an issue in the treebank.py script within the B2WSentiment class, particularly related to file path handling and CSV reading. The original code snippet is as follows:

class B2WSentiment:
    def __init__(self, path=None, tablesize=1000000):
        if not path:
            path = "data/B2W-Reviews01.csv"

        self.path = path
        self.df = pd.read_csv(path, nrows=15000, sep=';')[[
            "review_text", "overall_rating"
        ]].drop_duplicates(subset=['review_text'])
        self.tablesize = tablesize

While this works well in certain environments (like linux), it wasnt working on windows, throwing erros about the overall_rating` column (that doesn't exist) and also the file name that changed. To enhance portability and ensure more consistent behavior across different operating systems, I propose the following modifications:

class B2WSentiment:
    def __init__(self, path=None, tablesize=1000000):
        if not path:
            path = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'data/b2w.csv'))

        self.path = path
        self.df = pd.read_csv(path, nrows=15000, sep=',', quotechar='"')[[
            "review_text", "rating"
        ]].drop_duplicates(subset=['review_text'])
        self.tablesize = tablesize

@alan-barzilay , could you please review these changes? Your insights would be greatly appreciated to ensure the best practices and optimal functionality!

from nlportugues.

Related Issues (7)

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.