Giter Club home page Giter Club logo

Comments (11)

wodim avatar wodim commented on May 22, 2024 1

Yes. I personally don't like the idea of "to_json" to be honest, because the user should be left with the task of serialising the stuff (I'm using pickle myself because I imagine it's faster) but I guess it's a good idea to have those methods for consistency with what there is in markovify.Chain. It can't hurt.

from markovify.

jsvine avatar jsvine commented on May 22, 2024

My apologies, and great catch. I've updated the README to fix that section and add a more explicit example. Does following that example work for you? (You should be able to swap markovify.Text for markovify.NewlineText.)

from markovify.

wodim avatar wodim commented on May 22, 2024

Why do you still need the corpus text when reconstituting the model? Isn't everything inside the json file?

from markovify.

jsvine avatar jsvine commented on May 22, 2024

The JSON file contains only the chain, rather than the full model (i.e., corpus + state_size + chain). But I could definitely imagine adding a feature to export/import full model. In fact, I'll try doing that right now.

from markovify.

jsvine avatar jsvine commented on May 22, 2024

Done! See #44, now merged into master and available on PyPi in v0.5.0.

from markovify.

wodim avatar wodim commented on May 22, 2024

Hm, that's fine, but there's a problem -- despite the names of the methods (from_json/to_json) those methods don't accept/return a str containing json, but a dict.

from markovify.

jsvine avatar jsvine commented on May 22, 2024

Ah, I see. That's a good point. I suppose it'd make sense to do this:

  • .to_json/.from_json: accepts/returns JSON strings.
  • .to_dict/.from_dict: accepts/returns dicts.

What do you think?

from markovify.

wodim avatar wodim commented on May 22, 2024

That sounds good.

from markovify.

jsvine avatar jsvine commented on May 22, 2024

Here's the proposed change: https://github.com/jsvine/markovify/pull/45/files

Along the lines of what you were thinking?

from markovify.

jsvine avatar jsvine commented on May 22, 2024

Makes sense, and thanks again for these suggestions. Much appreciated!

from markovify.

wodim avatar wodim commented on May 22, 2024

That's right, thanks for your work.

from markovify.

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.