Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sentence segmentation error #592

Closed
jmugan opened this issue Oct 29, 2016 · 3 comments
Closed

sentence segmentation error #592

jmugan opened this issue Oct 29, 2016 · 3 comments

Comments

@jmugan
Copy link

jmugan commented Oct 29, 2016

I know that sentence segmentation is more difficult than it appears, but this looks like an error that spaCy might want to know about. Or if there is something I am doing wrong, it would be good for me to know :)

text = "He has a Ph.D. in tacology."
tokens = parser(text)
for sent in tokens.sents:
    print("Sentence:")
    print(sent)
    print()

results in

Sentence:
He has a Ph.

Sentence:
D. in tacology.

In Python 3.5, spaCy version 1.1.2.

@honnibal
Copy link
Member

Thanks!

One of the features of 1.0 I haven't documented yet is that it's now easy to fix this sort of thing at run-time, without messing with data files.

You should be able to do:

import spacy.en

spacy.en.English.Defaults.tokenizer_exceptions["Ph.D."] = [{"F": "Ph.D."}]

What you're doing here is telling the tokenizer, "when you see this chunk, 'Ph.D.', process it into these tokens". The list you're giving it here has just one token, and you've specified its form (with the F key). You can also specify its POS and lemma (with P and L). This is a little dinky --- it should support full token attributes.

@jmugan
Copy link
Author

jmugan commented Oct 29, 2016

Cool! That works!

@honnibal honnibal closed this as completed Nov 2, 2016
@lock
Copy link

lock bot commented May 9, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants