code: def test_build(self):
      data = Reader().read(
          "./tests/sentiment_data.txt",
          fmt="UITup",
          sep=",",
          tup_sep=":",
      )
      md = SentimentModality(data=data)
  
      uid_map = OrderedDict()
      iid_map = OrderedDict()
      for raw_uid, raw_iid, _ in data:
          uid_map.setdefault(raw_uid, len(uid_map))
          iid_map.setdefault(raw_iid, len(iid_map))
  
      matrix = dok_matrix(
          (len(uid_map), len(iid_map)), dtype=np.float32
      )
  
      for raw_uid, raw_iid, _ in data:
          user_idx = uid_map.get(raw_uid)
          item_idx = iid_map.get(raw_iid)
          matrix[user_idx, item_idx] = 1
  
      md.build(uid_map=uid_map, iid_map=iid_map, dok_matrix=matrix)
  
      self.assertEqual(md.num_aspects, 3)
      self.assertEqual(md.num_opinions, 2)
      self.assertEqual(len(md.sentiment), 4)
      self.assertEqual(len(md.user_sentiment), 3)
      self.assertEqual(len(md.item_sentiment), 3)
      self.assertEqual(len(md.aspect_id_map), 3)
      self.assertEqual(len(md.opinion_id_map), 2)
  
      try:
          SentimentModality().build()
      except ValueError:
          assert True
  
file_path: cornac/tests/cornac/data/test_sentiment.py
imports: import unittest
  import numpy
  from cornac.data import SentimentModality
  from cornac.data import Reader
  from collections import OrderedDict
  from scipy.sparse import dok_matrix
label_desc: Use image node_id 2 for calling the TestSentimentModality obj's underlying member method code with example usage: obj.test_build() without return types