|
3 | 3 | """ |
4 | 4 | Python client for the Rosette API. |
5 | 5 |
|
6 | | -Copyright (c) 2014-2022 Basis Technology Corporation. |
| 6 | +Copyright (c) 2014-2024 Basis Technology Corporation. |
7 | 7 |
|
8 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); |
9 | 9 | you may not use this file except in compliance with the License. |
|
30 | 30 |
|
31 | 31 | _APPLICATION_JSON = 'application/json' |
32 | 32 | _BINDING_LANGUAGE = 'python' |
33 | | -_BINDING_VERSION = '1.28.0' |
| 33 | +_BINDING_VERSION = '1.29.0' |
34 | 34 | _CONCURRENCY_HEADER = 'x-rosetteapi-concurrency' |
35 | 35 | _CUSTOM_HEADER_PREFIX = 'X-RosetteAPI-' |
36 | 36 | _CUSTOM_HEADER_PATTERN = re.compile('^' + _CUSTOM_HEADER_PREFIX) |
@@ -345,6 +345,29 @@ def validate(self): |
345 | 345 | repr("names")) |
346 | 346 |
|
347 | 347 |
|
| 348 | +class RecordSimilarityParameters(_RequestParametersBase): |
| 349 | + """Parameter object for C{record-similarity} endpoint. |
| 350 | + Required: |
| 351 | + C{records} The records to be compared; where each left record is compared to the associated right record. |
| 352 | + C{properties} Parameters used in the call |
| 353 | + C{fields} The definition of the fields used in the comparison. There must be a minimum of 1 field and |
| 354 | + can have a maximum of 5 fields. |
| 355 | + """ |
| 356 | + |
| 357 | + def __init__(self): |
| 358 | + self.use_multipart = False |
| 359 | + _RequestParametersBase.__init__(self, ("fields", "properties", "records")) |
| 360 | + |
| 361 | + def validate(self): |
| 362 | + """Internal. Do not use.""" |
| 363 | + for option in "fields", "properties", "records": # required |
| 364 | + if self[option] is None: |
| 365 | + raise RosetteException( |
| 366 | + "missingParameter", |
| 367 | + "Required Record Similarity parameter is missing: " + option, |
| 368 | + repr(option)) |
| 369 | + |
| 370 | + |
348 | 371 | class EndpointCaller(object): |
349 | 372 | """L{EndpointCaller} objects are invoked via their instance methods to obtain results |
350 | 373 | from the Rosette server described by the L{API} object from which they |
@@ -592,7 +615,8 @@ def __init__( |
592 | 615 | 'TOKENS': 'tokens', |
593 | 616 | 'TOPICS': 'topics', |
594 | 617 | 'TRANSLITERATION': 'transliteration', |
595 | | - 'EVENTS': 'events' |
| 618 | + 'EVENTS': 'events', |
| 619 | + 'RECORD_SIMILARITY': 'record-similarity' |
596 | 620 | } |
597 | 621 |
|
598 | 622 | def __del__(self): |
@@ -966,6 +990,15 @@ def name_deduplication(self, parameters): |
966 | 990 | @return: A python dictionary containing the results of de-duplication""" |
967 | 991 | return EndpointCaller(self, self.endpoints['NAME_DEDUPLICATION']).call(parameters, NameDeduplicationParameters) |
968 | 992 |
|
| 993 | + def record_similarity(self, parameters): |
| 994 | + """ |
| 995 | + Create an L{EndpointCaller} to get similarity core between a list of records and call it. |
| 996 | + @param parameters: An object specifying the data, |
| 997 | + and possible metadata, to be processed by the record matcher. |
| 998 | + @type parameters: L{RecordSimilarityParameters} |
| 999 | + @return: A python dictionary containing the results of record matching.""" |
| 1000 | + return EndpointCaller(self, self.endpoints['RECORD_SIMILARITY']).call(parameters, RecordSimilarityParameters) |
| 1001 | + |
969 | 1002 | def text_embedding(self, parameters): |
970 | 1003 | """ deprecated |
971 | 1004 | Create an L{EndpointCaller} to identify text vectors found in the texts |
|
0 commit comments