क्लासेस का उपयोग

Python में Software Engineering Principles

Adam Spannbauer

Machine Learning Engineer at Eastman

Document क्लास को बढ़ाना

class Document:
    def __init__(self, text):
        self.text = text

डॉक्यूमेंट को टोकनाइज़ करें

Python में Software Engineering Principles

मौजूदा Document क्लास

class Document:
    def __init__(self, text):
        self.text = text

Tokenize Document init

Python में Software Engineering Principles

__init__ को संशोधित करना

class Document:
    def __init__(self, text):
        self.text = text
        self.tokens = self._tokenize()

doc = Document('test doc') print(doc.tokens)
['test', 'doc']
Python में Software Engineering Principles

_tokenize() मेथड जोड़ना

# Import function to perform tokenization
from .token_utils import tokenize

class Document: def __init__(self, text, token_regex=r'[a-zA-Z]+'): self.text = text self.tokens = self._tokenize()
def _tokenize(self): return tokenize(self.text)
Python में Software Engineering Principles

नॉन-पब्लिक मेथड्स

Tokenize Document init

Private Property Sign

Python में Software Engineering Principles

नॉन-पब्लिक मेथड्स के जोखिम

  • डाक्यूमेंटेशन की कमी

  • अनिश्चितता

Private Property Sign

Python में Software Engineering Principles

अभ्यास करते हैं

Python में Software Engineering Principles

Preparing Video For Download...