Tika
  1. Tika
  2. TIKA-814

Increase the amount of bytes read by TextDetector

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.1
    • Component/s: None
    • Labels:
      None

      Description

      In TIKA-688 Jukka implemented a plain text detector. It is fired automatically inside MimeTypes. I find a number of files in my collections, which are binary but are still detected as plain text. They wouldn't be if the plain text detector were allowed to look at more than the initial 512 bytes. I think that the TextDetector should look at MimeTypes.getMinLength bytes. It is given a ByteArrayInputStream backed by an Array. It should read all bytes in that array.

      The performance impact should be negligible (no I/O, no allocations, just pure array lookups), while my experiments show that there are cases when 512 bytes is not enough.

      If anyone objects due to performance reasons, I'll create another patch, which will allow the users to decouple the TextDetector from MimeTypes and supply their own, with different settings.

        Activity

        Hide
        Antoni Mylka added a comment -

        A patch, which makes the text detector work on the entire array supplied by MimeTypes

        Show
        Antoni Mylka added a comment - A patch, which makes the text detector work on the entire array supplied by MimeTypes
        Hide
        Antoni Mylka added a comment -

        Committed in r1220698.

        This is a change, which theoretically impacts all users of Tika invoking MimeTypes. I say it has negligible performance overhead and yields better results on 5 broken BMP files I have in my collections.

        If you disagree: revert the change and reopen this issue. I'll create a second solution, with customizable plain text detection.

        For now, I close this.

        Show
        Antoni Mylka added a comment - Committed in r1220698. This is a change, which theoretically impacts all users of Tika invoking MimeTypes. I say it has negligible performance overhead and yields better results on 5 broken BMP files I have in my collections. If you disagree: revert the change and reopen this issue. I'll create a second solution, with customizable plain text detection. For now, I close this.

          People

          • Assignee:
            Unassigned
            Reporter:
            Antoni Mylka
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development