<jupyter_start><jupyter_text>String Operations<jupyter_code>namelist = ["Ali","Joseph","Osman","Jonah"]
sentence ="Do not let your difficulties fill you with anxiety, after all it is only in the darkest nights that stars shine more brightly."
sentence<jupyter_output><empty_output><jupyter_text>Join and Split funtionalities<jupyter_code>names = " ".join(namelist)
print(type(names),":",names)
wordlist =sentence.split(" ")
print(type(wordlist),":",wordlist)
# Additional example 
# concatination and multiplication does not add any extra character
additionsample = "The best deed of a great man is "+"to forgive and forget."
multiplication = "To be or not to be."*2
print("Text Additions: ",additionsample)
print("Text Multiplication: ",multiplication)



str = "Istanbul Turkey"
print(str[1])
print(str[-3])<jupyter_output>s
k<jupyter_text>Gettting deeper with string operations  Substring<jupyter_code>str = "NLTK Dolly Python"
print("Substring ends at: ", str[:4])
print("Substring starts at: ", str[11:])
print("Substring :", str[5:10])
print("Substring fancy:", str[-12:-7])<jupyter_output>Substring fancy: Dolly<jupyter_text>In operator<jupyter_code># check left handside string whether it is in right handside or not
if "NLTK" in str:
    print("found NLTK!")<jupyter_output>found NLTK!<jupyter_text>Replace function<jupyter_code># return new string object. takes two argument 
replaced = str.replace("Dolly","Maya")
print("Replaced string: ",replaced)<jupyter_output>Replaced string:  NLTK Maya Python<jupyter_text>Access Each Charecter<jupyter_code>print("Accessing each character: ")
for s in replaced:
    print(s)<jupyter_output>Accessing each character: 
N
L
T
K
 
M
a
y
a
 
P
y
t
h
o
n<jupyter_text>02. Reading Files  02.01- Reading PDF<jupyter_code># install pypdf2 module with "pip install pypdf2" if you don"t have
# create file name called pdf.py
import pdf
import pdf

pdfFile = 'sample-one-line.pdf'
pdfFileEncrypted = 'sample-one-line.protected.pdf'

print('PDF 1: \n',pdf.getTextPDF(pdfFile))
print('PDF 2: \n',pdf.getTextPDF(pdfFileEncrypted,"tuffy"))<jupyter_output>PDF 1: 
 This is a sample PDF document I am using to demonstrate in the tutorial.
 

PDF 2: 
 This is a sample PDF document
 
password protected.<jupyter_text>02.02- Reading Word Document<jupyter_code># install python-docx module with "pip install python-docx" if you don"t have
import docx
import word

docName ="sample-one-line.docx"
print("Document in full: \n", word.getTextWord(docName))
doc = docx.Document(docName)
print('Number of paragraphs :',len(doc.paragraphs))
print('Paragraph 2:',doc.paragraphs[1].text)
print('Paragraph 2 style:',doc.paragraphs[1].style)



print('Paragraph 1:',doc.paragraphs[0].text)
print('Number of runs in paragraph 1:',len(doc.paragraphs[0].runs))
for idx, run in enumerate(doc.paragraphs[0].runs):
    print('Run %s : %s' %(idx,run.text))

print('is Run 0 underlined:',doc.paragraphs[0].runs[5].underline)
print('is Run 2 bold:',doc.paragraphs[0].runs[1].bold)
print('is Run 7 italic:',doc.paragraphs[0].runs[3].italic)<jupyter_output>is Run 0 underlined: True
is Run 2 bold: True
is Run 7 italic: True
{'fraction_non_alphanumeric': 0.13022661985317588, 'fraction_numerical': 0.015639961698052984, 'mean_word_length': 6.42654028436019, 'pattern_counts': {'":': 2, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '157236', 'license': 'MIT', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1079, 'n_words': 303, 'path': '01.String_Operations.ipynb', 'repo_name': 'Savas21/TextProcessing', 'size': '3133'}