View Single Post
Old 10-15-2018, 12:00 PM   #139
knobunc
Junior Member
knobunc began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Sep 2018
Device: Paperwhite 3
Thanks! I'll give that a try.

Do you have any thoughts about making it possible to skip results from WorldCat that are not Dewey codes? e.g. "FIC" or "B" often come back. Unfortunately, they are not consistently used so I usually get back a DDC, but about 30% of the books have something else.

I added a (probably horrible) bit of code to classify_web_service_api.py to skip things that don't match a regex. And that works nicely for now while I'm updating my collection to include the FAST codes.

But I wasn't sure if it was something you were interested in adding to your plugin.

Code:
               #~ ---------------------------
                ddc = recommendations.getElementsByTagName('ddc')[0]
                #~ ---------------------------
                if ddc:
                    for mostPopular in ddc.getElementsByTagName('mostPopular'):
                        holdings = mostPopular.attributes["holdings"].value
                        nsfa = mostPopular.attributes["nsfa"].value
                        sfa = mostPopular.attributes["sfa"].value
                        if DEBUG: print('DDC mostPopular: class=' + sfa + ' normalized=' + nsfa + ' holdings=' + holdings)
                        # Allow cutter codes after matches, but we want numbers, not text strings (e.g. FIC, B, etc.)
                        if re.match(r"^\d+(\.$\d+)?(\s.+)?", sfa) is not None:
                            ddc_return = sfa
                            break
                    del ddc
                    del holdings
knobunc is offline   Reply With Quote