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
from nltk.tokenize import word_tokenize | |
from nltk.tokenize import wordpunct_tokenize | |
test_sentence = "Hi Mr. Sam, today's a good day to learn NLP. It's a well-known field of study." | |
#Method 1 - Without using the NLTK - Splitting at white spaces | |
words = test_sentence.split() | |
print words | |
#Method 2 - Using word_tokenize of NLTK |
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
from nltk import sent_tokenize | |
test_sentence = "Hi Mr. Sam, today's a good day to learn NLP. It's a well-known field of study." | |
sentences = sent_tokenize(test_sentence) | |
print sentences |
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
from nltk.stem import PorterStemmer | |
from nltk.tokenize import word_tokenize | |
ps = PorterStemmer(); | |
test_sentence = " learn learned learning learns" | |
tokenized_words = word_tokenize(test_sentence) | |
stemmed_words = [] | |
for i in tokenized_words: |
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
import ballerina.net.http; | |
@http:configuration {basePath:"/githubWebhook"} | |
service<http> githubWebhook { | |
@http:resourceConfig { | |
methods:["POST"], | |
path:"/listener" | |
} | |
resource webhookListener (http:Connection connection, http:InRequest request) { |
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
import ballerina/log; | |
import ballerina/mime; | |
import ballerina/net.http; | |
import ballerina/net.websub; | |
endpoint websub:SubscriberServiceEndpoint websubEP { | |
host:"localhost", | |
port:8181 | |
}; |
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
import ballerina/log; | |
import ballerina/mime; | |
import ballerina/net.http; | |
import ballerina/net.websub; | |
endpoint websub:SubscriberServiceEndpoint websubEP { | |
host:"localhost", | |
port:8181 | |
}; |
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
import ballerina/io; | |
import ballerina/net.http; | |
import ballerina/net.websub; | |
endpoint websub:HubClientEndpoint websubHubClientEP { | |
uri: "http://localhost:9999/websub/hub" | |
}; | |
function main (string [] args) { | |
websub:SubscriptionChangeRequest subscriptionChangeRequest = {topic:"http://www.websubpubtopic.com", callback:"http://localhost:8181/websub"}; |
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
import ballerina/io; | |
import ballerina/net.websub; | |
import ballerina/runtime; | |
endpoint websub:HubClientEndpoint websubHubClientEP { | |
uri: "http://localhost:9999/websub/hub" | |
}; | |
function main (string [] args) { | |
io:println("Starting up the Ballerina Hub Service"); |
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
import ballerina/io; | |
import ballerina/http; | |
import ballerina/webhook; | |
import ballerina/websub; | |
endpoint webhook:GitHubListener githubListenerEP { | |
host:"localhost", | |
port:8181 | |
}; |
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
//Method that accepts intent verification requests | |
onVerifyIntent (endpoint client, http:Request request) { | |
//Build the response for the subscription intent verification request that was received | |
var subscriptionVerificationResponse = websub:buildSubscriptionVerificationResponse(request); | |
http:Response response = {}; | |
match (subscriptionVerificationResponse) { | |
//Intent verification request was responded to successfully | |
http:Response httpResponse => { | |
log:printInfo("Intent verified for subscription request"); | |
response = httpResponse; |
OlderNewer