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 a pseudo-code that can detect whether a given sentence is positive or negative.
user
func sentimentanalysis(sentence):
  // initialize the sentiment score
  sentimentscore = 0

  // split the sentence into words
  words = sentence.split(' ')

  // loop through each word
  for word in words
    // check if word is in sentiment dictionary
    sentimentvalue = checksentimentdictionary(word)

    // calculate sentiment score
    sentimentscore = sentimentscore + sentimentvalue

  // return the sentiment score
  return sentimentscore
assistant