Giter Club home page Giter Club logo

Comments (7)

chrismattmann avatar chrismattmann commented on July 23, 2024

hi @MaheshSankaran - see the X-TIKA:content field available in the metadata. That's not HTML, but it's the extracted text.

Unfortunately if you have a look at: http://wiki.apache.org/tika/TikaJAXRS we don't have support in Tika server yet for providing the extracted XHTML. It is supported in tika-app and its -J command for example. See the difference in JSON e.g., X:TIKA-Content in http://wiki.apache.org/tika/GrobidJournalParser.

I've filed an issue at Tika: https://issues.apache.org/jira/browse/TIKA-1716 Feel free to comment there and to help get it implemented. If it's available in Tika-Server we can easily make it available here.

from tika-python.

MaheshSankaran avatar MaheshSankaran commented on July 23, 2024

thank you chrismattmann.i have been voted and commented on issue which you created.

from tika-python.

chrismattmann avatar chrismattmann commented on July 23, 2024

thanks @MaheshSankaran you commented your support, thanks. If you have time feel free to contribute a solution too. I likely won't have time to for a bit.

from tika-python.

chrismattmann avatar chrismattmann commented on July 23, 2024

Now that TIKA-1716 is done, I will add support here in the Python library for it. Stand by.

from tika-python.

chrismattmann avatar chrismattmann commented on July 23, 2024

OK, I have this working in a branch:

[chipotle:~] mattmann% python2.7
Python 2.7.8 (default, Sep 27 2014, 11:46:04) 
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from tika import parser
>>> parser.from_file('/Users/mattmann/.bashrc')
{'content': u'\n\n\n\n\n\n\n\n\nalias tika="java -jar /usr/local/tika/tika-app-1.8.jar"\nalias ls="ls -FHG"\n\n', 'metadata': {u'resourceName': u'.bashrc', u'X-Parsed-By': [u'org.apache.tika.parser.DefaultParser', u'org.apache.tika.parser.txt.TXTParser'], u'Content-Type': u'text/plain; charset=ISO-8859-1', u'X-TIKA:parse_time_millis': u'8', u'Content-Encoding': u'ISO-8859-1'}}
>>> parser.from_file('/Users/mattmann/.bashrc', xmlContent=True)
{'content': u'<html xmlns="http://www.w3.org/1999/xhtml">\n<head>\n<meta name="Content-Encoding" content="ISO-8859-1" />\n<meta name="X-Parsed-By" content="org.apache.tika.parser.DefaultParser" />\n<meta name="X-Parsed-By" content="org.apache.tika.parser.txt.TXTParser" />\n<meta name="Content-Type" content="text/plain; charset=ISO-8859-1" />\n<meta name="resourceName" content=".bashrc" />\n<title></title>\n</head>\n<body><p>alias tika="java -jar /usr/local/tika/tika-app-1.8.jar"\nalias ls="ls -FHG"\n</p>\n</body></html>', 'metadata': {u'resourceName': u'.bashrc', u'X-Parsed-By': [u'org.apache.tika.parser.DefaultParser', u'org.apache.tika.parser.txt.TXTParser'], u'Content-Type': u'text/plain; charset=ISO-8859-1', u'X-TIKA:parse_time_millis': u'6', u'Content-Encoding': u'ISO-8859-1'}}
>>> parser.from_buffer(open('/Users/mattmann/.bashrc', 'r').read())
{'content': u'\n\n\n\n\n\n\n\nalias tika="java -jar /usr/local/tika/tika-app-1.8.jar"\nalias ls="ls -FHG"\n\n', 'metadata': {u'Content-Encoding': u'ISO-8859-1', u'Content-Type': u'text/plain; charset=ISO-8859-1', u'X-TIKA:parse_time_millis': u'5', u'X-Parsed-By': [u'org.apache.tika.parser.DefaultParser', u'org.apache.tika.parser.txt.TXTParser']}}
>>> parser.from_buffer(open('/Users/mattmann/.bashrc', 'r').read(), xmlContent=True)
{'content': u'<html xmlns="http://www.w3.org/1999/xhtml">\n<head>\n<meta name="Content-Encoding" content="ISO-8859-1" />\n<meta name="X-Parsed-By" content="org.apache.tika.parser.DefaultParser" />\n<meta name="X-Parsed-By" content="org.apache.tika.parser.txt.TXTParser" />\n<meta name="Content-Type" content="text/plain; charset=ISO-8859-1" />\n<title></title>\n</head>\n<body><p>alias tika="java -jar /usr/local/tika/tika-app-1.8.jar"\nalias ls="ls -FHG"\n</p>\n</body></html>', 'metadata': {u'Content-Encoding': u'ISO-8859-1', u'Content-Type': u'text/plain; charset=ISO-8859-1', u'X-TIKA:parse_time_millis': u'4', u'X-Parsed-By': [u'org.apache.tika.parser.DefaultParser', u'org.apache.tika.parser.txt.TXTParser']}}
>>> 

I'm going to leave it in the branch please try it out @MaheshSankaran branch is html-output65. Once Tika 1.11 is out, I will go ahead and merge the branch to master.

from tika-python.

MaheshSankaran avatar MaheshSankaran commented on July 23, 2024

Great Work @chrismattmann
will try once tika 1.11 is release.

Thanks,
Mahesh

from tika-python.

teoric avatar teoric commented on July 23, 2024

I stumbled on this it searching for a way around tika-python because I could not get the XHTML. It seems that you added the xmlContent flag to the parser interface meanwhile (on 1.15, it works). This is great!

Would you mind adding it to the documentation, or do you still consider it too unstable?

from tika-python.

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.