Created
November 15, 2014 10:38
-
-
Save simkimsia/9ace6002cc758d5a303a to your computer and use it in GitHub Desktop.
sent_detect function using Maxent_Sent_Token_Annotator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sent_detect <- function(text, language) { | |
# Function to compute sentence annotations using the Apache OpenNLP Maxent sentence detector employing the default model for language 'en'. | |
sentence_token_annotator <- Maxent_Sent_Token_Annotator(language) | |
# Convert text to class String from package NLP | |
text <- as.String(text) | |
# Sentence boundaries in text | |
sentence.boundaries <- annotate(text, sentence_token_annotator) | |
# Extract sentences | |
sentences <- text[sentence.boundaries] | |
# return sentences | |
return(sentences) | |
} | |
tiny <- sent_detect("hi i am Apple", language = "en") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment