Cover Material, Copyright, and License
Preface
- How To Read This Book?
- Requests from the Author
- Why Use Common Lisp?
- Acknowledgments
- Setting Up Your Common Lisp Development System and Quicklisp
Introduction
- Why Did I Write this Book?
- Free Software Tools for Common Lisp Programming
- Making Book Examples Run Portably on Most Common Lisp Implementations
- How is Lisp Different from Languages like Java and C++?
- Advantages of Working in a Lisp Environment
Common Lisp Basics
- Getting Started with SBCL
- Making the repl Nicer using rlwrap
- The Basics of Lisp Programming
- Symbols
- Operations on Lists
- Using Arrays and Vectors
- Using Strings
- Using Hash Tables
- Using Eval to Evaluate Lisp Forms
- Using a Text Editor to Edit Lisp Source Files
- Recovering from Errors
- Garbage Collection
- Loading your Working Environment Quickly
- Functional Programming Concepts
Quicklisp
- Using Quicklisp to Find Packages
- Using Quicklisp to Configure Emacs and Slime
Defining Lisp Functions
- Using Lambda Forms
- Using Recursion
- Closures
- Using the Function eval
Defining Common Lisp Macros
- Example Macro
- Using the Splicing Operator
- Using macroexpand-1
Using Common Lisp Loop Macros
- dolist
- dotimes
- do
- Using the loop Special Form to Iterate Over Vectors or Arrays
Common Lisp Package System
Input and Output
- The Lisp read and read-line Functions
- Lisp Printing Functions
Plotting Data
- Implementing the Library
- Packaging as a Quicklisp Project
Common Lisp Object System - CLOS
- Example of Using a CLOS Class
- Implementation of the HTMLstream Class
- Using Defstruct or CLOS
Network Programming
- An introduction to Drakma
- An introduction to Hunchentoot
- Complete REST Client Server Example Using JSON for Data Serialization
- Network Programming Wrap Up
Using the Brave Search APIs
- Setting an Environment Variable for the Access Key for Brave Search APIs
- Example Search Script
Accessing Relational Databases
- Database Wrap Up
Using MongoDB, Solr NoSQL Data Stores
- MongoDB
- A Common Lisp Solr Client
- NoSQL Wrapup
Natural Language Processing
- Loading and Running the NLP Library
- Part of Speech Tagging
- Categorizing Text
- Detecting People’s Names and Place Names
- Summarizing Text
- Text Mining
Information Gathering
- DBPedia Lookup Service
- Web Spiders
- Using Apache Nutch
- Wrap Up
Using The CL Machine-Learning Library
- Using the CLML Data Loading and Access APIs
- K-Means Clustering of Cancer Data Set
- SVM Classification of Cancer Data Set
- CLML Wrap Up
Backpropagation Neural Networks
Hopfield Neural Networks
Using Python Deep Learning Models In Common Lisp With a Web Services Interface
- Setting up the Python Web Services Used in this Chapter
- Installing the spaCY NLP Services
- Installing the Coreference NLP Services
- Common Lisp Client for the spaCy NLP Web Services
- Common Lisp Client for the Coreference NLP Web Services
- Trouble Shooting Possible Problems - Skip if this Example Works on Your System
- Python Interop Wrap-up
Using the PY4CL Library to Embed Python in Common Lisp
- Project Structure, Building the Python Wrapper, and Running an Example
- Implementation of spacy-py4cl
- Trouble Shooting Possible Problems - Skip if this Example Works on Your System
- Wrap-up for Using Py4CL
Semantic Web and Linked Data
- Resource Description Framework (RDF) Data Model
- Extending RDF with RDF Schema
- The SPARQL Query Language
- Case Study: Using SPARQL to Find Information about Board of Directors Members of Corporations and Organizations
- Installing the Apache Jena Fuseki RDF Server
- Common Lisp Client Examples for the Apache Jena Fuseki RDF Server
Implementing a Simple RDF Datastore and Partial SPARQL Support in Common Lisp
- 1. RDF Triple Structure
- 2. RDF Datastore
- 3. Basic Datastore Operations
- 4. Query Support
- 5. SPARQL Query Structure
- 6. SPARQL Query Parsing
- 7. Query Execution
- 8. Result Projection
- 9. Main Query Execution
- Conclusion
Automatically Generating Data for Knowledge Graphs
- Implementation Notes
- Generating RDF Data
- Generating Data for the Neo4j Graph Database
- Implementing the Top Level Application APIs
- Implementing The Web Interface
- Creating a Standalone Application Using SBCL
- Augmenting RDF Triples in a Knowledge Graph Using DBPedia
- KGCreator Wrap Up
Knowledge Graph Sampler for Creating Small Custom Knowledge Graphs
Knowledge Graph Navigator Common Library Implementation
- Example Output
- Project Configuration and Running the Application
- Review of NLP Utilities Used in Application
- Developing Low-Level SPARQL Utilities
- Implementing the Caching Layer
- Utilities in the Main Library File kgn-common.lisp
- Wrap-up
Knowledge Graph Navigator Text-Based User Interface
- Example Output
- Text User Interface Implementation
- Wrap-up
Knowledge Graph Navigator User Interface Using LispWorks CAPI
- Project Configuration and Running the Application
- Utilities to Colorize SPARQL and Generated Output
- Main Implementation File kgn-capi-ui.lisp
- User Interface Utilites File user-interface.lisp
- User Interface CAPI Options Panes Definition File option-pane.lisp
- Using LispWorks CAPI UI Toolkit
- Wrap-up
Using the OpenAI and Mistral APIs
- History of OpenAI
- Common Lisp Library for Using OpenAI APIs
- History of Mistral AI
- Client Library for Mistral APIs
Using the Perplexity Sonar Web Search and LLM APIs
- Example Library Use
- Library Implementation
- Wrap Up for the Perplexity Sonar API
- Wrap Up Part 2: Perplexity Offers a Derivative DeepSeek R1 Model on its APIs
Using the Perplexity Sonar Web Search and LLM APIs
- Example Library Use
- Library Implementation
- Wrap Up for the Perplexity Sonar API
- Wrap Up Part 2: Perplexity Offers a Derivative DeepSeek R1 Model on its APIs
Moonshot’s Kimi K2 Model
- Simple Text Generation
- A More Complicated Example With Tool Use
- Moonshot AI’s Kimi K2 Model Wrap Up
Using the Hugging Face Deep Learning Natural Language Processing APIs
- History of Hugging Face and How They Differ from OpenAI and Anthropic
- Common Lisp Library for Hugging Face APIs
- Hugging Face APIs Wrapup
Using a Local Document Embeddings Vector Database With OpenAI GPT-5 APIs for Semantically Querying Your Own Data
- Overview of Local Embeddings Vector Database to Enhance the Use of GPT3 APIs With Local Documents
- Implementing a Local Vector Database for Document Embeddings
- Using Local Embeddings Vector Database With OpenAI GPT APIs
- Testing Local Embeddings Vector Database With OpenAI GPT APIs
- Adding Chat History
- Wrap Up for Using Local Embeddings Vector Database to Enhance the Use of GPT5 APIs With Local Documents
Prompt Engineering for Large Language Models
- Two Types of LLMS
- Prompt Examples
- Prompt Engineering Wrapup
Client Library for the Google Gemini LLM APIs
- Example Use
- Using Google’s “Grounding Search”
- Using Google’s “Grounding Search” With Citations
Client Library for the Tavily Web Search APIs
- Example Use
AutoContext: Prepare Effective Prompts with Context for LLM Queries
- Implementing the BM25 Algorithm
- Implementing Vectorization of Text and Semantic Similarity
- Implementation of Main Program
- Example Generated Prompt with Context
- Wrap Up For Generating Prompts with Contexts
Agents Orchestrating LLM Tool Use
- Example Multi Agent Implementation
- Code Discusion
- test.lisp
- Example Output
- Multi Agent Example Wrap Up
More Agents Using X’s Grok and Perplexity APIs
- Agent Using X’s Grok API
- Agent Using X’s Grok API and Perplexity’s Search API
