표 이해
표 이해 보강 기능을 적용하면 문서 내 표 및 표 관련 데이터에 대한 자세한 정보를 확인할 수 있습니다.
다음 작업은 테이블 정보가 포함된 HTML 필드를 생성하고 컬렉션에 대한 테이블 이해 강화 기능을 자동으로 적용합니다:
-
스마트 문서 이해 도구를 사용하여 사용자 학습 또는 사전 학습된 SDU 모델을 정의하는 경우 컬렉션에 대해 생성되는
Table Understanding필드에html보강이 적용됩니다. -
계약용 문서 검색 프로젝트 유형을 생성하면 사전 학습된 SDU 모델이 컬렉션에 자동으로 적용됩니다. 결과적으로 컬렉션에 대해 생성되는
Table Understanding필드에html보강이 적용됩니다.자세한 내용은 스마트 문서 이해 를 참조하세요.
시작하기 전에
컬렉션의 문서에는 테이블의 HTML 표현이 있는 필드가 포함되어 있어야 합니다. 이 정보는 종종 html 필드에 저장됩니다. 컬렉션이 CSV 또는 JSON 파일로 구성된 경우 HTML 형식의 테이블 정보를 포함하는 html 필드 이외의 필드가 있을 수 있습니다.
테이블 이해도 강화 적용
테이블의 HTML 표현이 포함된 필드에만 보강 기능을 적용할 수 있습니다.
풍부함을 적용하려면 다음 단계를 완료하십시오
-
탐색 창에서 컬렉션 관리 페이지를 연 다음 컬렉션을 클릭하여 엽니다.
-
강화 탭을 클릭하십시오.
-
표 이해 심화 학습을 찾아보세요.
-
필드 목록에서 "
html" 필드를 선택합니다.표의 HTML 표현이 포함된 필드를 선택합니다.
보강이 적용된 후에는 테이블에 저장된 정보를 찾기 위해 Discovery가 필요한 쿼리를 제출할 때 유효한 결과를 얻을 수 있습니다.
개발자는 API를 사용하여 테이블을 쿼리할 수 있습니다. 자세한 내용은 쿼리 매개변수 를 참조하세요.
API를 사용하여 테이블 이해도 보강 기능을 적용하는 방법에 대한 자세한 내용은 API를 사용하여 보강 기능 적용하기 를 참조하세요.
Python에서 표 형식 데이터로 작업하기
IBM의 오픈 소스 라이브러리인 판다용 텍스트 확장 프로그램를 사용하여 Discovery의 문서에서 파싱된 테이블을 판다 DataFrame 객체로 읽어들입니다. 판다 DataFrame는 2차원 표 형식의 데이터를 Python에서 다운스트림 분석을 위해 변환 및 조작할 수 있는 형태로 나타내는 개체입니다.
예를 들어, 많은 연례 보고서 문서의 표에서 콘텐츠를 추출하여 관심 있는 여러 해의 데이터 요소를 포함하는 단일 표로 재구성할 수 있습니다. 자세한 내용은 판다를 사용하여 PDF 문서의 테이블에서 구조화된 정보 추출하기 및 IBM Watson 블로그 게시글을 참조하세요.
출력 스키마
Table Understanding 강화의 출력 스키마는 다음과 같습니다.
{
"tables": [
{
"location" : {
"begin" : int,
"end" : int
},
"text": string,
"section_title": {
"text": string,
"location": {
"begin" : int,
"end" : int
}
},
"title": {
"location": {
"begin": int,
"end": int,
},
"text": string
},
"table_headers" : [
{
"cell_id" : string,
"location" : {
"begin" : int,
"end" : int
},
"text" : string,
"row_index_begin" : int,
"row_index_end" : int,
"column_index_begin" : int,
"column_index_end" : int
},
...
],
"column_headers" : [
{
"cell_id" : string,
"location" : {
"begin" : int,
"end" : int
},
"text" : string,
"text_normalized" : string,
"row_index_begin" : int,
"row_index_end" : int,
"column_index_begin" : int,
"column_index_end" : int
},
...
],
"row_headers" : [
{
"cell_id" : string,
"location" : {
"begin" : int,
"end" : int
},
"text" : string,
"text_normalized" : string,
"row_index_begin" : int,
"row_index_end" : int,
"column_index_begin" : int,
"column_index_end" : int
},
...
],
"body_cells" : [
{
"cell_id" : string,
"location" : {
"begin" : int,
"end" : int
},
"text" : string,
"row_index_begin" : int,
"row_index_end" : int,
"column_index_begin" : int,
"column_index_end" : int,
"row_header_ids": [ string ],
"row_header_texts": [ string ],
"row_header_texts_normalized": [ string ],
"column_header_ids": [ string ],
"column_header_texts": [ string ],
"column_header_texts_normalized": [ string ],
"attributes" : [
{
"type" : string,
"text" : string,
"location" : {
"begin" : int,
"end" : int
}
},
...
]
},
...
],
"key_value_pairs": [
{
"key": {
"cell_id": string,
"location": {
"begin": int,
"end": int
},
"text": string
},
"value": [{
"cell_id": string,
"location": {
"begin": int,
"end": int
},
"text": string
},
...
]
},
...
],
"contexts": [
{
"text": string,
"location": {
"begin": int,
"end": int
}
},
...
]
}
]
}
스키마 배치
스키마는 다음으로 구성되어 있습니다.
-
tables: 입력 문서에서 식별되는 테이블을 정의하는 배열입니다.-
location: 현재 테이블의 위치이며 입력 문서에서begin및end인덱스로 정의됩니다. -
text: 연관된 마크업 컨텐츠가 없는 입력 문서에 있는 현재 테이블의 텍스트 컨텐츠입니다. -
section_title: 현재 테이블에 포함된 섹션 제목의 위치입니다(식별되는 경우). 섹션 제목이 식별되지 않으면 비어 있습니다.text: 식별된 섹션 제목의 텍스트입니다.location: 섹션 제목의 위치이며 입력 문서에서begin및end인덱스로 정의됩니다.
-
title: 식별된 경우,Table x.: ...양식의 현재 테이블의 제목 또는 캡션입니다. 제목이 식별되지 않으면 비어 있습니다.title가 존재하는 경우, 동일한 테이블의contexts배열에서 제외됩니다.location: 제목의 위치이며 입력 문서에서begin및end인덱스로 정의됩니다.text: 식별된 테이블 제목 또는 캡션의 텍스트입니다.
-
table_headers: 현재 테이블의 모든 기타 셀에 대한 헤더로 사용할 수 있는 테이블 레벨 셀의 배열입니다. 각 테이블 헤더는 다음 요소의 콜렉션으로 정의됩니다.cell_id: 현재 테이블에 있는 셀의 고유 ID입니다.location: 셀의 위치이며 입력 문서에서begin및end인덱스로 정의됩니다.text: 연관된 마크업 컨텐츠가 없는 입력 문서에 있는 셀의 텍스트 컨텐츠입니다.row_index_begin: 현재 테이블에 있는 셀의begin위치에 대한row인덱스입니다.row_index_end: 현재 테이블에 있는 셀의end위치에 대한row인덱스입니다.column_index_begin: 현재 테이블에 있는 셀의begin위치에 대한column인덱스입니다.column_index_end: 현재 테이블에 있는 셀의end위치에 대한column인덱스입니다.
-
column_headers: 열 레벨 셀의 배열입니다. 각각을 현재 테이블과 동일한 열에 있는 다른 셀의 헤더로 사용할 수 있습니다. 각 열 헤더는 다음 항목의 콜렉션으로 정의됩니다.cell_id: 현재 테이블에 있는 셀의 고유 ID입니다.location: 셀의 위치이며 입력 문서에서begin및end인덱스로 정의됩니다.text: 연관된 마크업 컨텐츠가 없는 입력 문서에 있는 셀의 텍스트 컨텐츠입니다.text_normalized: 정규화된 열 머리글 텍스트입니다.row_index_begin: 현재 테이블에 있는 셀의begin위치에 대한row인덱스입니다.row_index_end: 현재 테이블에 있는 셀의end위치에 대한row인덱스입니다.column_index_begin: 현재 테이블에 있는 셀의begin위치에 대한column인덱스입니다.column_index_end: 현재 테이블에 있는 셀의end위치에 대한column인덱스입니다.
-
row_headers: 행 레벨 셀의 배열입니다. 각각을 현재 테이블과 동일한 행에 있는 다른 셀의 헤더로 사용할 수 있습니다. 각 행 헤더는 다음 항목의 콜렉션으로 정의됩니다.cell_id: 현재 테이블에 있는 셀의 고유 ID입니다.location: 셀의 위치이며 입력 문서에서begin및end인덱스로 정의됩니다.text: 연관된 마크업 컨텐츠가 없는 입력 문서에 있는 셀의 텍스트 컨텐츠입니다.text_normalized: 정규화된 행 머리글 텍스트입니다.row_index_begin: 현재 테이블에 있는 셀의begin위치에 대한row인덱스입니다.row_index_end: 현재 테이블에 있는 셀의end위치에 대한row인덱스입니다.column_index_begin: 현재 테이블에 있는 셀의begin위치에 대한column인덱스입니다.column_index_end: 현재 테이블에 있는 셀의end위치에 대한column인덱스입니다.
-
body_cells: 해당 행 및 열 헤더가 연관된 현재 테이블의 테이블 헤더 또는 열 헤더 또는 행 헤더 셀이 아닌 셀의 배열입니다. 각 본문 셀은 다음 항목의 콜렉션으로 정의됩니다.-
cell_id: 현재 테이블에 있는 셀의 고유 ID입니다. -
location: 셀의 위치이며 입력 문서에서begin및end인덱스로 정의됩니다. -
text: 연관된 마크업 컨텐츠가 없는 입력 문서에 있는 셀의 텍스트 컨텐츠입니다. -
row_index_begin: 현재 테이블에 있는 이 셀의begin위치에 대한row인덱스입니다. -
row_index_end: 현재 테이블에 있는 이 셀의end위치에 대한row인덱스입니다. -
column_index_begin: 현재 테이블에 있는 이 셀의begin위치에 대한column인덱스입니다. -
column_index_end: 현재 테이블에 있는 이 셀의end위치에 대한column인덱스입니다. -
row_header_ids: 값의 배열로, 각 값은 이 본문 셀과 관련된 행 머리글의 셀 ID 값입니다. -
row_header_texts: 값 배열로, 각 값은 이 본문 셀의 행 헤더에 있는 텍스트입니다. -
row_header_texts_normalized: 값 배열로, 각 값은 이 본문 셀의 행 헤더에서 정규화된 텍스트입니다. -
column_header_ids: 값의 배열로, 각 값은 이 본문 셀과 관련된 열 머리글의 셀 ID 값입니다. -
column_header_texts: 값 배열로, 각 값은 이 본문 셀의 열 머리글에 있는 텍스트입니다. -
column_header_texts_normalized: 값의 배열로, 각 값은 이 본문 셀의 열 머리글에서 정규화된 텍스트입니다. -
attributes: 문서 속성을 식별하는 배열입니다. 배열의 각 오브젝트는 3개의 요소로 구성됩니다.type: 속성의 유형입니다. 가능한 값은Address,Currency,DateTime,Duration,Location,Number,Organization,Percentage및Person입니다.text: 속성과 연관된 텍스트입니다.location: 속성의 위치이며begin및end인덱스로 정의됩니다.
-
-
key_value_pairs: 입력 문서의 테이블에서 키-값 쌍을 지정하는 배열입니다. 자세한 정보는 키-값 쌍 이해를 참조하십시오.-
key: 키-값 쌍에 대한 키를 지정하는 오브젝트입니다.cell_id: 테이블에 있는 키의 고유 ID입니다.location: 키 셀의 위치이며 입력 문서에서begin및end인덱스로 정의됩니다.text: HTML 마크업이 없는 테이블 셀의 텍스트 컨텐츠입니다.
-
value: 키-값 쌍의 값을 지정하는 배열입니다.cell_id: 테이블에 있는 값의 고유 ID입니다.location: 값 셀의 위치이며 입력 문서에서begin및end인덱스로 정의됩니다.text: HTML 마크업이 없는 테이블 셀의 텍스트 컨텐츠입니다.
-
-
contexts: 테이블 앞뒤에 오는 관련 자료 목록이며(섹션 제목 제외),section_title필드에 제공됩니다. 관련 자료에는 관련 문장, 각주, 그리고 테이블을 참조하는 문서의 다른 부분의 문장이 포함되어 있습니다. 목록은 배열로 표시됩니다. 배열의 각 오브젝트는 다음 요소로 구성됩니다.text: HTML 마크업이 없는, 입력 문서의 관련 자료의 텍스트 컨텐츠입니다.location: 관련 자료의 위치이며 입력 문서에서begin및end인덱스로 정의됩니다.
-
테이블 출력 스키마에 대한 참고사항
- 셀당 행 및 열 인덱스 값은 0 기반이므로
0부터 시작하십시오. row_header_ids및row_header_texts요소 배열의 다중 값은 행 헤더의 가능한 계층 구조를 나타냅니다.column_header_ids및column_header_texts요소 배열의 다중 값은 열 헤더의 가능한 계층 구조를 나타냅니다.
예제
다음 표는 입력 문서의 예제 표입니다.
테이블은 다음과 같이 구성되어 있습니다
표에는 다음 구문이 사용됩니다:
- 굵은체 텍스트는 열 헤더를 표시함
- 기울임꼴 텍스트 는 행 머리글을 나타냅니다
- 스타일이 지정되지 않은 텍스트는 본문 셀을 표시함
서비스의 출력은 예제의 첫 번째 본체 셀(즉, 값이 35.0% 인 3행의 첫 번째 셀)을 다음과 같이 나타냅니다
{
"tables": [ {
"location": {
"begin": 872,
"end": 5879
},
"text": "...",
"section_title": {
"text": "",
"location": {
"begin": 0,
"end": 0
}
},
"table_headers" : [ ],
"column_headers" : [ {
"cell_id" : "colHeader-1050-1082",
"location" : {
"begin" : 1050,
"end" : 1083
},
"text" : "Three months ended September 30,",
"text_normalized" : "Three months ended September 30,",
"row_index_begin" : 0,
"row_index_end" : 0,
"column_index_begin" : 1,
"column_index_end" : 2
}, {
"cell_id" : "colHeader-1270-1301",
"location" : {
"begin" : 1270,
"end" : 1302
},
"text" : "Nine months ended September 30,",
"text_normalized" : "Nine months ended September 30,",
"row_index_begin" : 0,
"row_index_end" : 0,
"column_index_begin" : 3,
"column_index_end" : 4
}, {
"cell_id" : "colHeader-1544-1548",
"location" : {
"begin" : 1544,
"end" : 1549
},
"text" : "2005",
"text_normalized" : "Year 1",
"row_index_begin" : 1,
"row_index_end" : 1,
"column_index_begin" : 1,
"column_index_end" : 1
}, {
"cell_id" : "colHeader-1712-1716",
"location" : {
"begin" : 1712,
"end" : 1717
},
"text" : "2004",
"text_normalized" : "Year 2",
"row_index_begin" : 1,
"row_index_end" : 1,
"column_index_begin" : 2,
"column_index_end" : 2
}, {
"cell_id" : "colHeader-1889-1893",
"location" : {
"begin" : 1889,
"end" : 1894
},
"text" : "2005",
"text_normalized" : "Year 1",
"row_index_begin" : 1,
"row_index_end" : 1,
"column_index_begin" : 3,
"column_index_end" : 3
}, {
"cell_id" : "colHeader-2057-2061",
"location" : {
"begin" : 2057,
"end" : 2062
},
"text" : "2004",
"text_normalized" : "Year 2",
"row_index_begin" : 1,
"row_index_end" : 1,
"column_index_begin" : 4,
"column_index_end" : 4
} ],
"row_headers" : [ {
"cell_id" : "rowHeader-2244-2262",
"location" : {
"begin" : 2244,
"end" : 2263
},
"text" : "Statutory tax rate",
"text_normalized" : "Statutory tax rate",
"row_index_begin" : 2,
"row_index_end" : 2,
"column_index_begin" : 0,
"column_index_end" : 0
}, {
"cell_id" : "rowHeader-3197-3217",
"location" : {
"begin" : 3197,
"end" : 3218
},
"text" : "IRS audit settlement",
"text_normalized" : "IRS audit settlement",
"row_index_begin" : 3,
"row_index_end" : 3,
"column_index_begin" : 0,
"column_index_end" : 0
}, {
"cell_id" : "rowHeader-4148-4176",
"location" : {
"begin" : 4148,
"end" : 4177
},
"text" : "Dividends received deduction",
"text_normalized" : "Dividends received deduction",
"row_index_begin" : 4,
"row_index_end" : 4,
"column_index_begin" : 0,
"column_index_end" : 0
}, {
"cell_id" : "rowHeader-5106-5130",
"location" : {
"begin" : 5106,
"end" : 5131
},
"text" : "Total effective tax rate",
"text_normalized" : "Total effective tax rate",
"row_index_begin" : 5,
"row_index_end" : 5,
"column_index_begin" : 0,
"column_index_end" : 0
} ],
"key_value_pairs" : [ ],
"body_cells" : [ {
"cell_id" : "bodyCell-2450-2455",
"location" : {
"begin" : 2450,
"end" : 2456
},
"text" : "35.0%",
"row_index_begin" : 2,
"row_index_end" : 2,
"column_index_begin" : 1,
"column_index_end" : 1,
"row_header_ids" : [ "rowHeader-2244-2262" ],
"row_header_texts" : [ "Statutory tax rate" ],
"row_header_texts_normalized" : [ "Statutory tax rate" ],
"column_header_ids" : [ "colHeader-1050-1082", "colHeader-1544-1548" ],
"column_header_texts" : [ "Three months ended September 30,", "2005" ],
"column_header_texts_normalized" : [ "Three months ended September 30,", "Year 1" ],
"attributes": [ ]
}, {
"cell_id" : "bodyCell-2633-2638",
"location" : {
"begin" : 2633,
"end" : 2639
},
"text" : "35.0%",
"row_index_begin" : 2,
"row_index_end" : 2,
"column_index_begin" : 2,
"column_index_end" : 2,
"row_header_ids" : [ "rowHeader-2244-2262" ],
"row_header_texts" : [ "Statutory tax rate" ],
"row_header_texts_normalized" : [ "Statutory tax rate" ],
"column_header_ids" : [ "colHeader-1050-1082", "colHeader-1712-1716" ],
"column_header_texts" : [ "Three months ended September 30,", "2004" ],
"column_header_texts_normalized" : [ "Three months ended September 30,", "Year 2" ],
"attributes": [ ]
}, {
"cell_id" : "bodyCell-2825-2830",
"location" : {
"begin" : 2825,
"end" : 2831
},
"text" : "35.0%",
"row_index_begin" : 2,
"row_index_end" : 2,
"column_index_begin" : 3,
"column_index_end" : 3,
"row_header_ids" : [ "rowHeader-2244-2262" ],
"row_header_texts" : [ "Statutory tax rate" ],
"row_header_texts_normalized" : [ "Statutory tax rate" ],
"column_header_ids" : [ "colHeader-1270-1301", "colHeader-1889-1893" ],
"column_header_texts" : [ "Nine months ended September 30,", "2005" ],
"column_header_texts_normalized" : [ "Nine months ended September 30,", "Year 1" ],
"attributes": [ ]
}, {
"cell_id" : "bodyCell-3008-3013",
"location" : {
"begin" : 3008,
"end" : 3014
},
"text" : "35.0%",
"row_index_begin" : 2,
"row_index_end" : 2,
"column_index_begin" : 4,
"column_index_end" : 4,
"row_header_ids" : [ "rowHeader-2244-2262" ],
"row_header_texts" : [ "Statutory tax rate" ],
"row_header_texts_normalized" : [ "Statutory tax rate" ],
"column_header_ids" : [ "colHeader-1270-1301", "colHeader-2057-2061" ],
"column_header_texts" : [ "Nine months ended September 30,", "2004" ],
"column_header_texts_normalized" : [ "Nine months ended September 30,", "Year 2" ],
"attributes": [ ]
},
...
],
"contexts": [ ]
}
키와 값 쌍에 대한 이해
테이블은 여러 개의 테이블 셀에 걸쳐 있는 키-값 쌍을 포함하는 경우가 있습니다. 표 이해 기능은 다음과 같은 유형의 표 쌍을 감지할 수 있습니다.
-
다음 예제 표와 같이 인접한 셀에 있는 간단한 키-값 쌍:
기본 표 키 값 품목 번호 123456789날짜 1/1/2019양 $1,000 -
다음 예제 표와 같이 같은 셀에 키-값 쌍이 있습니다
복합 표 키-값 쌍 키-값 쌍 항목 번호: 123456789금액: $1000날짜: 1/1/2019주소: 123 Anywhere Dr