{"id":15014164,"url":"https://github.com/d99kris/spacy-cpp","last_synced_at":"2025-10-13T00:42:38.520Z","repository":{"id":27872494,"uuid":"115424740","full_name":"d99kris/spacy-cpp","owner":"d99kris","description":"C++ wrapper library for the NLP library spaCy","archived":false,"fork":false,"pushed_at":"2023-03-25T02:08:53.000Z","size":86,"stargazers_count":102,"open_issues_count":0,"forks_count":16,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-19T12:42:33.156Z","etag":null,"topics":["c-plus-plus","linux","nlp","nlp-libraries","spacy"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/d99kris.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-26T13:30:23.000Z","updated_at":"2025-03-27T20:24:50.000Z","dependencies_parsed_at":"2024-09-24T20:05:55.540Z","dependency_job_id":null,"html_url":"https://github.com/d99kris/spacy-cpp","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/d99kris/spacy-cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d99kris%2Fspacy-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d99kris%2Fspacy-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d99kris%2Fspacy-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d99kris%2Fspacy-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d99kris","download_url":"https://codeload.github.com/d99kris/spacy-cpp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d99kris%2Fspacy-cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279013634,"owners_count":26085298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-plus-plus","linux","nlp","nlp-libraries","spacy"],"created_at":"2024-09-24T19:45:16.759Z","updated_at":"2025-10-13T00:42:38.505Z","avatar_url":"https://github.com/d99kris.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"Spacy-cpp\n=========\n\n| **Linux** | **Mac** |\n|-----------|---------|\n| [![Linux](https://github.com/d99kris/spacy-cpp/workflows/Linux/badge.svg?branch=master)](https://github.com/d99kris/spacy-cpp/actions?query=workflow%3ALinux) | [![macOS](https://github.com/d99kris/spacy-cpp/workflows/macOS/badge.svg?branch=master)](https://github.com/d99kris/spacy-cpp/actions?query=workflow%3AmacOS) |\n\nSpacy-cpp is a C++ wrapper library for the NLP library\n[spaCy](https://spacy.io/). This project is not affiliated with spaCy, it is\nhowever distributed under the same type of license (MIT).\n\nThe goal of spacy-cpp is to expose the functionality of spaCy to C++\napplications, and to provide an API that is similar to that of spaCy,\nenabling rapid development in Python and simple porting to C++.\n\nSpacy-cpp is under development and does not yet support all API's of spaCy,\nrefer to the API Documentation section below.\n\n\nExample Usage\n=============\nSimple POS tagging example using spacy-cpp:\n```cpp\nSpacy::Spacy spacy;\nauto nlp = spacy.load(\"en_core_web_sm\");\nauto doc = nlp.parse(\"This is a sentence.\");\nfor (auto\u0026 token : doc.tokens())\n    std::cout \u003c\u003c token.text() \u003c\u003c \" [\" \u003c\u003c token.pos_() \u003c\u003c \"]\\n\";\n```\n\nFor reference - doing the same using the spaCy API in Python:\n```python\nimport spacy\nnlp = spacy.load(\"en_core_web_sm\")\ndoc = nlp(u\"This is a sentence.\")\nfor token in doc:\n    print(token.text + \" [\" + token.pos_ + \"]\")\n```\n\n\nSupported Platforms\n===================\nSpacy-cpp is implemented using C++11 with the intention of being portable.\nCurrent version has been tested on:\n- macOS Ventura 13.1\n- Ubuntu 22.04 LTS\n\n\nPre-requisites\n==============\nSpacy-cpp requires python development library, pip, spaCy and typically a\nspaCy model.\n\nmacOS\n-----\nInstall build dependencies:\n\n    brew install cmake python\n\nInstall spaCy and an English model:\n\n    pip3 install -U spacy\n    python3 -m spacy download en_core_web_sm\n\nUbuntu\n------\nInstall build dependencies:\n\n    sudo apt install cmake python3-pip libpython3-dev\n\nInstall spaCy and an English model:\n\n    pip3 install -U spacy\n    python3 -m spacy download en_core_web_sm\n\n\nInstallation\n============\nSpacy-cpp can be used either as a shared library or as a header-only library.\n\nShared Library\n--------------\nBuild and install spacy-cpp:\n\n    mkdir -p build \u0026\u0026 cd build \u0026\u0026 cmake .. \u0026\u0026 make \u0026\u0026 sudo make install\n\nLink library:\n\n    -lspacy\n\nInclude header (convenience header including all modules):\n\n    #include \u003cspacy/spacy\u003e\n\nHeader-only Library\n-------------------\nCopy the src/spacy directory to the source directory of your project. Then\ndefine SPACY_HEADER_ONLY and include headers needed (spacy/spacy includes\nall headers):\n\n    #define SPACY_HEADER_ONLY\n    #include \u003cspacy/spacy\u003e\n\nCMake Usage\n-----------\nThe source tree includes two CMake project examples:\n\n- [Using spacy-cpp as header-only library](examples/cmake-add-subdirectory-hdr)\n- [Using spacy-cpp as shared library](examples/cmake-add-subdirectory-lib)\n\n\nFAQ\n===\n\n### No module named spacy. Why does spacy-cpp not find spacy?\nIf a system has more than one Python installation, each of the installations\nwill have its own set of pip-installed Python packages. One must ensure that\nspacy is installed for the Python version used by spacy-cpp (alternatively\npoint spacy-cpp to the desired Python installation). When building spacy-cpp\nusing CMake (example: `./make.sh tests`) the Python version used will be\noutput, for example `PYTHON_EXECUTABLE=\"/usr/local/bin/python3.11\"`. Use this\ninterpreter to ensure spacy works correctly in Python, example:\n`/usr/local/bin/python3.11 ./examples/python-spacy-usage.py`. If not working,\nuse this Python version to install spacy and a language model:\n\n    /usr/local/bin/python3.11 -m pip install -U spacy\n    /usr/local/bin/python3.11 -m spacy download en_core_web_sm\n\n\nAPI Documentation\n=================\nSpacy-cpp is under development and does not support the complete spaCy API yet.\n\nSupported Classes\n-----------------\n- [Attrs](https://github.com/d99kris/spacy-cpp/blob/master/src/spacy/attrs.h)\n- [Doc](https://github.com/d99kris/spacy-cpp/blob/master/src/spacy/doc.h)\n- [MorphAnalysis](https://github.com/d99kris/spacy-cpp/blob/master/src/spacy/morphanalysis.h)\n- [Nlp](https://github.com/d99kris/spacy-cpp/blob/master/src/spacy/nlp.h)\n- [Spacy](https://github.com/d99kris/spacy-cpp/blob/master/src/spacy/spacy.h)\n- [Span](https://github.com/d99kris/spacy-cpp/blob/master/src/spacy/span.h)\n- [StringStore](https://github.com/d99kris/spacy-cpp/blob/master/src/spacy/stringstore.h)\n- [Token](https://github.com/d99kris/spacy-cpp/blob/master/src/spacy/token.h)\n- [Vocab](https://github.com/d99kris/spacy-cpp/blob/master/src/spacy/vocab.h)\n\nSupported Methods / Attributes\n------------------------------\n**Attrs** supports all attribute constants.\n\n**Doc** supports the following methods / attributes:\n- count_by()\n- ents()\n- has_vector()\n- is_parsed()\n- is_tagged()\n- noun_chunks()\n- sentiment()\n- sents()\n- similarity()\n- text()\n- text_with_ws()\n- tokens()\n- vector_norm()\n\n**MorphAnalysis** supports the following methods / attributes:\n- get()\n- str()\n- to_dict()\n\n**Nlp** supports the following methods / attributes:\n- parse()\n- vocab()\n\n**Spacy** supports the following methods / attributes:\n- load()\n- attrs()\n\n**Span** supports the following methods / attributes:\n- doc()\n- label()\n- label_()\n- lemma_()\n- orth_()\n- root()\n- sentiment()\n- text()\n- text_with_ws()\n- tokens()\n- vector_norm()\n\n**StringStore** supports the following methods / attributes:\n- add()\n\n**Token** supports the following methods / attributes:\n- check_flag()\n- children()\n- cluster()\n- dep()\n- dep_()\n- ent_iob_()\n- has_vector()\n- head()\n- i()\n- idx()\n- is_alpha()\n- is_ascii()\n- is_bracket()\n- is_digit()\n- is_left_punct()\n- is_lower()\n- is_oov()\n- is_punct()\n- is_quote()\n- is_right_punct()\n- is_space()\n- is_stop()\n- is_title()\n- is_upper()\n- lang()\n- lang_()\n- lemma()\n- lemma_()\n- like_email()\n- like_num()\n- like_url()\n- lower()\n- lower_()\n- morph()\n- nbor()\n- norm()\n- norm_()\n- orth()\n- orth_()\n- pos()\n- pos_()\n- prob()\n- rank()\n- sentiment()\n- shape()\n- shape_()\n- tag()\n- tag_()\n- text()\n- text_with_ws()\n- whitespace_()\n\n**Vocab** supports the following methods / attributes:\n- strings()\n\nKey Differences with spaCy\n--------------------------\n1. In spacy-cpp Nlp cannot be called as a method in order to perform parsing.\n   Instead one need to use Nlp::parse().\n2. In spacy-cpp Doc is not an iterable, instead one need to use Doc::token()\n   to get a std::vector of the tokens in the Doc. Likewise for Span.\n3. In spacy-cpp non-ASCII strings must be UTF-8 encoded in order to be\n   correctly processed.\n\n\nTechnical Details\n=================\nSpacy-cpp uses cmake for its tests. Commands to build and execute the test\nsuite:\n\n    mkdir -p build \u0026\u0026 cd build \u0026\u0026 cmake -DSPACYCPP_BUILD_TESTS=ON .. \u0026\u0026 make \u0026\u0026 ctest --output-on-failure ; cd -\n\n\nLicense\n=======\nSpacy-cpp is distributed under the MIT license.\nSee [LICENSE](https://github.com/d99kris/spacy-cpp/blob/master/LICENSE) file.\n\n\nContributions\n=============\nBugs, PRs, etc are welcome on the GitHub project page\nhttps://github.com/d99kris/spacy-cpp\n\n\nKeywords\n========\nc++, c++11, natural language processing, nlp, spacy.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd99kris%2Fspacy-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd99kris%2Fspacy-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd99kris%2Fspacy-cpp/lists"}