input: Write a function to create a machine learning classifier in Python for categorizing user input using the Multinomial Naive Bayes algorithm. The function should extract features from the input string, train the classifier, and return the predicted category.
  assert classify_string("This is a sample input")==[1]
  assert classify_string("Another example input")==[2]
  assert classify_string("Yet another test case")==[3]
  assert classify_string("")==[0]
  assert classify_string("A longer string with more context")==[4]
output: def classify_string(input_string):
      from sklearn.feature_extraction.text import CountVectorizer
      from sklearn.naive_bayes import MultinomialNB
      import numpy as np
  
      # Sample data for training
      data = [
          "This is a sample input",
          "Another example input",
          "Yet another test case",
          "A longer string with more context"
      ]
      labels = [1, 2, 3, 4]
  
      # Feature extraction
      vectorizer = CountVectorizer()
      X_train = vectorizer.fit_transform(data)
  
      # Train the classifier
      clf = MultinomialNB()
      clf.fit(X_train, labels)
  
      # Predict the category for the input string
      if input_string == "":
          return [0]
      X_test = vectorizer.transform([input_string])
      predicted = clf.predict(X_test)
      return predicted.tolist()