Skip to main content

Functions

Some Wrangles require authentication to the WrangleWorks servers to function. See the installation instructions

Wrangles can be used as functions, directly incorporated into python code.

>>> import wrangles
>>> wrangles.extract.attributes('it is 15mm long')

{'length': ['15mm']}

Wrangles broadly accept a single input string, or a list of strings. If a list is provided, the results will be returned in an equivalent list in the same order and length as the original.

Classify​

Predict which categories items belong to. A classification wrangle must be created to be able to use this.

Tabset​

Samples​

>>> wrangles.classify('ball bearing', '<model id>')
MechPT

>>> wrangles.classify(['ball bearing', 'spanner'], '<model id>')
['MechPT', 'Tools']

Parameters​

ParameterRequiredData TypeNotes
input✓str, listThe text(s) to be classified.
model_id✓strID of the model to run.

Extract​

Address​

Tabset​

Samples​

Extract features from addresses such as streets or countries.

>>> wrangles.extract.address('1100 Congress Ave, Austin, TX 78701, USA', 'streets')
['1100 Congress Ave']

>>> wrangles.extract.address(['1100 Congress Ave, Austin, TX 78701, USA'], 'streets')
[['1100 Congress Ave']]
Parameters​
ParameterRequiredData TypeNotes
input✓str, listThe text(s) to be searched for attributes.
dataType✓streets / cities / regions / countriesThe type of information to return.

Ai​

Tabset​

Samples​

Use the power of AI (OpenAI's chatGPT in particular) to extract meaningful data

>>> wrangles.extract.ai('Yellow Submarine', api_key='<api key>', output='The names of any colors found in the input)
'Yellow'

>>> wrangles.extract.ai('Yellow Submarine', api_key='<api key>', output={'type': 'string', 'description': 'The names of any colors found in the input'})
'Yellow'
Parameters​
ParameterRequiredData TypeNotes
input✓str, listA single value or list of values to extract information from. If a list is provided, each element will be analyzed individually and a list of equal length will be returned.
api_key✓strAn OpenAI API key.
outputstr, dictThis can be a string prompting the output, a JSON schema definition of the output requested or a dict of JSON schema definitions.
model_idstrAn extract.ai model ID containing a saved definition. Use this or output. If both are provided, output that precedence over the definition from the model_id.
modelstrThe model to use for the extraction. Current default is set to gpt-4o-mini.
threadsintNumber of threads to use for parallel processing.
timeoutintTimeout in seconds for each API call.
retriesintNumber of retries to attempt on failure.
messageslistOverall prompts to pass additional instructions.
urlstrOverride the endpoint. Must implement the OpenAI chat completions API schema with function calling.

Attributes​

Extract numeric attributes such as lengths or voltages.

Tabset​

Samples​
>>> wrangles.extract.attributes('it is 15mm long')
{'length': ['15mm']}

>>> wrangles.extract.attributes(['it is 15mm long', 'the voltage is 15V'])
[{'length': ['15mm']}, {'electric potential': ['15V']}]
Parameters​
ParameterRequiredData TypeNotes
input✓str, listThe text(s) to be searched for attributes.
responseContentspan / objectDefault span. If span, returns original text, if object returns an object of value and dimension.
typeangle / area / current / force / length / power / pressure / electric potential / volume / massSpecify which types of attributes to find. If omitted, a dictionary of all attributes types is returned

Codes​

Extract alphanumeric codes.

Tabset​

Samples​
>>> wrangles.extract.codes('test ABCD1234ZZ test')
['ABCD1234ZZ']

>>> wrangles.extract.codes(['test ABCD1234ZZ test', 'NNN555BBB this one has two XYZ789'])
[['ABCD1234ZZ'], ['NNN555BBB', 'XYZ789']]
Parameters​
ParameterRequiredData TypeNotes
input✓str, listThe text(s) to be searched for codes.

Custom​

Extract entities using a custom model. An extraction wrangle must be created to be able to use this.

Tabset​

Samples​
>>> wrangles.extract.custom('test skf test', '<model id>')
['SKF']

>>> wrangles.extract.custom(['test skf test', 'festo is hidden in here'], '<model id>')
[['SKF'], ['FESTO']]
Parameters​
ParameterRequiredData TypeNotes
input✓str, listThe text(s) to be searched for custom entities.
model_id✓strID of the model to run.

Properties​

Extract categorical properties such as colours or materials.

Tabset​

Samples​
>>> wrangles.extract.properties('yellow submarine')
{'Colours': ['Yellow']}

>>> wrangles.extract.properties(['yellow submarine', 'the green mile'])
[{'Colours': ['Yellow']}, {'Colours': ['Green']}]
Parameters​
ParameterRequiredData TypeNotes
input✓str, listThe text(s) to be searched for properties.
typecolours / materials / shapes / standardsThe type of property to return. If omitted, a dictionary with all results will be returned.

Lookup​

Lookups can be used to look up data from a saved lookup wrangle. They can either be key (exact) or semantic (most similar meaning) based matches.

Exact Lookups​

Exact lookups look up exact matches (from your list of values) in a saved lookup wrangle.

Tabset​

Samples​
>>> wrangles.lookup(["Key1", "Key2"], "<model id>", "Value1")
["Key1's Value1", "Key2's Value1"]

>>> wrangles.lookup("Key1", "<model id>")
{"Value1": "Key1's Value1", "Value2": "Key1's Value2"}
Parameters​
ParameterRequiredData TypeNotes
input✓str, listThe text(s) to be searched for properties.
model_id✓strID of the model to run.
columnsstr, listThe columns to be returned. If not provided, all columns will be returned as a dict.

Semantic Lookups​

Semantic lookups look up the most similar matches (from your list of values) in a saved lookup wrangle.

Tabset​

Samples​
>>> wrangles.lookup(["KeyOne", "KeyTwo"], "<model id>", "Value1")
["Key1's Value1", "Key2's Value1"]

>>> wrangles.lookup("KeyOne", "<model id>")
{"Value1": "Key1's Value1", "Value2": "Key1's Value2"}
Parameters​
ParameterRequiredData TypeNotes
input✓str, listThe text(s) to be searched for properties.
model_id✓strID of the model to run.
columnsstr, listThe columns to be returned. If not provided, all columns will be returned as a dict.

Standardize​

Standardize text data, such as replacing abbreviations. A standardization wrangle must be created to be able to use this.

Tabset​

Samples​

>>> wrangles.standardize('It will arrive asap.', '<model id>')
'It will arrive as soon as possible.'

>>> wrangles.standardize(['It will arrive asap.', 'I live in the USA'])
['It will arrive as soon as possible.', 'I live in the United States']

Parameters​

ParameterRequiredData TypeNotes
input✓str, listThe text(s) to be standardized.
model_id✓strID of the model to run.

Translate​

Translate text between languages.

Requires a WrangleWorks Account and DeepL API Key (A free account for up to 500,000 characters per month is available).

Tabset​

Samples​

>>> wrangles.translate('My name is Chris', 'ES')
Mi nombre es Chris

>>> wrangles.translate(['My name is Chris', 'I live in Austin'], 'DE')
['Mein Name ist Chris', 'Ich wohne in Austin']

Parameters​

ParameterRequiredData TypeNotes
input✓str, listThe text(s) to be classified.
target_language✓strA code for the target language. Available Codes
source_languagestrA code for the source language. If omitted, the language will be inferred from the contents.
caselower / upper / titleAllow changing the case of the input prior to translation.