The Maana "Text Extractor" Knowledge Service is able to extract textual information from various file formats (see below) and to convert files to XHTML.
- Files are not locked or encrypted.
- No embedded objects, such as macros, shall be extracted.
- Subscribes to fileAdded events to automatically process supported k:File instances to:
- create an instance of Kind Document
- with extracted text
- link k:File instance via HasKind relation to k:Document
- (this is essentially the mutation below)
- Queries:
- given a k:File, what is extracted text?
- Mutations:
- given a k:File, what is extracted and linked k:Document?
- DOC
- DOCX
- PPT
- PPTX
- XLS
- XLSX
See official Tika documentation for details on the aforementioned types.
| Type/Extension | MIME Type |
|---|---|
| PDF/pdf | application/pdf |
| Older Word Document/doc | application/msword |
| Newer Word Document/docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
| Older PowerPoint/ppt | application/vnd.ms-powerpoint |
| Newer PowerPoint/pptx | application/vnd.openxmlformats-officedocument.presentationml.presentation |
| Older Excel/xls | application/vnd.ms-excel |
| Newer Excel/xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
Content-Type: application/json
| Input | Output |
|---|---|
| Input 1 | Output 1 |
| Input 2 | Output 2 |
| Input 3 | Output 3 |
# Input 1
mutation {
createDoc(
file: {
id:"SOME\_FILE\_ID",
name: "SOME\_FILE\_NAME",
url: "http://SOME\_BASE\_URL/SOME_FILE.xls",
status: 200
}
){id name text}
}# Output 1
{
"data": {
"createDoc": {
"id": "92054dd5-6939-45eb-bac4-a6f95eb70f9c",
"name": "SOME\_FILE\_NAME",
"text": "some text found in the file",
"xhtml": "file content as XHTML"
}
}
}# Input 2
query {
extractText(
file: {
id:"SOME\_FILE\_ID",
name: "SOME\_FILE\_NAME",
url: "http://SOME\_BASE\_URL/SOME_FILE.xls",
status: 200
}
)# Output 2
}
{
"data": {
"extractText": "some text found in the file"
}
}# Input 3
query {
extractXHTML(
file: {
id:"SOME\_FILE\_ID",
name: "SOME\_FILE\_NAME",
url: "http://SOME\_BASE\_URL/SOME_FILE.xls",
status: 200
}
)
}# Output 3
{
"data": {
"extractXHTML": "file content as XHTML"
}
}Language: Scala
Build: SBT
Dependencies:
- Apache Tika parser API - Higher-level parsing (includes non-PDF types) and content-type auto-detection.
- Apache Pdfbox API - Parsing PDF.
- Akka API - Web service/HTTP.
- Sangria API - GraphQL.
- MAANA Q RabbitMQ Service - To be notified when there are new files to process.
- MAANA Q Service - addDocument (persist the extracted text) and addLink (from the file to the document).
Git, Sbt, Java 8, Scala 2.11+
Network access to Maana Q RabbitMQ and File/Document/Link services
If not defined, default local docker settings are used.
MAANA\_TEXT\_EXTRACTOR_PORT - default 8046
PUBLIC\_BACKEND\_URI
\- where dependent services are available (for addDocument, addLink, etc.).
MAANA\_SERVICE\_REQ\_TIMEOUT\_IN_SEC - how long to wait for Q services to return: default 10 seconds
RABBITMQ_ADDR
RABBITMQ_PORT - usually 5672 for cluster Q (25672 for local Q - be sure to stop local rabbitmq)Security-Related Variable(s) against Secure Q
REACT\_APP\_PORTAL\_AUTH\_DOMAIN
REACT\_APP\_PORTAL\_AUTH\_CLIENT_ID
REACT\_APP\_PORTAL\_AUTH\_CLIENT_SECRET
REACT\_APP\_PORTAL\_AUTH\_IDENTIFIER
SAS_CREDENTIALgit clone [ssh://git@bitbucket.corp.maana.io:7999/h4/h4.git](ssh://git@bitbucket.corp.maana.io:7999/h4/h4.git)
Follow instructions on local H4 service build/execution