### 3D Graphics Setup with Visual Module Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Initializes a 3D scene using the 'visual' module, setting the scene range and center, and drawing a single blue sphere. Requires the 'visual' module to be installed. ```Python from visual import * scene.range = (256, 256, 256) scene.center = (128, 128, 128) color = (0.1, 0.1, 0.9) # mostly blue sphere(pos=scene.center, radius=128, color=color) ``` -------------------------------- ### Install necessary libraries Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/retrieval_qdrant.ipynb Install the qdrant-client, docling, and fastembed libraries. A kernel restart might be required after installation. ```python %pip install --no-warn-conflicts -q qdrant-client docling fastembed ``` -------------------------------- ### Install Docling and Dependencies Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/serialization.ipynb Installs the necessary Docling packages and their dependencies using pip. A kernel restart might be required after installation. ```python %pip install -qU pip docling docling-core~=2.29 rich ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/installation/index.md Run this command from your local clone's root directory to install all necessary development dependencies and extras for Docling. ```bash uv sync --all-extras ``` -------------------------------- ### Install Docling and Dependencies Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/pictures_description.ipynb Installs the docling library with VLM support and ipython for interactive environments. A kernel restart might be necessary after installation. ```python %pip install -q docling[vlm] ipython ``` -------------------------------- ### Install Docling with pip Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/installation/index.md Install the Docling package using pip. This is the primary method for installation. ```bash pip install docling ``` -------------------------------- ### Create and Display a Basic GUI Window Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md This snippet demonstrates how to initialize a GUI window with a title and start the Tkinter event loop. Ensure Swampy or Gui module is installed and imported correctly. ```Python from swampy.Gui import * g = Gui() g.title('Gui') g.mainloop() ``` -------------------------------- ### Install Flash Attention Package Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/faq/index.md Install the Flash Attention library, either by building from sources or using pre-built wheels. Building from sources requires a CUDA development environment. ```shell # Building from sources (required the CUDA dev environment) pip install flash-attn # Using pre-built wheels (not available in all possible setups) FLASH_ATTENTION_SKIP_CUDA_BUILD=TRUE pip install flash-attn ``` -------------------------------- ### Install Docling with CPU-only PyTorch for Linux Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/installation/index.md Install Docling with a CPU-only PyTorch distribution, recommended for Linux systems without dedicated GPUs. ```bash # Example for installing on the Linux cpu-only version pip install docling --extra-index-url https://download.pytorch.org/whl/cpu ``` -------------------------------- ### Install Docling and Transformers Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/hybrid_chunking.ipynb Installs the necessary libraries for using Docling and its dependencies like transformers. A kernel restart might be required after installation. ```python %pip install -qU pip docling transformers ``` -------------------------------- ### Install and Run the Excel Analysis Agent Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Mainstream Framework Integration/scipy_agent/README.md Installs project dependencies and runs the main application script. ```bash pip install -r requirements.txt python app/main.py ``` -------------------------------- ### Install Docling, Weaviate Client, Rich, and PyTorch Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/rag_weaviate.ipynb Installs necessary Python packages for Docling, Weaviate client, rich for output formatting, and PyTorch for potential GPU acceleration. It also suppresses specific warnings and Weaviate client logs for cleaner output. ```python %%capture %pip install docling~="2.7.0" %pip install -U weaviate-client~="4.9.4" %pip install rich %pip install torch import logging import warnings warnings.filterwarnings("ignore") # Suppress Weaviate client logs logging.getLogger("weaviate").setLevel(logging.ERROR) ``` -------------------------------- ### Setup Test Document Directory Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/rag_llamaindex.ipynb Prepares a temporary directory and downloads a PDF file to it for demonstration purposes. Requires `pathlib`, `tempfile`, and `requests`. ```python from pathlib import Path from tempfile import mkdtemp import requests tmp_dir_path = Path(mkdtemp()) r = requests.get(SOURCE) with open(tmp_dir_path / f"{Path(SOURCE).name}.pdf", "wb") as out_file: out_file.write(r.content) ``` -------------------------------- ### Install Tesserocr with specific options Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/installation/index.md Troubleshooting installation for the Tesserocr Python package by using specific pip install options. ```console pip uninstall tesserocr pip install --no-binary :all: tesserocr ``` -------------------------------- ### List Available MarkItDown Plugins Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/markitdown-aspose-cells-plugin/README.md Verify that the installed plugin is recognized by MarkItDown by listing all available plugins. This command should show the newly installed plugin. ```bash markitdown --list-plugins ``` -------------------------------- ### Install Docling with RapidOCR Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/installation/index.md Install the RapidOCR extra feature for Docling, which is not included in the default installation. ```bash pip install rapidocr_onnxruntime ``` -------------------------------- ### Install Tesseract OCR on RHEL Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/installation/index.md Install Tesseract OCR and language packs on RHEL-based systems and set the TESSDATA_PREFIX. ```bash dnf install tesseract tesseract-devel tesseract-langpack-eng tesseract-osd leptonica-devel TESSDATA_PREFIX=/usr/share/tesseract/tessdata/ echo "Set TESSDATA_PREFIX=${TESSDATA_PREFIX}" ``` -------------------------------- ### Install Docling Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/README.md Install the Docling package using pip. This command installs the package in editable mode. ```bash pip install -e . ``` -------------------------------- ### Install Pre-commit Hook Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/CONTRIBUTING.md Install the `pre-commit` framework to automatically run styling and validation checks before each commit. This ensures code quality and consistency. ```bash pre-commit install ``` -------------------------------- ### Install Marker PDF Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/README.md Installs the marker-pdf package. Use the [full] extra to include dependencies for non-PDF documents. ```shell pip install marker-pdf ``` ```shell pip install marker-pdf[full] ``` -------------------------------- ### Install Docling with Compatible PyTorch (pip) Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/installation/index.md Use this command if you are a pip user to install Docling with the necessary PyTorch compatibility for Intel Macs. ```bash # For pip users pip install "docling[mac_intel]" ``` -------------------------------- ### Install Docling (Poetry) Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/installation/index.md Use this command if you are a Poetry user to add Docling to your project. ```bash # For Poetry users poetry add docling ``` -------------------------------- ### Install Dependencies Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/rag_milvus.ipynb Installs the necessary Python packages for Milvus, Docling, OpenAI, and PyTorch. If using Google Colab, a runtime restart may be required after installation. ```python ! pip install --upgrade pymilvus docling openai torch ``` -------------------------------- ### Installing docling-core with chunking-openai extra Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/concepts/chunking.md Install the 'chunking-openai' extra for docling-core if you prefer using OpenAI's tiktoken tokenizer with HybridChunker. This ensures compatibility with OpenAI's tokenization methods. ```shell pip install 'docling-core[chunking-openai]' ``` -------------------------------- ### Install LlamaIndex and Docling Packages Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/rag_llamaindex.ipynb Installs the core LlamaIndex library along with specific Docling extensions for readers, node parsers, embeddings, LLMs, and vector stores. Includes packages for file reading and environment variable loading. Use `--no-warn-conflicts` for Colab environments. ```python %pip install -q --progress-bar off --no-warn-conflicts llama-index-core llama-index-readers-docling llama-index-node-parser-docling llama-index-embeddings-huggingface llama-index-llms-huggingface-api llama-index-vector-stores-milvus llama-index-readers-file python-dotenv ``` -------------------------------- ### Install Required Libraries Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/rag_azuresearch.ipynb Installs the necessary Python packages for Docling, Azure AI Search, Azure OpenAI, and other utilities. Uncomment and run this command in a fresh environment like Google Colab. ```python # If running in a fresh environment (like Google Colab), uncomment and run this single command: %pip install "docling~=2.12" azure-search-documents==11.5.2 azure-identity openai rich torch python-dotenv ``` -------------------------------- ### Simple For Loop Example Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Demonstrates a basic for loop that prints 'Hello!' multiple times. This is a simple illustration of loop syntax. ```python for i in range(4): print 'Hello!' ``` -------------------------------- ### Install Tesseract OCR on Debian-based Linux Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/installation/index.md Install Tesseract OCR and related libraries on Debian-based systems and determine the TESSDATA_PREFIX. ```bash apt-get install tesseract-ocr tesseract-ocr-eng libtesseract-dev libleptonica-dev pkg-config TESSDATA_PREFIX=$(dpkg -L tesseract-ocr-eng | grep tessdata$) echo "Set TESSDATA_PREFIX=${TESSDATA_PREFIX}" ``` -------------------------------- ### Install LangChain Docling and Dependencies Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/visual_grounding.ipynb Installs necessary Python packages for using LangChain with Docling, including Milvus and Hugging Face integrations. Use `--no-warn-conflicts` for Colab environments. ```python %pip install -q --progress-bar off --no-warn-conflicts langchain-docling langchain-core langchain-huggingface langchain_milvus langchain matplotlib python-dotenv ``` -------------------------------- ### Installing docling-core with chunking extra Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/concepts/chunking.md Install the 'chunking' extra for docling-core if you need HuggingFace tokenizers with HybridChunker. This is required for certain tokenizer functionalities. ```shell pip install 'docling-core[chunking]' ``` -------------------------------- ### Install Docling with Compatible PyTorch (uv) Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/installation/index.md Use this command if you are a uv user to install Docling along with a compatible PyTorch version (2.2.2) and torchvision. ```bash # For uv users uv add torch==2.2.2 torchvision==0.17.2 docling ``` -------------------------------- ### Install Scikit-learn, Aspose.Cells, and NumPy Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Mainstream Framework Integration/Scikit-learn/ReadMe.md Install the necessary Python packages using pip. This command ensures you have Scikit-learn for machine learning, Aspose.Cells for Excel operations, and NumPy for numerical computations. ```bash pip install aspose-cells-python scikit-learn numpy ``` -------------------------------- ### Install Docling with OnnxTR OCR engine Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/installation/index.md Install the OnnxTR OCR engine for Docling using the plugin system, specifying CPU support. ```bash pip install "docling-ocr-onnxtr[cpu]" ``` -------------------------------- ### Run Django Development Server Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Mainstream Framework Integration/Django/README.md Execute this command in your project's root directory to start the Django development server. ```bash python manage.py runserver ``` -------------------------------- ### Install LangChain and Dependencies Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/rag_langchain.ipynb Installs necessary LangChain packages including docling, core, Hugging Face, Milvus, and python-dotenv. Use `--no-warn-conflicts` for Colab environments. ```python %pip install -q --progress-bar off --no-warn-conflicts langchain-docling langchain-core langchain-huggingface langchain_milvus langchain python-dotenv ``` -------------------------------- ### Install Dependencies for Docling Haystack Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/rag_haystack.ipynb Installs necessary libraries for using Docling with Haystack, Milvus, and Sentence Transformers. Use `--no-warn-conflicts` for Colab environments. ```python %pip install -q --progress-bar off --no-warn-conflicts docling-haystack haystack-ai docling pymilvus milvus-haystack sentence-transformers python-dotenv ``` -------------------------------- ### Python Dictionary Get Method Example Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Illustrates the usage of the dictionary's `get` method to retrieve a value associated with a key, providing a default value if the key is not found. This is used to simplify the histogram function. ```python >>> h = histogram('a') >>> print h {'a': 1} >>> h.get('a', 0) 1 >>> h.get('b', 0) 0 ``` -------------------------------- ### Create Canvas and Column Frame Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Initializes a white canvas and starts a new column frame for subsequent widgets. This is part of the GUI setup process. ```python self.canvas = self.ca(width=400, height=400, bg='white') self.col() ``` -------------------------------- ### Setup Lumpy and Poker Hand Example Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Initializes Lumpy and creates instances of Deck and PokerHand, moving cards to the hand. This sets up a more complex scenario for class diagram generation. ```python from swampy.Lumpy import Lumpy from PokerHand import * lumpy = Lumpy() lumpy.make_reference() deck = Deck() hand = PokerHand() deck.move_cards(hand, 7) ``` -------------------------------- ### Python Setup.py Entrypoint for Docling Plugin Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/concepts/plugins.md Registers a Docling plugin within a setup.py file using setuptools. The 'docling' key in entry_points maps the plugin name to its module. ```python from setuptools import setup setup( # ..., entry_points = { 'docling': [ 'your_plugin_name = "your_package.module"' ] } ) ``` -------------------------------- ### Get Shape of a List of Tuples using structshape Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md This example demonstrates how structshape analyzes a list of tuples, showing the types of elements within each tuple. It requires prior creation of the list of tuples, for instance, using zip. ```python >>> s = 'abc' >>> lt = zip(t, s) >>> print structshape(lt) list of 3 tuple of (int, str) ``` -------------------------------- ### Initialize Qdrant Client and Document Converter Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/retrieval_qdrant.ipynb Set up the Qdrant client to use in-memory mode for prototyping and initialize the DocumentConverter to handle HTML input formats. For production, use the Qdrant Docker image. ```python COLLECTION_NAME = "docling" doc_converter = DocumentConverter(allowed_formats=[InputFormat.HTML]) client = QdrantClient(location=":memory:") # The :memory: mode is a Python imitation of Qdrant's APIs for prototyping and CI. # For production deployments, use the Docker image: docker run -p 6333:6333 qdrant/qdrant ``` -------------------------------- ### Creating a dictionary using dict and zip Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Illustrates a concise method to create a dictionary by combining the dict() constructor with the zip() function. ```Python >>> d = dict(zip('abc', range(3))) >>> print d {'a': 0, 'c': 2, 'b': 1} ``` -------------------------------- ### Initialize Qdrant Client Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/retrieval_qdrant.ipynb Initializes a Qdrant client to connect to a local Qdrant instance. Ensure Qdrant is running on the specified location. ```python client = QdrantClient(location="http://localhost:6333") ``` -------------------------------- ### Create and Sync Project Environment with uv Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/CONTRIBUTING.md Use `uv sync` to create a virtual environment and install project dependencies. This command ensures your local environment matches the project's requirements. ```bash uv sync ``` -------------------------------- ### Open and Create a Database with anydbm Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Opens a database file, creating it if it does not exist. The 'c' mode is used for creation. ```python import anydbm db = anydbm.open('captions.db', 'c') ``` -------------------------------- ### Initialize Qdrant Client and Set Models Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/retrieval_qdrant.ipynb Initializes the Qdrant client and sets the models for text and sparse embeddings. Ensure Qdrant is running locally on the default port. ```python client = QdrantClient(location="http://localhost:6333") client.set_model("sentence-transformers/all-MiniLM-L6-v2") client.set_sparse_model("Qdrant/bm25") ``` -------------------------------- ### Initialize Milvus Vector Store and Index Documents Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/backend_xml_rag.ipynb Sets up a Milvus vector store and indexes documents from a directory using specified transformations and an embedding model. Ensure MILVUS_URI, embed_dim, and EMBED_MODEL are defined. ```python from llama_index.core import StorageContext, VectorStoreIndex from llama_index.vector_stores.milvus import MilvusVectorStore vector_store = MilvusVectorStore( uri=MILVUS_URI, dim=embed_dim, overwrite=True, ) index = VectorStoreIndex.from_documents( documents=dir_reader.load_data(show_progress=True), transformations=[node_parser], storage_context=StorageContext.from_defaults(vector_store=vector_store), embed_model=EMBED_MODEL, show_progress=True, ) ``` -------------------------------- ### Example Usage of is_divisible Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Demonstrates the usage of the is_divisible function with example inputs. ```python >>> is_divisible(6, 4) False >>> is_divisible(6, 3) True ``` -------------------------------- ### Create a dictionary with initial items Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Illustrates creating a dictionary with multiple key-value pairs defined at initialization. Note that the order of items is not guaranteed. ```python >>> eng2sp = {'one': 'uno', 'two': 'dos', 'three': 'tres'} >>> print eng2sp {'one': 'uno', 'three': 'tres', 'two': 'dos'} ``` -------------------------------- ### Initialize Milvus Client Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/rag_milvus.ipynb Instantiate a MilvusClient to connect to your Milvus instance. Use a local file path for Milvus Lite or a server URI for a deployed Milvus instance or Zilliz Cloud. ```python from pymilvus import MilvusClient milvus_client = MilvusClient(uri="./milvus_demo.db") collection_name = "my_rag_collection" ``` -------------------------------- ### RAG Setup with DoclingLoader Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/rag_langchain.ipynb Configures environment variables, loads .env file, and sets up parameters for a Retrieval Augmented Generation (RAG) pipeline using DoclingLoader. This includes defining file paths, embedding models, generation models, export type, query, prompt template, and Milvus connection details. ```python import os from pathlib import Path from tempfile import mkdtemp from dotenv import load_dotenv from langchain_core.prompts import PromptTemplate from langchain_docling.loader import ExportType def _get_env_from_colab_or_os(key): try: from google.colab import userdata try: return userdata.get(key) except userdata.SecretNotFoundError: pass except ImportError: pass return os.getenv(key) load_dotenv() # https://github.com/huggingface/transformers/issues/5486: os.environ["TOKENIZERS_PARALLELISM"] = "false" HF_TOKEN = _get_env_from_colab_or_os("HF_TOKEN") FILE_PATH = ["https://arxiv.org/pdf/2408.09869"] # Docling Technical Report EMBED_MODEL_ID = "sentence-transformers/all-MiniLM-L6-v2" GEN_MODEL_ID = "mistralai/Mixtral-8x7B-Instruct-v0.1" EXPORT_TYPE = ExportType.DOC_CHUNKS QUESTION = "Which are the main AI models in Docling?" PROMPT = PromptTemplate.from_template( "Context information is below.\n---------------------\n{context}\n---------------------\nGiven the context information and not prior knowledge, answer the query.\nQuery: {input}\nAnswer:\n", ) TOP_K = 3 MILVUS_URI = str(Path(mkdtemp()) / "docling.db") ``` -------------------------------- ### Install Required Packages Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Mainstream Framework Integration/TensorFlow/ReadMe.md Installs TensorFlow, NumPy, and Aspose.Cells for Python using pip. Python 3.10-3.12 is recommended. ```bash pip install tensorflow pip install numpy pip install aspose-cells-python ``` -------------------------------- ### Downloading Web Content with urllib Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md This example demonstrates how to use the urllib module to open a URL, read its content line by line, and strip leading/trailing whitespace from each line. ```python import urllib ``` ```python conn = urllib.urlopen('http://thinkpython.com/secret.html') for line in conn: print line.strip() ``` -------------------------------- ### Install ocrmac for macOS Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/installation/index.md Install the ocrmac package for using Apple's Vision framework as an OCR backend on macOS. ```bash pip install ocrmac ``` -------------------------------- ### Install Tesseract OCR on macOS Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/installation/index.md Install Tesseract OCR and set the TESSDATA_PREFIX environment variable on macOS using Homebrew. ```console brew install tesseract leptonica pkg-config TESSDATA_PREFIX=/opt/homebrew/share/tessdata/ echo "Set TESSDATA_PREFIX=${TESSDATA_PREFIX}" ``` -------------------------------- ### Serve MkDocs Documentation Locally Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/CONTRIBUTING.md Run the MkDocs development server to preview documentation changes locally. The server is typically available at http://localhost:8000. ```bash mkdocs serve ``` -------------------------------- ### Get Text from Entry Widget Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Retrieves the current text content from an Entry widget. This can be used to get user input. ```Python entry.get() ``` -------------------------------- ### Environment Setup and Configuration Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/rag_llamaindex.ipynb Sets up environment variables, filters warnings, and defines a helper function to retrieve environment variables from Google Colab or the operating system. Loads environment variables from a .env file. ```python import os from pathlib import Path from tempfile import mkdtemp from warnings import filterwarnings from dotenv import load_dotenv def _get_env_from_colab_or_os(key): try: from google.colab import userdata try: return userdata.get(key) except userdata.SecretNotFoundError: pass except ImportError: pass return os.getenv(key) load_dotenv() filterwarnings(action="ignore", category=UserWarning, module="pydantic") filterwarnings(action="ignore", category=FutureWarning, module="easyocr") ``` -------------------------------- ### Docling v2: Initialize DocumentConverter with Default Settings Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/v2.md Demonstrates the default initialization of DocumentConverter, which still works as in Docling v1. ```python ## Default initialization still works as before: # doc_converter = DocumentConverter() ``` -------------------------------- ### INI Entrypoint for Docling Plugin Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/concepts/plugins.md Configures a Docling plugin using a setup.cfg file. The 'docling' section lists the plugin name and its corresponding package module. ```ini [options.entry_points] docling = your_plugin_name = your_package.module ``` -------------------------------- ### Instantiate and Load Documents with DoclingLoader Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/visual_grounding.ipynb Initializes DoclingLoader with source file paths, the converter, export type, and a HybridChunker. It then loads the documents. ```python from langchain_docling import DoclingLoader from docling.chunking import HybridChunker loader = DoclingLoader( file_path=SOURCES, converter=converter, export_type=ExportType.DOC_CHUNKS, chunker=HybridChunker(tokenizer=EMBED_MODEL_ID), ) docs = loader.load() ``` -------------------------------- ### Empty String Slice Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Demonstrates that slicing with identical start and end indices, or with a start index greater than the end index, results in an empty string. ```Python >>> fruit = 'banana' >>> fruit[3:3] '' ``` -------------------------------- ### Import required classes Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/retrieval_qdrant.ipynb Import QdrantClient for vector database interaction, and HybridChunker, InputFormat, and DocumentConverter from the docling library for document processing. ```python from qdrant_client import QdrantClient from docling.chunking import HybridChunker from docling.datamodel.base_models import InputFormat from docling.document_converter import DocumentConverter ``` -------------------------------- ### Create and Query RAG Engine with Filters Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/backend_xml_rag.ipynb Instantiate a query engine with a language model, metadata filters, and a similarity top-k value. Then, execute a query and display the response within a formatted panel. ```python query_engine = index.as_query_engine(llm=GEN_MODEL, filter=filters, similarity_top_k=3) result = query_engine.query(query) console.print( Panel( result.response.strip(), title="Generated Content with RAG", border_style="bold green", ) ) ``` -------------------------------- ### Importing the string module Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Demonstrates how to import the string module to access predefined strings like punctuation. ```Python import string ``` -------------------------------- ### Python Infinite Recursion Example Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md A minimal example demonstrating infinite recursion, which occurs when a recursive function never reaches its base case. This typically results in a 'Maximum recursion depth exceeded' error. ```python def recurse(): recurse() ``` -------------------------------- ### Install Docling with NumPy for macOS x86_64 Compatibility Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/faq/index.md Ensures compatibility on macOS x86_64 by installing Docling with a NumPy version less than 2.0.0. This is necessary because older PyTorch versions required by Docling only work with NumPy 1.x. ```shell pip install docling "numpy<2.0.0" ``` -------------------------------- ### Create a Menubutton Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Initializes a Gui and creates a Menubutton with a default color. This sets up the basic structure for the menu. ```python g = Gui() g.la('Select a color:') colors = ['red', 'green', 'blue'] mb = g.mb(text=colors[0]) ``` -------------------------------- ### Python Interactive Mode Example Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Demonstrates using Python's interactive mode to execute simple expressions and see immediate results. The '>>>' prompt indicates the interpreter is ready for input. ```python >>> 1 + 1 2 ``` -------------------------------- ### Create a Button with a Callback Function Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md This example defines a function `make_label` and assigns it as the command for a button. When the button is pressed, the `make_label` function is executed, creating a new label in the GUI. ```Python def make_label(): g.la(text='Thank you.') button2 = g.bu(text='No, press me!', command=make_label) ``` -------------------------------- ### Get Current Working Directory Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Retrieves and prints the current working directory of the program. ```python >>> import os >>> cwd = os.getcwd() >>> print cwd /home/dinsdale ``` -------------------------------- ### Setting up Milvus Vector Store Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/visual_grounding.ipynb Initializes a Milvus vector store from documents using HuggingFace embeddings. Ensure the EMBED_MODEL_ID and necessary documents are available. The connection arguments and index parameters can be customized. ```python from langchain.vectorstores import Milvus from langchain_huggingface import HuggingFaceEmbeddings from pathlib import Path from tempfile import mkdtemp EMBED_MODEL_ID = "sentence-transformers/all-MiniLM-L6-v2" TOP_K = 3 embedding = HuggingFaceEmbeddings(model_name=EMBED_MODEL_ID) milvus_uri = str(Path(mkdtemp()) / "docling.db") # or set as needed vectorstore = Milvus.from_documents( documents=docs, embedding=embedding, collection_name="docling_demo", connection_args={"uri": milvus_uri}, index_params={"index_type": "FLAT"}, drop_old=True, ) ``` -------------------------------- ### Import TurtleWorld Module Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Imports all functions from the TurtleWorld module. This is used when Swampy is installed as a package. ```python from swampy.TurtleWorld import * ``` -------------------------------- ### Modulus Operator Example Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Demonstrates the use of the modulus operator (%) in Python to find the remainder of a division. ```Python >>> quotient = 7 / 3 >>> print quotient 2 >>> remainder = 7 % 3 >>> print remainder 1 So 7 divided by 3 is 2 with 1 left over. ``` -------------------------------- ### Create Excel File and Set Cell Style Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/README.md Shows how to create an Excel file and apply various styles to a cell, including font color, background, and borders. Requires 'aspose-cells-python' and 'aspose-pydrawing'. ```python import aspose.cells as ac import aspose.pydrawing as ad from aspose.cells import Workbook,FileFormatType #Create a new Workbook workbook = Workbook() worksheet=workbook.worksheets[0] #get cell style style=worksheet.cells.style #set font color style.font.color=ad.Color.green #set pattern style.pattern=ac.BackgroundType.GRAY12 #set Background style.background_color = ad.Color.red #set Border style.set_border(ac.BorderType.LEFT_BORDER,ac.CellBorderType.THIN,ad.Color.blue) style.set_border(ac.BorderType.RIGHT_BORDER,ac.CellBorderType.DOUBLE,ad.Color.gold) #set string value to cell 'A1' cells=worksheet.cells cell=cells.get("A1") cell.put_value("Text") #apply style to cell 'A1' cell.set_style(style) #save this workbook workbook.save("Style.xlsx") ``` -------------------------------- ### Python NameError Example Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Demonstrates a common runtime error (NameError) caused by a misspelled variable name. ```python principal = 327.68 interest = principle * rate ``` -------------------------------- ### Get Absolute Path Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Converts a relative path to an absolute path based on the current working directory. ```python >>> os.path.abspath('memo.txt') '/home/dinsdale/memo.txt' ``` -------------------------------- ### Increment Method Error Example Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Shows a TypeError that occurs when the increment method is called with an incorrect number of arguments. ```python >>> end = start.increment(1337, 460) TypeError: increment() takes exactly 2 arguments (3 given) ``` -------------------------------- ### Tuple comparison examples Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Shows how relational operators compare tuples element by element, stopping at the first difference. ```Python >>> (0, 1, 2) < (0, 3, 4) True >>> (0, 1, 2000000) < (0, 3, 4) True ``` -------------------------------- ### Create Excel File from Scratch Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/README.md Demonstrates how to create a new Excel workbook, add a value to a cell, and save the file. Requires the 'aspose-cells-python' package. ```python import aspose.cells from aspose.cells import License,Workbook,FileFormatType #Create a new Workbook workbook = Workbook() #Get the first worksheet worksheet=workbook.worksheets[0] #Get the "A1" cell cells=worksheet.cells cell=cells.get("A1") #Write "Hello World" to "A1" in the first sheet cell.put_value("Hello World!") #save this workbook to XLSX workbook.save("HelloWorld.xlsx") ``` -------------------------------- ### Configure Pipeline for SmolVLM Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/examples/pictures_description.ipynb Sets up pipeline options to enable picture description using the HuggingFaceTB/SmolVLM-256M-Instruct model. It configures the prompt, image scaling, and generation of picture images. ```python from docling.datamodel.pipeline_options import smolvlm_picture_description pipeline_options = PdfPipelineOptions() pipeline_options.do_picture_description = True pipeline_options.picture_description_options = ( smolvlm_picture_description # <-- the model choice ) pipeline_options.picture_description_options.prompt = ( "Describe the image in three sentences. Be consise and accurate." ) pipeline_options.images_scale = 2.0 pipeline_options.generate_picture_images = True converter = DocumentConverter( format_options={ InputFormat.PDF: PdfFormatOption( pipeline_options=pipeline_options, ) } ) doc = converter.convert(DOC_SOURCE).document ``` -------------------------------- ### Get the number of items in a dictionary Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Uses the len() function to determine the total number of key-value pairs in a dictionary. ```python >>> len(eng2sp) 3 ``` -------------------------------- ### Configure Other Vision Models Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/docling/docs/usage/enrichments.md Use PictureDescriptionVlmOptions to specify a Hugging Face Hub model for image descriptions. Ensure to add the correct repo_id and customize the prompt. ```python from docling.datamodel.pipeline_options import PictureDescriptionVlmOptions pipeline_options.picture_description_options = PictureDescriptionVlmOptions( repo_id="", # <-- add here the Hugging Face repo_id of your favorite VLM prompt="Describe the image in three sentences. Be consise and accurate.", ) ``` -------------------------------- ### Delete Text from Text Widget Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Removes a range of text from a Text widget, specified by start and end indices. ```Python text.delete(1.2, END) ``` -------------------------------- ### Instantiate and Use Time Object Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Demonstrates creating a Time object, setting its attributes, and calling the print_time function. ```python >>> start = Time() >>> start.hour = 9 >>> start.minute = 45 >>> start.second = 00 >>> print_time(start) 09:45:00 ``` -------------------------------- ### Import Lumpy for Class Diagrams Source: https://github.com/aspose-cells/aspose.cells-for-python-via-.net/blob/main/Plugin/marker/data/examples/markdown/thinkpython/thinkpython.md Imports the Lumpy class from the swampy.Lumpy library. This is the initial setup for generating diagrams. ```python from swampy.Lumpy import Lumpy ```