{"id":32480270,"url":"https://github.com/boehm-e/google_nlp_to_spacy","last_synced_at":"2026-07-15T10:32:01.478Z","repository":{"id":129631267,"uuid":"161468728","full_name":"boehm-e/google_nlp_to_spacy","owner":"boehm-e","description":"A wrapper to make google cloud natural language API return elements structured like spacy","archived":false,"fork":false,"pushed_at":"2019-10-01T12:24:21.000Z","size":44,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T01:57:15.638Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boehm-e.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-12-12T10:04:00.000Z","updated_at":"2021-01-08T15:03:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"5e4c71a8-a0c3-4847-87fb-da12567fb504","html_url":"https://github.com/boehm-e/google_nlp_to_spacy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/boehm-e/google_nlp_to_spacy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boehm-e%2Fgoogle_nlp_to_spacy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boehm-e%2Fgoogle_nlp_to_spacy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boehm-e%2Fgoogle_nlp_to_spacy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boehm-e%2Fgoogle_nlp_to_spacy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boehm-e","download_url":"https://codeload.github.com/boehm-e/google_nlp_to_spacy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boehm-e%2Fgoogle_nlp_to_spacy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35501663,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-15T02:00:06.706Z","response_time":131,"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":[],"created_at":"2025-10-27T01:57:04.551Z","updated_at":"2026-07-15T10:32:01.472Z","avatar_url":"https://github.com/boehm-e.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GOOGLE NLP TO SPACY\n\nA wrapper to make google cloud natural language API return elements structured like spacy\n\n### Context\nI was working on a NLP project and began to create algorithmes with spacy classes.\nFor some reason (mostly scalability, and performances) I decided to switch to google cloud language, which achieve the current state of the art results on 11 NLP tasks ([google blog](https://ai.googleblog.com/2018/11/open-sourcing-bert-state-of-art-pre.html))\n\n### Goal\nThe goal of this project is to provide a simple transition from Spacy to Google Cloud NLP by providing wrappers to Google NLP that matches Spacy's documentation.\nSo (ideally) we only have to change a few line to our code and all is working.\n\n### Prerequisites\n\nIn order to run this, you will need the google cloud language package :\n```\npip install google-cloud-language\n```\n\nYou have to setup you google credentials:\n```\nGOOGLE_APPLICATION_CREDENTIALS=path/to/credentials.json\n```\n\n# Usage\n## To use this module do as follow :\n\n### clone the repository\n```\ngit clone git@github.com:boehm-e/google_nlp_to_spacy.git\ncd google_nlp_to_spacy\n```\n### try it\n```\npython3 example.py\n```\n\n### use in your project\n```python\n#setup\ngspacy = GoogleSpacy()\ngnlp = gspacy.load('fr')\n\ndoc = gnlp(\"Le lion marche dans la foret.\")\nfor token in doc:\n    print( token.text, token.lemma_, token.pos_, token.dep_ )\n\n  # | lion   | lion    | NOUN  | nsubj   |\n  # |--------|---------|-------|---------|\n  # | marche | marcher | VERB  | root    |\n  # |--------|---------|-------|---------|\n  # | dans   | dans    | ADP   | prep    |\n  # |--------|---------|-------|---------|\n  # | la     | le      | DET   | det     |\n  # |--------|---------|-------|---------|\n  # | foret  | foret   | NOUN  | pobj    |\n  # |--------|---------|-------|---------|\n  # | .      | .       | PUNCT | p       |\n\n\ndoc = gnlp(\"Le lion marche. Il est dans la foret.\")\nprint(doc.sents)\n# [Le lion marche., Il est dans la foret.]\n```\n\n### export and import\nyou can export and import document (for example, to store it in a database)\n\n#### export to json\n```python\n\n# export\ndoc = gnlp(\"Avec la mer du Nord pour dernier terrain vague\")\njsonDoc = doc.to_json()\n\n#\u003e{'text': 'Avec la mer du Nord pour dernier terrain vague',\n#  'sents': [{'start': 0, 'end': 40}],\n#  'tokens': [{'id': 0,\n#    'text': 'Avec',\n#    'lemma': 'Avec',\n#    'gender': 'GENDER_UNKNOWN',\n#    'person': 'PERSON_UNKNOWN',\n#    'number': 'NUMBER_UNKNOWN',\n#    'start': 0,\n#    'end': 4,\n#    'pos': 'ADP',\n#    'dep': 'root',\n#    'head': 0},\n#   ... ... ...\n#   {'id': 8,\n#    'text': 'vague',\n#    'lemma': 'vague',\n#    'gender': 'MASCULINE',\n#    'person': 'PERSON_UNKNOWN',\n#    'number': 'SINGULAR',\n#    'start': 41,\n#    'end': 46,\n#    'pos': 'NOUN',\n#    'dep': 'nn',\n#    'head': 7}]\n#   }\n```\n\n#### import from json\n\n```python\ndoc = gnlp(jsonDoc, from_json=True) # we take the json export from previous example\n\nprint(doc[2])\n#\u003e mer\n```\n\n### References\n\n- ### GSDoc\n\n| Name          | Type     | Description                                       |\n| ------------- | -------- | --------------------------------------------------|\n|  \\_\\_getitem\\_\\_ (position)          | GSToken   | The token at doc[i].                            |\n|  \\_\\_getitem\\_\\_ (range)          | GSSpan   | The span at doc[start:end].                            |\n|  to_json()          | json   | A json representation of the document who can be stored and used to construct the same Doc |\n\n- ## GSSpan\n\n| Name          | Type     | Description                                       |\n| ------------- | -------- | --------------------------------------------------|\n|  doc         | GSDoc   | The parent document.                            |\n|  start         | int   | The index of the first token of the span. |\n|  end         | int   |  The index of the first token after the span. |\n|  to_json()          | json   | A json representation of the document who can be stored and used to construct the same Doc |\n\n- ### GSToken\n\n| Name          | Type     | Description                                       |\n| ------------- | -------- | --------------------------------------------------|\n|  text         | String   | Verbatim text content.                            |\n|  pos_         | String   | Coarse-grained part-of-speech                     |\n|  dep_         | String   | Syntactic dependency relation                     |\n|  head         | *GSToken | The head index in the dependency tree             |\n|  lefts        | *GSToken | The leftward immediate children of the word, in the syntactic dependency parse. |\n|  rights         | *GSToken | The rightward immediate children of the word, in the syntactic dependency parse.|\n|  children         | *GSToken | A sequence of the token’s immediate syntactic children. |\n|  i            | Integer  | The index of the token within the parent document.|\n|  idx          | Integer  | The begin offset of the token within the document.|\n|  lemma_       | String   | Base form of the token                            |\n|  lower        | String   | Lowercase form of the token                       |\n|  shape        | String   | \"Hello World\" =\u003e \"Xxxxx Xxxxx\"                    |\n|  gender       | String   | GENDER_UNKNOWN \\| FEMININE \\| MASCULINE \\| NEUTER    |\n|  person       | String   | PERSON_UNKNOWN \\| FIRST \\| SECOND \\| THIRD \\| REFLEXIVE_PERSON |\n|  number       | String   | NUMBER_UNKNOWN \\| SINGULAR \\| PLURAL \\| DUAL  |\n|  is_lower     | Boolean  | Is the token in lowercase?                        |\n|  is_upper     | Boolean  | Is the token in uppercase?                        |\n|  is_title     | Boolean  | Is the token in titlecase?                        |\n|  is_space     | Boolean  | Does the token consist of whitespace characters?  |\n\n## Authors\n* **Erwan BOEHM** - [github](https://github.com/boehm-e/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboehm-e%2Fgoogle_nlp_to_spacy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboehm-e%2Fgoogle_nlp_to_spacy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboehm-e%2Fgoogle_nlp_to_spacy/lists"}