00001 """autogenerated by genpy from stanford_parser_msgs/Parse.msg. Do not edit."""
00002 import sys
00003 python3 = True if sys.hexversion > 0x03000000 else False
00004 import genpy
00005 import struct
00006
00007 import stanford_parser_msgs.msg
00008
00009 class Parse(genpy.Message):
00010 _md5sum = "094e3dbdff171c4bff80579d73b3ed1b"
00011 _type = "stanford_parser_msgs/Parse"
00012 _has_header = False
00013 _full_text = """SquashedParseTreeNode[] nodes
00014 Dependency[] dependencies
00015 string[] words
00016 string[] tags
00017
00018
00019 ================================================================================
00020 MSG: stanford_parser_msgs/SquashedParseTreeNode
00021 # tag is a part-of-speech tag from the list of constants below.
00022 int32 tag
00023 # parent_id is the location of the node pointing to this one in the tree, or -1 if root.
00024 int32 parent_id
00025 # score is a measure of confidence
00026 float64 score
00027 # word is the location of the word in the words array, or -1 if none.
00028 int32 word_index
00029
00030 # Constants below, using descriptions from http://bulba.sdsu.edu/jeanette/thesis/PennTags.html
00031 # To make code-safe, we use the following substitutions:
00032 # '-' -> '_'
00033 # '$' -> '_S'
00034 int32 ROOT=-100
00035 int32 ADJP=-101
00036 int32 _ADV=-102
00037 int32 ADVP=-103
00038 int32 _BNF=-104
00039 int32 CC=-105
00040 int32 CD=-106
00041 int32 _CLF=-107
00042 int32 _CLR=-108
00043 int32 CONJP=-109
00044 int32 _DIR=-110
00045 int32 DT=-111
00046 int32 _DTV=-112
00047 int32 EX=-113
00048 int32 _EXT=-114
00049 int32 FRAG=-115
00050 int32 FW=-116
00051 int32 _HLN=-117
00052 int32 IN=-118
00053 int32 INTJ=-119
00054 int32 JJ=-120
00055 int32 JJR=-121
00056 int32 JJS=-122
00057 int32 _LGS=-123
00058 int32 _LOC=-124
00059 int32 LS=-125
00060 int32 LST=-126
00061 int32 MD=-127
00062 int32 _MNR=-128
00063 int32 NAC=-129
00064 int32 NN=-130
00065 int32 NNS=-131
00066 int32 NNP=-132
00067 int32 NNPS=-133
00068 int32 _NOM=-134
00069 int32 NP=-135
00070 int32 NX=-136
00071 int32 PDT=-137
00072 int32 POS=-138
00073 int32 PP=-139
00074 int32 _PRD=-140
00075 int32 PRN=-141
00076 int32 PRP=-142
00077 int32 _PRP=-143
00078 int32 PRP_S=-144
00079 int32 PRT=-145
00080 int32 _PUT=-146
00081 int32 QP=-147
00082 int32 RB=-148
00083 int32 RBR=-149
00084 int32 RBS=-150
00085 int32 RP=-151
00086 int32 RRC=-152
00087 int32 S=-153
00088 int32 SBAR=-154
00089 int32 SBARQ=-155
00090 int32 _SBJ=-156
00091 int32 SINV=-157
00092 int32 SQ=-158
00093 int32 SYM=-159
00094 int32 _TMP=-160
00095 int32 TO=-161
00096 int32 _TPC=-162
00097 int32 _TTL=-163
00098 int32 UCP=-164
00099 int32 UH=-165
00100 int32 VB=-166
00101 int32 VBD=-167
00102 int32 VBG=-168
00103 int32 VBN=-169
00104 int32 VBP=-170
00105 int32 VBZ=-171
00106 int32 _VOC=-172
00107 int32 VP=-173
00108 int32 WDT=-174
00109 int32 WHADJP=-175
00110 int32 WHADVP=-176
00111 int32 WHNP=-177
00112 int32 WHPP=-178
00113 int32 WP=-179
00114 int32 WP_S=-180
00115 int32 WRB=-181
00116 int32 X=-182
00117 # These stay out for testing purposes. We want to make sure tags[] is working properly.
00118 # # int32 SENTENCE_CLOSER=183 # .;?
00119 # # int32 COMMA=184
00120 # # int32 COLON=185
00121 # # int32 LPAREN=186
00122 # # int32 RPAREN=187
00123
00124 # .
00125 # ,
00126 # :
00127 # (
00128 # )
00129
00130
00131 # # Pound sign
00132 # $ Dollar sign
00133 # . Sentence-final punctuation
00134 # , Comma
00135 # : Colon, semi-colon
00136 # ( Left bracket character
00137 # ) Right bracket character
00138 # " Straight double quote
00139 # ` Left open single quote
00140 # " Left open double quote
00141 # ' Right close single quote
00142 # " Right close double quote
00143 # ``
00144 # ''
00145
00146
00147 ================================================================================
00148 MSG: stanford_parser_msgs/Dependency
00149 string relation
00150 int32 governor_index
00151 int32 dependent_index
00152
00153 # TODO: put all the relations here
00154 """
00155 __slots__ = ['nodes','dependencies','words','tags']
00156 _slot_types = ['stanford_parser_msgs/SquashedParseTreeNode[]','stanford_parser_msgs/Dependency[]','string[]','string[]']
00157
00158 def __init__(self, *args, **kwds):
00159 """
00160 Constructor. Any message fields that are implicitly/explicitly
00161 set to None will be assigned a default value. The recommend
00162 use is keyword arguments as this is more robust to future message
00163 changes. You cannot mix in-order arguments and keyword arguments.
00164
00165 The available fields are:
00166 nodes,dependencies,words,tags
00167
00168 :param args: complete set of field values, in .msg order
00169 :param kwds: use keyword arguments corresponding to message field names
00170 to set specific fields.
00171 """
00172 if args or kwds:
00173 super(Parse, self).__init__(*args, **kwds)
00174
00175 if self.nodes is None:
00176 self.nodes = []
00177 if self.dependencies is None:
00178 self.dependencies = []
00179 if self.words is None:
00180 self.words = []
00181 if self.tags is None:
00182 self.tags = []
00183 else:
00184 self.nodes = []
00185 self.dependencies = []
00186 self.words = []
00187 self.tags = []
00188
00189 def _get_types(self):
00190 """
00191 internal API method
00192 """
00193 return self._slot_types
00194
00195 def serialize(self, buff):
00196 """
00197 serialize message into buffer
00198 :param buff: buffer, ``StringIO``
00199 """
00200 try:
00201 length = len(self.nodes)
00202 buff.write(_struct_I.pack(length))
00203 for val1 in self.nodes:
00204 _x = val1
00205 buff.write(_struct_2idi.pack(_x.tag, _x.parent_id, _x.score, _x.word_index))
00206 length = len(self.dependencies)
00207 buff.write(_struct_I.pack(length))
00208 for val1 in self.dependencies:
00209 _x = val1.relation
00210 length = len(_x)
00211 if python3 or type(_x) == unicode:
00212 _x = _x.encode('utf-8')
00213 length = len(_x)
00214 buff.write(struct.pack('<I%ss'%length, length, _x))
00215 _x = val1
00216 buff.write(_struct_2i.pack(_x.governor_index, _x.dependent_index))
00217 length = len(self.words)
00218 buff.write(_struct_I.pack(length))
00219 for val1 in self.words:
00220 length = len(val1)
00221 if python3 or type(val1) == unicode:
00222 val1 = val1.encode('utf-8')
00223 length = len(val1)
00224 buff.write(struct.pack('<I%ss'%length, length, val1))
00225 length = len(self.tags)
00226 buff.write(_struct_I.pack(length))
00227 for val1 in self.tags:
00228 length = len(val1)
00229 if python3 or type(val1) == unicode:
00230 val1 = val1.encode('utf-8')
00231 length = len(val1)
00232 buff.write(struct.pack('<I%ss'%length, length, val1))
00233 except struct.error as se: self._check_types(se)
00234 except TypeError as te: self._check_types(te)
00235
00236 def deserialize(self, str):
00237 """
00238 unpack serialized message in str into this message instance
00239 :param str: byte array of serialized message, ``str``
00240 """
00241 try:
00242 if self.nodes is None:
00243 self.nodes = None
00244 if self.dependencies is None:
00245 self.dependencies = None
00246 end = 0
00247 start = end
00248 end += 4
00249 (length,) = _struct_I.unpack(str[start:end])
00250 self.nodes = []
00251 for i in range(0, length):
00252 val1 = stanford_parser_msgs.msg.SquashedParseTreeNode()
00253 _x = val1
00254 start = end
00255 end += 20
00256 (_x.tag, _x.parent_id, _x.score, _x.word_index,) = _struct_2idi.unpack(str[start:end])
00257 self.nodes.append(val1)
00258 start = end
00259 end += 4
00260 (length,) = _struct_I.unpack(str[start:end])
00261 self.dependencies = []
00262 for i in range(0, length):
00263 val1 = stanford_parser_msgs.msg.Dependency()
00264 start = end
00265 end += 4
00266 (length,) = _struct_I.unpack(str[start:end])
00267 start = end
00268 end += length
00269 if python3:
00270 val1.relation = str[start:end].decode('utf-8')
00271 else:
00272 val1.relation = str[start:end]
00273 _x = val1
00274 start = end
00275 end += 8
00276 (_x.governor_index, _x.dependent_index,) = _struct_2i.unpack(str[start:end])
00277 self.dependencies.append(val1)
00278 start = end
00279 end += 4
00280 (length,) = _struct_I.unpack(str[start:end])
00281 self.words = []
00282 for i in range(0, length):
00283 start = end
00284 end += 4
00285 (length,) = _struct_I.unpack(str[start:end])
00286 start = end
00287 end += length
00288 if python3:
00289 val1 = str[start:end].decode('utf-8')
00290 else:
00291 val1 = str[start:end]
00292 self.words.append(val1)
00293 start = end
00294 end += 4
00295 (length,) = _struct_I.unpack(str[start:end])
00296 self.tags = []
00297 for i in range(0, length):
00298 start = end
00299 end += 4
00300 (length,) = _struct_I.unpack(str[start:end])
00301 start = end
00302 end += length
00303 if python3:
00304 val1 = str[start:end].decode('utf-8')
00305 else:
00306 val1 = str[start:end]
00307 self.tags.append(val1)
00308 return self
00309 except struct.error as e:
00310 raise genpy.DeserializationError(e)
00311
00312
00313 def serialize_numpy(self, buff, numpy):
00314 """
00315 serialize message with numpy array types into buffer
00316 :param buff: buffer, ``StringIO``
00317 :param numpy: numpy python module
00318 """
00319 try:
00320 length = len(self.nodes)
00321 buff.write(_struct_I.pack(length))
00322 for val1 in self.nodes:
00323 _x = val1
00324 buff.write(_struct_2idi.pack(_x.tag, _x.parent_id, _x.score, _x.word_index))
00325 length = len(self.dependencies)
00326 buff.write(_struct_I.pack(length))
00327 for val1 in self.dependencies:
00328 _x = val1.relation
00329 length = len(_x)
00330 if python3 or type(_x) == unicode:
00331 _x = _x.encode('utf-8')
00332 length = len(_x)
00333 buff.write(struct.pack('<I%ss'%length, length, _x))
00334 _x = val1
00335 buff.write(_struct_2i.pack(_x.governor_index, _x.dependent_index))
00336 length = len(self.words)
00337 buff.write(_struct_I.pack(length))
00338 for val1 in self.words:
00339 length = len(val1)
00340 if python3 or type(val1) == unicode:
00341 val1 = val1.encode('utf-8')
00342 length = len(val1)
00343 buff.write(struct.pack('<I%ss'%length, length, val1))
00344 length = len(self.tags)
00345 buff.write(_struct_I.pack(length))
00346 for val1 in self.tags:
00347 length = len(val1)
00348 if python3 or type(val1) == unicode:
00349 val1 = val1.encode('utf-8')
00350 length = len(val1)
00351 buff.write(struct.pack('<I%ss'%length, length, val1))
00352 except struct.error as se: self._check_types(se)
00353 except TypeError as te: self._check_types(te)
00354
00355 def deserialize_numpy(self, str, numpy):
00356 """
00357 unpack serialized message in str into this message instance using numpy for array types
00358 :param str: byte array of serialized message, ``str``
00359 :param numpy: numpy python module
00360 """
00361 try:
00362 if self.nodes is None:
00363 self.nodes = None
00364 if self.dependencies is None:
00365 self.dependencies = None
00366 end = 0
00367 start = end
00368 end += 4
00369 (length,) = _struct_I.unpack(str[start:end])
00370 self.nodes = []
00371 for i in range(0, length):
00372 val1 = stanford_parser_msgs.msg.SquashedParseTreeNode()
00373 _x = val1
00374 start = end
00375 end += 20
00376 (_x.tag, _x.parent_id, _x.score, _x.word_index,) = _struct_2idi.unpack(str[start:end])
00377 self.nodes.append(val1)
00378 start = end
00379 end += 4
00380 (length,) = _struct_I.unpack(str[start:end])
00381 self.dependencies = []
00382 for i in range(0, length):
00383 val1 = stanford_parser_msgs.msg.Dependency()
00384 start = end
00385 end += 4
00386 (length,) = _struct_I.unpack(str[start:end])
00387 start = end
00388 end += length
00389 if python3:
00390 val1.relation = str[start:end].decode('utf-8')
00391 else:
00392 val1.relation = str[start:end]
00393 _x = val1
00394 start = end
00395 end += 8
00396 (_x.governor_index, _x.dependent_index,) = _struct_2i.unpack(str[start:end])
00397 self.dependencies.append(val1)
00398 start = end
00399 end += 4
00400 (length,) = _struct_I.unpack(str[start:end])
00401 self.words = []
00402 for i in range(0, length):
00403 start = end
00404 end += 4
00405 (length,) = _struct_I.unpack(str[start:end])
00406 start = end
00407 end += length
00408 if python3:
00409 val1 = str[start:end].decode('utf-8')
00410 else:
00411 val1 = str[start:end]
00412 self.words.append(val1)
00413 start = end
00414 end += 4
00415 (length,) = _struct_I.unpack(str[start:end])
00416 self.tags = []
00417 for i in range(0, length):
00418 start = end
00419 end += 4
00420 (length,) = _struct_I.unpack(str[start:end])
00421 start = end
00422 end += length
00423 if python3:
00424 val1 = str[start:end].decode('utf-8')
00425 else:
00426 val1 = str[start:end]
00427 self.tags.append(val1)
00428 return self
00429 except struct.error as e:
00430 raise genpy.DeserializationError(e)
00431
00432 _struct_I = genpy.struct_I
00433 _struct_2i = struct.Struct("<2i")
00434 _struct_2idi = struct.Struct("<2idi")