Giter VIP home page Giter VIP logo

books's Introduction

Books with Detailed Explanations

  1. Mastering spaCy
  • Covered everything in the book based on chapter wise, you can get all the notes.

Preview

books's People

Contributors

raravindds avatar

Stargazers

 avatar

Watchers

 avatar

books's Issues

Chapter 4 Combining linguistic features and named entities

Hi, please let me congratulate for the job I have done with the Mastering Spacy book, I just wonder if you managed to run the example that is under "Combining linguistic features and named entities" section:

Here is the code, but I get an error.

import spacy
nlp = spacy.load("en_core_web_md")#we created a Language object, nlp
doc = nlp("Einstein lived in Zurich.")
person_ents = [ent for ent in doc.ents if ent.label_ == "PERSON"]
for person_ent in person_entities:
#We use head of the entity's last token
    head = person_ent[-1].head if head.lemma_ == "live":
#Check if the children of live contains prepositionalattachment 
    preps = [token for token in head.children if token.dep_ == "prep"]
    for prep in preps:         
        places = [token for token in prep.children if token.ent_type_ == "GPE"]   
# Verb is in past or present tense
        print({'person': person_ent, 'city': places, 'past': head.tag_ == "VBD"})

Any help will be appreciated

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.