categorize¶
categorize(items)
Description¶
Categorize items
in categories and subcategories.
Using GenAi, this function generates a hierarchy of categories and subcategories that best represents the given items
.
(items
: must be a json array of strings or or objects).
It returns a json array of objects as:
[
{item: first_item, ...
]
Usage¶
Call or Deploy categorize
?
Call categorize
directly
The easiest way to use bigfunctions
categorize
function is deployed in 39 public datasets for all of the 39 BigQuery regions.- It can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
- (You need to use the dataset in the same region as your datasets otherwise you may have a function not found error)
Public BigFunctions Datasets
Region | Dataset |
---|---|
eu |
bigfunctions.eu |
us |
bigfunctions.us |
europe-west1 |
bigfunctions.europe_west1 |
asia-east1 |
bigfunctions.asia_east1 |
... | ... |
Deploy categorize
in your project
Why deploy?
- You may prefer to deploy
categorize
in your own project to build and manage your own catalog of functions. - This is particularly useful if you want to create private functions (for example calling your internal APIs).
- Get started by reading the framework page
Deployment
categorize
function can be deployed with:
pip install bigfunctions
bigfun get categorize
bigfun deploy categorize
Examples¶
1. Categorize texts
select bigfunctions.eu.categorize(json '''[
"this is a great application"
"i cannot connect"
]'''
)
select bigfunctions.us.categorize(json '''[
"this is a great application"
"i cannot connect"
]'''
)
select bigfunctions.europe_west1.categorize(json '''[
"this is a great application"
"i cannot connect"
]'''
)
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| categories |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| [
{'item': 'this is a great application', 'category': 'General Feedback/Positive Review'},
{'item': 'i cannot connect', 'category': 'App Issues/Login Issues'},
]
|
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2. Categorize User Reviews of Nickel App in App Store
select bigfunctions.eu.categorize(
(
select to_json(array_agg(content))
from bigfunctions.eu.get_appstore_reviews(
'https://apps.apple.com/fr/app/nickel-compte-pour-tous/id1119225763'
)
)
)
select bigfunctions.us.categorize(
(
select to_json(array_agg(content))
from bigfunctions.us.get_appstore_reviews(
'https://apps.apple.com/fr/app/nickel-compte-pour-tous/id1119225763'
)
)
)
select bigfunctions.europe_west1.categorize(
(
select to_json(array_agg(content))
from bigfunctions.europe_west1.get_appstore_reviews(
'https://apps.apple.com/fr/app/nickel-compte-pour-tous/id1119225763'
)
)
)
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| categories |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| [
{'item': 'this is a great application', 'category': 'General Feedback/Positive Review'},
{'item': 'i cannot connect', 'category': 'App Issues/Login Issues'},
]
|
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Need help or Found a bug?
Get help using categorize
The community can help! Engage the conversation on Slack
We also provide professional suppport.
Report a bug about categorize
If the function does not work as expected, please
- report a bug so that it can be improved.
- or open the discussion with the community on Slack.
We also provide professional suppport.