def decodeInventoryEntry_level2(document):
 count = Inventory(str(document))
 for token in document:
  if ((token.dep_ == (u'pobj' or u'meta')) and (token.pos_ == (u'NOUN' or u'NNS' or u'NN'))):
   item = ''
   for i in token.children:
    item += (' ' + str(i))
   item += (' ' + str(token))
   count.item = item
   if (token.head.dep_ != u'prep'):
    break
   else:
    amountUnit = token.head.head
    count.unit = str(amountUnit)
    for inner in amountUnit.children:
     if (inner.pos_ == u'NUM'):
      count.amount += str(inner)
 return count

def decodeInventoryEntry_level2 ( document ) : count = Inventory ( str ( document ) ) for token in document : if ( ( token . dep_ == ( u'pobj' or u'meta' ) ) and ( token . pos_ == ( u'NOUN' or u'NNS' or u'NN' ) ) ) : item = '' for i in token . children : item += ( ' ' + str ( i ) ) item += ( ' ' + str ( token ) ) count . item = item if ( token . head . dep_ != u'prep' ) : break else : amountUnit = token . head . head count . unit = str ( amountUnit ) for inner in amountUnit . children : if ( inner . pos_ == u'NUM' ) : count . amount += str ( inner ) return count
entry level 2 .