楼主: Lisrelchen
1851 9

【Apache Tika】Apache Tika Content Detection [推广有奖]

  • 0关注
  • 62粉丝

VIP

已卖:4194份资源

院士

67%

还不是VIP/贵宾

-

TA的文库  其他...

Bayesian NewOccidental

Spatial Data Analysis

东西方数据挖掘

威望
0
论坛币
50288 个
通用积分
83.6906
学术水平
253 点
热心指数
300 点
信用等级
208 点
经验
41518 点
帖子
3256
精华
14
在线时间
766 小时
注册时间
2006-5-4
最后登录
2022-11-6

楼主
Lisrelchen 发表于 2017-3-12 07:20:02 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
Apache Tika Content Detection

[size=17.3333339691162px]This page gives you information on how content and language detection works with Apache Tika, and how to tune the behaviour of Tika.


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:detection Content apache Detect PAC default content Magic

沙发
Lisrelchen 发表于 2017-3-12 07:21:42
  1. Mime Magic Detection

  2. By looking for special ("magic") patterns of bytes near the start of the file, it is often possible to detect the type of the file. For some file types, this is a simple process. For others, typically container based formats, the magic detection may not be enough. (More detail on detecting container formats below)

  3. Tika is able to make use of a a mime magic info file, in the Freedesktop MIME-info format to peform mime magic detection. (Note that Tika supports a few more match types than Freedesktop does)

  4. This is provided within Tika by org.apache.tika.detect.MagicDetector. It is most commonly access via org.apache.tika.mime.MimeTypes, normally sourced from the tika-mimetypes.xml and custom-mimetypes.xml files. For more information on defining your own custom mimetypes, see the new parser guide.
复制代码

藤椅
Lisrelchen 发表于 2017-3-12 07:22:18
  1. Resource Name Based Detection

  2. Where the name of the file is known, it is sometimes possible to guess the file type from the name or extension. Within the tika-mimetypes.xml file is a list of patterns which are used to identify the type from the filename.

  3. However, because files may be renamed, this method of detection is quick but not always as accurate.

  4. This is provided within Tika by org.apache.tika.detect.NameDetector.
复制代码

板凳
Lisrelchen 发表于 2017-3-12 07:22:45
  1. Ways of triggering Detection

  2. The simplest way to detect is through the Tika Facade class, which provides methods to detect based on File, InputStream, InputStream and Filename, Filename or a few others. It works best with a File or TikaInputStream.

  3. Alternately, detection can be performed on a specific Detector, or using DefaultDetector to have all available Detectors used. A typical pattern would be something like:

  4. TikaConfig tika = new TikaConfig();

  5. for (File f : myListOfFiles) {
  6.    Metadata metadata = new Metadata();
  7.    metadata.set(Metadata.RESOURCE_NAME_KEY, f.toString());
  8.    String mimetype = tika.getDetector().detect(
  9.         TikaInputStream.get(f), metadata);
  10.    System.out.println("File " + f + " is " + mimetype);
  11. }
  12. for (InputStream is : myListOfStreams) {
  13.    String mimetype = tika.getDetector().detect(
  14.         TikaInputStream.get(is), new Metadata());
  15.    System.out.println("Stream " + is + " is " + mimetype);
  16. }
复制代码

报纸
auirzxp 学生认证  发表于 2017-3-12 07:28:36
提示: 作者被禁止或删除 内容自动屏蔽

地板
MouJack007 发表于 2017-3-12 08:07:07
谢谢楼主分享!

7
MouJack007 发表于 2017-3-12 08:07:30

8
钱学森64 发表于 2017-3-12 09:32:15
谢谢分享

9
franky_sas 发表于 2017-3-12 12:47:36

10
kkkm_db 发表于 2017-3-13 05:24:04
谢谢分享

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-10 19:46