Created
November 24, 2016 06:34
-
-
Save chetkhatri/0bb67596bbb2e9b446e944908b3325c6 to your computer and use it in GitHub Desktop.
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 nltk | |
import re | |
with open('/home/chetan/Documents/sample-certificate.txt','r') as file: | |
text = file.read() | |
# print(text) | |
sentences = nltk.sent_tokenize(text) | |
tokenized_sentences = [nltk.word_tokenize(sentence) for sentence in sentences] | |
# print(tokenized_sentences) | |
sign_date = {} | |
for indecies, elements in enumerate(tokenized_sentences): | |
for index, element in enumerate(elements): | |
elements.append(element) | |
if(element == "dated"): | |
sign_date[indecies] = index | |
print(index) | |
elif(element == ','): | |
sign_date.append(index) | |
sign_date[indecies] = index | |
print(elements) | |
regex = re.compile(r"BP(\d{8})") | |
result = regex.search(text) | |
print('Agreement Number: '+result.group()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tokenized_sentences has that list i sent you earlier.