docs: update access elements#262
Conversation
Codecov Report
@@ Coverage Diff @@
## main #262 +/- ##
=======================================
Coverage 86.16% 86.16%
=======================================
Files 134 134
Lines 6160 6160
=======================================
Hits 5308 5308
Misses 852 852
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
| ## Index by multi-modal attributes | ||
| In case you define a multi-modal Document schema and you create a DocumentArray of multi-modal Documents, you can | ||
| select attributes inside each Document: | ||
|
|
||
| ```python | ||
| from docarray import Document, DocumentArray | ||
| from docarray.dataclasses.types import dataclass, Text, Image | ||
|
|
||
|
|
||
| @dataclass | ||
| class MultiModalDocument: | ||
| text: Text | ||
| image: Image | ||
|
|
||
|
|
||
| da = DocumentArray( | ||
| [ | ||
| Document(MultiModalDocument(text='cat', image='cat.jpg')), | ||
| Document(MultiModalDocument(text='dog', image='dog.jpg')), | ||
| Document(MultiModalDocument(text='bird', image='bird.jpg')), | ||
| ] | ||
| ) | ||
|
|
||
| # plot images | ||
| da['@r.[image]'].plot_image_sprites() | ||
|
|
||
| # print text attributes | ||
| for text_doc in da['@r.[text]']: | ||
| print(text_doc.text) | ||
|
|
||
| # select both attributes | ||
| da['@r.[image, text]'] | ||
|
|
||
| # select attributes of the Documents at a given postion | ||
| da['@r[1].[text]'] | ||
| ``` | ||
|
|
||
|
|
There was a problem hiding this comment.
please read the new docs before continuing on this PR, this section needs a rewrite and not needed at all
There was a problem hiding this comment.
Should I completely remove the section (and keep the other minor changes) or remove the content and point to the selection documented in the dataclass section ?
|
📝 Docs are deployed on https://ft-docs-update-access-elements--jina-docs.netlify.app 🎉 |
docs: update access elements page