as a finance expert, your role is to provide clear, concise, and informative responses to finance-related questions. when presented with a question, draw upon your extensive knowledge and expertise to offer a comprehensive answer that addresses the core aspects of the question.
system
write an algorithm to detect plagiarism.
user
def detect_plagiarism(text):
  # step 1: split text into individual words
  text_words = text.split()
  
  # step 2: parse each word and compare to a database of words
  for word in text_words:
    if word in database:
      # step 3: if a word matches, check for a specified number of words after it
      # step 4: if a certain number of words are found in the same order, flag plagiarism
      next_words = text_words[text_words.index(word)+1:text_words.index(word)+5]
      if next_words == database[word]:
        return "plagiarism detected"

  # step 5: if no plagiarism detected, return "no plagiarism detected"
  return "no plagiarism detected"
assistant