cosmel.repo.product module

class cosmel.repo.product.Product(pid, brand, name, head, name_ws, descr_ws)[source]

Bases: object

The product object.

Parameters:
  • pid (str) – the ID.
  • brand (Brand) – the brand.
  • name (str) – the name.
  • head (str) – the head word.
  • name_ws (str) – the segmented name.
  • descr_ws (str) – the segmented description.
brand

the brand.

Type:Brand
pid

the ID.

Type:str
name

the name (excluding brand).

Type:str
name_ws

the word-segmented name.

Type:WsWords
descr

the description.

Type:str
descr_ws

the word-segmented description.

Type:WsWords
head

the head word.

Type:str
head_ws

the word-segmented name.

Type:WsWords
infix_ws

the word-segmented infix.

Type:WsWords
infix_ws_(with_head=True)[source]

WsWords: the word-segmented infix (with/without head word).

suffix_ws

the word-segmented suffix.

Type:WsWords
suffix_ws_(with_head=True)[source]

WsWords: the word-segmented suffix (with/without head word).

class cosmel.repo.product.ProductSet(repo_root, bname_to_brand)[source]

Bases: collections.abc.Collection

The set of products.

  • Item: the product object (Product).
Parameters:
  • repo_root (str) – the path to the folder containing data files.
  • bname_to_brand (BName2Brand) – the dictionary maps brand name to brand object.
class cosmel.repo.product.Id2Product(product_set)[source]

Bases: collections.abc.Mapping

The dictionary maps ID to product.

  • Key: the product ID. (str).
  • Item: the product object (Product).
Parameters:product_set (ProductSet) – the product set.
class cosmel.repo.product.BrandPName2Product(product_set)[source]

Bases: collections.abc.Mapping

The dictionary maps brand object and product name to product object.

  • Key: the tuple of brand object (Brand) and product name (str).
  • Item: the product object (Product).
Parameters:product_set (ProductSet) – the product set.
class cosmel.repo.product.BNamePName2Product(brand_pname_to_product, bname_to_brand)[source]

Bases: collections.abc.Sequence

The dictionary maps brand name and product name to product.

  • Key: the tuple of brand name (str) and product name (str).
  • Item: the product object (Product).
Parameters:
  • brand_pname_to_product (BrandPName2Product) – the dictionary maps brand object and product name to product object.
  • bname_to_brand (BName2Brand) – the dictionary maps name and brand.
class cosmel.repo.product.PName2ProductList(product_set)[source]

Bases: collections.abc.Mapping

The dictionary maps product name to product object list.

Parameters:product_set (ProductSet) – the product set.
class cosmel.repo.product.BrandHead2ProductList(product_set)[source]

Bases: collections.abc.Mapping

The dictionary maps brand object and head word to product object list.

Parameters:product_set (ProductSet) – the product set.
class cosmel.repo.product.BNameHead2ProductList(brand_head_to_product_list, bname_to_brand)[source]

Bases: collections.abc.Sequence

The dictionary maps brand name and head word to product object list.

  • Key: tuple of brand name (str) and product head word (str).
  • Item: ReadOnlyList of product object (Product).
Parameters:
  • brand_head_to_product_list (BrandHead2Productlist) – the dictionary maps brand object and head word to product object list.
  • bname_to_brand (BName2Brand) – the dictionary maps name and brand.