@@ -113,29 +113,29 @@ def antonym(term, formatted=False):
113113 @staticmethod
114114 def meaning (term , disable_errors = False ):
115115 if len (term .split ()) > 1 :
116- print ( "Error: A Term must be only a single word" )
117- else :
118- try :
119- html = _get_soup_object ("http://wordnetweb.princeton.edu/perl/webwn?s={0}" .format (
120- term ))
121- types = html .findAll ("h3" )
122- length = len (types )
123- lists = html .findAll ("ul" )
124- out = {}
125- for a in types :
126- reg = str (lists [types .index (a )])
127- meanings = []
128- for x in re .findall (r'\((.*?)\)' , reg ):
129- if 'often followed by' in x :
130- pass
131- elif len (x ) > 5 or ' ' in str (x ):
132- meanings .append (x )
133- name = a .text
134- out [name ] = meanings
135- return out
136- except Exception as e :
137- if disable_errors == False :
138- print ("Error: The Following Error occured: %s" % e )
116+ term = "+" . join ( term . split () )
117+
118+ try :
119+ html = _get_soup_object ("http://wordnetweb.princeton.edu/perl/webwn?s={0}" .format (
120+ term ))
121+ types = html .findAll ("h3" )
122+ length = len (types )
123+ lists = html .findAll ("ul" )
124+ out = {}
125+ for a in types :
126+ reg = str (lists [types .index (a )])
127+ meanings = []
128+ for x in re .findall (r'\((.*?)\)' , reg ):
129+ if 'often followed by' in x :
130+ pass
131+ elif len (x ) > 5 or ' ' in str (x ):
132+ meanings .append (x )
133+ name = a .text
134+ out [name ] = meanings
135+ return out
136+ except Exception as e :
137+ if disable_errors == False :
138+ print ("Error: The Following Error occured: %s" % e )
139139
140140if __name__ == '__main__' :
141141 d = PyDictionary ('honest' ,'happy' )
0 commit comments