Comments (5)
I have used this code to assume units for tags:
from collections import Counter
from itertools import chain
from stroyprombeton import models as stb_models
def most_common(group):
return Counter(chain.from_iterable(
t.name.split(' ') for t in group.tags.all()
)).most_common(10)
for g in stb_models.TagGroup.objects.all():
print(g.name, ':', most_common(g))
The result:
Длина : [('м', 760), ('279', 2), ('4600', 2), ('1860', 2), ('3360', 2), ('2760', 2), ('2160', 2), ('3000', 2), ('4000', 2), ('5280', 2)]
Ширина : [('м', 403), ('750', 2), ('900', 2), ('1100', 2), ('1000', 2), ('1200', 2), ('2100', 2), ('2500', 2), ('1500', 2), ('2000', 2)]
Высота : [('м', 439), ('750', 2), ('900', 2), ('1100', 2), ('200', 2), ('250', 2), ('300', 2), ('350', 2), ('400', 2), ('580', 2)]
Масса : [('кг', 1465), ('2330.0', 2), ('5280.0', 2), ('480.0', 2), ('900.0', 2), ('5300.0', 2), ('6300.0', 2), ('350.0', 2), ('470.0', 2), ('700.0', 2)]
Объём : [('м', 946), ('куб', 946), ('0.97', 2), ('1.4', 2), ('2.2', 2), ('0.2', 2), ('0.35', 2), ('1.3', 2), ('2.52', 2), ('0.13', 2)]
Внешний диаметр : [('м', 43), ('660', 2), ('910', 2), ('1200', 2), ('1240', 2), ('1530', 2), ('1780', 2), ('1820', 2), ('1940', 2), ('2400', 2)]
Внутренний диаметр : [('м', 17), ('500', 2), ('750', 2), ('1000', 2), ('1250', 2), ('1500', 2), ('2000', 2), ('400', 1), ('700', 1), ('2500', 1)]
Рабочая документация : [('Серия', 42), ('выпуск', 28), ('3.900.1-10,', 8), ('1.152.1-8,', 7), ('1', 6), ('3.006.1-3/83,', 3), ('2', 3), ('3.902.1-12,', 3), ('3', 2), ('6', 2)]
This is group of tags to unit map:
Длина, Высота, Ширина, Внешний диаметр, Внутренний диаметр -> м
Масса -> кг
Объём -> м куб
from stroyprombeton.
Done
from stroyprombeton.
I have used this script:
from django.db.utils import IntegrityError
from stroyprombeton import models as stb_models
def add_units_to_tags():
m = 'м'
units = {
'Длина': m,
'Высота': m,
'Ширина': m,
'Внешний диаметр': m,
'Внутренний диаметр': m,
'Масса': 'кг',
}
duplicates = []
complex_units = {'Объём': 'м куб'}
for tag in stb_models.Tag.objects.all():
group_name = tag.group.name
if group_name not in units and group_name not in complex_units:
print(f'Skip {group_name}')
continue
if group_name in units and units[group_name] not in tag.name.split(' '):
units_to_set = units[group_name]
elif group_name in complex_units and len(tag.name.split(complex_units[group_name])) == 1:
units_to_set = complex_units[group_name]
else:
units_to_set = ''
tag.name = f'{tag.name} {units_to_set}'.strip()
try:
tag.save()
except IntegrityError:
duplicates.append({
'dup_id': tag.id,
'orig': {
'name': tag.name,
'group_id': tag.group.id}})
return duplicates
from stroyprombeton.
@artemiy312 , it seems we should have мм
instead of м
for metrical dimensions.
That's pretty what is #746 what about. Assigned it on you
from stroyprombeton.
I have added units for 49 tags. The rest of 1577 have been removed in this issue #754 as duplicates
from stroyprombeton.
Related Issues (20)
- Add or fix tags to the category page's DB templates HOT 2
- Bad dimension units at tags content HOT 6
- Redundant group name occurences at the tag values HOT 7
- navigation_menu.html:9-12: Show example Series and... HOT 1
- Doubled product names on the section page
- Merge duplicate tags HOT 4
- Merge duplicate tags HOT 6
- tags.py:4: Move all tags related context classes in this... HOT 1
- product_pdf_price.html:58: Render an option's tags for... HOT 2
- Define region by IP
- parse_stalbeton.py:25-26: Parse work docs from stalbeton.... HOT 1
- parse_stalbeton.py:84-86: Implement... HOT 1
- parse_stalbeton.py:104: Parse stalbeton's options. HOT 1
- parse_stalbeton.py:107-109: Parse series from stalbeton.... HOT 1
- parse_stalbeton.py:122-124: Create... HOT 1
- parse_stalbeton.py:128-131: Save parsed stalbeton to a... HOT 1
- Fix tags wrong dimension units HOT 3
- Expand product names at the section page HOT 1
- Oversized menu dropdown issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stroyprombeton.