Giter VIP home page Giter VIP logo

Comments (7)

MthwRobinson avatar MthwRobinson commented on May 16, 2024 1

Looks like we need to add handling for those element types in elements_to_isd. As of now, I think the element metadata gets lost when you read it in from JSON too. I'll update the issue description to reflect that. We'll be able to get a fix in for that shortly. Thanks for flagging!

https://github.com/Unstructured-IO/unstructured/blob/main/unstructured/staging/base.py#L26-L33

from unstructured.

MthwRobinson avatar MthwRobinson commented on May 16, 2024 1

@Matthieu-Tinycoaching - There's a PR up to address the issue you flagged. That also adds helper functions for saving to/loading from JSON

from unstructured.

MthwRobinson avatar MthwRobinson commented on May 16, 2024 1

Right now! Just released the updated in 0.4.15

from unstructured.

MthwRobinson avatar MthwRobinson commented on May 16, 2024

@Matthieu-Tinycoaching - Checkout out convert_to_isd and isd_to_elements in our docs. You can serialize and deserialize from JSON like this:

with open("elements.json", "w") as f:
    json.dump(convert_to_isd(elements), f)

with open("elements.json", "r") as f:
    elements = isd_to_elements(json.load(f))

Would that meet your needs? We'd also be happy to include an elements_to_json and elements_from_json to wrap that.

from unstructured.

Matthieu-Tinycoaching avatar Matthieu-Tinycoaching commented on May 16, 2024

Hi @MthwRobinson thanks for the tip! It seems to do the job.

However, when trying this on the example data layout-parser-paper.pdf, FigureCaption and Text data seem to be lost when reimporting data from the JSON file.

When counting for the types of elements present in the document just after parsing:
Counter({<class 'unstructured.documents.elements.ListItem'>: 223, <class 'unstructured.documents.elements.NarrativeText'>: 69, <class 'unstructured.documents.elements.Title'>: 15, <class 'unstructured.documents.elements.FigureCaption'>: 6, <class 'unstructured.documents.elements.Text'>: 2})

When doing this after reimporting from the JSON file:
Counter({<class 'unstructured.documents.elements.ListItem'>: 223, <class 'unstructured.documents.elements.NarrativeText'>: 69, <class 'unstructured.documents.elements.Title'>: 15})

Any idea?

from unstructured.

MthwRobinson avatar MthwRobinson commented on May 16, 2024

Added #270 to capture the missing elements. Will add some serialization/deserialization helper functions while we're in there.

from unstructured.

Matthieu-Tinycoaching avatar Matthieu-Tinycoaching commented on May 16, 2024

@MthwRobinson nice!
Do you know when the new release with this fix will be out?

from unstructured.

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.