class_docstr: This class implements the actual language identifier.
class_docstr_tok: ["This","class","implements","the","actual","language","identifier","."]
docstr: Map an instance into the feature space of the trained model.
docstr_tok: ["Map","an","instance","into","the","feature","space","of","the","trained","model","."]
code: def instance2fv(self, text):
      """
      Map an instance into the feature space of the trained model.
      """
      if sys.version_info > (3, 0):
          # Python3
          if isinstance(text, str):
              text = text.encode("utf8")
      else:
          # Python2
          if isinstance(text, unicode):
              text = text.encode("utf8")
          # Convert the text to a sequence of ascii values
          text = map(ord, text)
  
      arr = np.zeros((self.nb_numfeats,), dtype="uint32")
  
      # Count the number of times we enter each state
      state = 0
      statecount = defaultdict(int)
      for letter in text:
          state = self.tk_nextmove[(state << 8) + letter]
          statecount[state] += 1
  
      # Update all the productions corresponding to the state
      for state in statecount:
          for index in self.tk_output.get(state, []):
              arr[index] += statecount[state]
  
      return arr
  
imports: from __future__ import print_function
  import base64
  import bz2
  import json
  import optparse
  import sys
  import logging
  import numpy
  from wsgiref.simple_server import make_server
  from wsgiref.util import shift_path_info
  from collections import defaultdict
label_desc: Use image node_id 5 for calling the LanguageIdentifier obj's underlying member method code with example usage: obj.instance2fv(text) and returns: arr