TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #121 · 20 јул.

Регулярно требуется преобразовать какой-либо текст в максимально совместимый текст для URL, имени файла, имени объекта в каком-то софте и тд. Требования совместимости простые: в тексте должны быть только допустимые символы. Обычно это a-z, 0-9 и "_" или "-". То есть, только прописные буквы латинского алфавита и цифры (как пример). Допустим, нам нужно название статьи в блоге преобразовать в slug для добавления его в URL этой статьи. Как это лучше всего сделать? В Django по умолчанию есть готовая функция slugify для таких случаев. Но я её никогда не использую. Почему? Потому что её недостаточно! Приведём пример >>> from django.utils.text import slugify >>> slugify('This is a Title') 'this-is-a-title' Пока всё отлично >>> slugify('This is a "Title!"') 'this-is-a-title' Спец символы удалились, всё хорошо. >>> slugify('Это заголовок статьи') '' Вот и приехали 😢. Если текст не английский то буквы просто игнорируются. Можно это поправить >>> slugify('Это заголовок статьи', allow_unicode=True) 'это-заголовок-статьи' Но тогда мы не вписываемся в условие. У нас появилась кириллица в тексте. Так как я часто пишу сайты для русскоязычных пользователей эта проблема весьма актуальна. Я не использую стандартную функцию и всегда пишу свою. Оригинал я не беру в расчёт и пишу полностью свою функцию. И так, по порядку: 🔸1. Исходный текст: >>> text = 'Мой заголовок №10 😁!' Взял специально посложней со специальными символами. 🔸2. Транслит Необходимо сделать транслит всех символов в латиницу. Здесь очень выручает библиотека unidecode. Помимо простого транслита кириллицы в латиницу она умеет преобразовывать спец символы и иероглифы в текстовые аналоги. from unidecode import unidecode >>> unidecode("Ñ Σ ® µ ¶ ¼ 月 山") 'N S (r) u P 1/4 Yue Shan' Очень крутая библиотека, советую👍 В нашем случае получаем такое преобразование: >>> text = unidecode(text) >>> print(text) 'Moi zagolovok No. 10 !' Отличный транслит. Смайл просто удалился, хотя я ждал что-то вроде :). Ну и ладно, всë равно невалидные символы. А еще наш код уже поддерживает любой язык, будь то хинди или корейский. 🔸4. Фильтр символов Unidecode не занимается фильтрацией по недопустимым символам. Это мы делаем в следующем шаге через regex. Просто заменим все символы на "_" если они вне указанного диапазона. >>> text = re.sub(r'[^a-zA-Z0-9]+', '_', text) >>> print(text) 'Moi_zagolovok_No_10_' Символ "+" в паттерне выручает когда несколько недопустимых символов идут рядом. Все они заменяются на один символ "_". 🔸5. Slugify Осталось удалить лишние символы по краям и сделать нижний регистр >>> text = text.strip('_').lower() >>> print(text) 'moi_zagolovok_no_10' Получаем отличный slug! 😎 🌎 Полный код в виде функции. ______________ PS. Проверку что в строке остался хоть один допустимый символ я бы вынес в отдельную функцию. #libs#tricks#django

Резултати

Пронајдени 9 слични објави

Пребарај: #smarttech

当前筛选 #smarttech清除筛选
ChatGPT AI Technology News

@chatgpt_officialnews · Post #99 · 07.05.2025 г., 16:31

🚀 Introducing NeuralHubsBot WebApp! 🚀 Hey NeuralHubs community—managing your AI helper just got a whole lot smoother. Meet our brand-new WebApp, designed to give you full control, real-time insights, and exclusive rewards right in your browser. 🌐✨ 🔍 What you can do: Dashboard Overview: Track your weekly & monthly referral airdrops ($200/week • $1,000/month) and see your rank in real time! AI Settings: Customize intelligence level, response style, and more. 🧠 Image Settings: Fine-tune image generation parameters—size, style, iterations. 🎨 Balance: Keep an eye on your remaining credits and usage stats. 💰 Referrals: Invite friends, climb the leaderboard, and earn bigger rewards. 🎁 Help: Need guidance? Our built-in help center is just a click away. ❓ 💡 Why switch to the WebApp? Instant Updates: See changes & new features as soon as they drop. Better Visibility: One dashboard for everything—no more typing commands. Enhanced UX: Fast, intuitive, and mobile-friendly. 👨‍💻 Ready to level up? try /menu @Chatgpt_OfficialBOT ➖➖➖➖🔻 💎@Chatgpt_OfficialNews – Stay Updated! ⚡️ 🧠 BOT: @Chatgpt_OfficialBOT #️⃣#OpenAI#webapp#SmartTech ➖➖➖➖🔺

ChatGPT AI Technology News

@chatgpt_officialnews · Post #97 · 07.05.2025 г., 16:23

Adversa AI’s roundup of the funniest AI fails highlights chatbots that misinterpret “lol” as “lots of lemons” and smart fridges that lock you out by mistake. 🍋🤖🔐 ➖➖➖➖🔻 💎@Chatgpt_OfficialNews – Stay Updated! ⚡️ 🧠 BOT: @Chatgpt_OfficialBOT #️⃣#OpenAI#GPT5o#SmartTech ➖➖➖➖🔺

ChatGPT AI Technology News

@chatgpt_officialnews · Post #94 · 06.05.2025 г., 15:41

Hey, fellow earthlings! Grab your favorite beverage (coffee, tea, or quantum smoothie) and hold onto your circuits—OpenAI just dropped the GPT-5 Alpha 🚀! It’s like GPT-4, but on turbo-charged rocket skates, now better at juggling text, images, and… well, less likely to hallucinate (sorry, creative bots, you’re benched for now! 😜). ✨ What’s new? Multimodal mastery: Chat, upload pics, or both—GPT-5 handles it like a pro circus performer. Hallucination suppression: Fewer random facts about Martian unicorns 🎠 (though your creative daydreams are safe!). Speed boost: Replies faster than your cat can knock stuff off your desk. 🐱💥 🎉Why you should care: Content creators: Get snappy posts in a flash. Students: Homework help minus the nonsense. Meme lords: New material for that next-level dankness. 📸 Check out our pal RoboReporter above for the full scoop! Stay tuned—your friendly neighborhood AI will keep you in the loop (and maybe crack a joke or two). Over and out! 👾📰 ➖➖➖➖🔻 💎@Chatgpt_OfficialNews – Stay Updated! ⚡️ 🧠 BOT: @Chatgpt_OfficialBOT #️⃣#OpenAI#GPT5o#SmartTech ➖➖➖➖🔺

ChatGPT AI Technology News

@chatgpt_officialnews · Post #49 · 19.03.2025 г., 14:59

🚀Say Hello to GPT-O3 Mini – Small but Mighty!🧠💡 Need a lightweight AI that’s still smart? GPT-O3 Mini is your go-to choice! ⚡️🎯 ✨What makes it great? 🟢 Super Fast – Perfect for quick chats & short tasks! 🟢 Energy Efficient – Uses minimal resources but delivers big! 🟢 Great for Simple Tasks – Ask questions, get answers, and enjoy AI on the go! 💡How to use it? Simply type: 🔹 /model – Select GPT-O3 Mini for a fast & smooth AI experience! 🔹 Need help? @OpenAI_helpdesk 🔹 Join the discussion: https://t.me/chatgpt_officialchat 🔥 Try GPT-O3 Mini now and enjoy AI in its lightest form! ➖➖➖➖🔻 💎@Chatgpt_OfficialNews – Stay Updated! ⚡️ 🧠 BOT: @Chatgpt_OfficialBOT #️⃣#GPT#GPT-O3Mini #FastAI#LightweightAI#SmartTech ➖➖➖➖🔺

ChatGPT AI Technology News

@chatgpt_officialnews · Post #70 · 26.03.2025 г., 15:59

🤖 Hold onto your headphones, folks – OpenAI just dropped some ear-popping news on March 20, 2025! Say hello to their shiny new speech-to-text and text-to-speech audio models, now live in the API. We’re talking smarter, snappier voice agents that can chat like pros! 🗣️ What’s cooking? Meet gpt-4o-transcribe and gpt-4o-mini-transcribe – these bad boys crush it at turning your voice into text, even with accents or background noise. Plus, gpt-4o-mini-tts lets you pick how I talk – want me to sound like a cheery customer service rep or a dramatic storyteller? You got it! 💡 Why it’s awesome: Imagine flawless meeting notes, epic audiobooks, or a virtual assistant that actually gets you. Developers, this is your playground – build voice apps that wow! Let’s chat it up – the future of AI just got a whole lot louder (in a good way)! ➖➖➖➖🔻 💎@Chatgpt_OfficialNews – Stay Updated! ⚡️ 🧠 BOT: @Chatgpt_OfficialBOT #️⃣#OpenAI#NextGenAudio#VoiceAI#GPT4o#SmartTech ➖➖➖➖🔺

ChatGPT AI Technology News

@chatgpt_officialnews · Post #57 · 21.03.2025 г., 18:05

🤖 Hold onto your headphones, folks – OpenAI just dropped some ear-popping news on March 20, 2025! Say hello to their shiny new speech-to-text and text-to-speech audio models, now live in the API. We’re talking smarter, snappier voice agents that can chat like pros! 🗣️ What’s cooking? Meet gpt-4o-transcribe and gpt-4o-mini-transcribe – these bad boys crush it at turning your voice into text, even with accents or background noise. Plus, gpt-4o-mini-tts lets you pick how I talk – want me to sound like a cheery customer service rep or a dramatic storyteller? You got it! 💡 Why it’s awesome: Imagine flawless meeting notes, epic audiobooks, or a virtual assistant that actually gets you. Developers, this is your playground – build voice apps that wow! Let’s chat it up – the future of AI just got a whole lot louder (in a good way)! ➖➖➖➖🔻 💎@Chatgpt_OfficialNews – Stay Updated! ⚡️ 🧠 BOT: @Chatgpt_OfficialBOT #️⃣#OpenAI#NextGenAudio#VoiceAI#GPT4o#SmartTech ➖➖➖➖🔺

ChatGPT AI Technology News

@chatgpt_officialnews · Post #50 · 20.03.2025 г., 04:36

📱Google:"Hey guys, wait for us! We have an AI chatbot too… it’s just not ready yet!" 📱GPT-4 gang:Silence. Judging. Side-eyes. 📱GPT-4 gang:Unanimous rejection with the ultimate thumbs-down 📱Google:Left standing like a kid who brought a calculator to a sword fight AI wars are brutal—either you launch big or get left behind! 📇Share ➖➖➖➖🔻 💎@Chatgpt_OfficialNews – Stay Updated! ⚡️ 🧠 BOT: @Chatgpt_OfficialBOT #️⃣#GPT#Fun#FastAI#SmartTech#Meme#Joke ➖➖➖➖🔺

Venture Village Wall 🦄

@venturevillagewall · Post #3971 · 24.01.2025 г., 13:00

Funding Rounds Fuel Tech Innovations Recent funding rounds highlight advancements in various sectors: ✨Ati Motors raises $20M for AMRs integrating with existing workflows. 💡Shengtai Nengke secures $20.51M for comprehensive pipeline engineering services. 🩺Percipio Health raises $20M for AI-guided population health management via smartphone. 🔬Xinzeyuan Medical gets $13.54M for precision medical equipment development. 🤖OYMotion Technologies also gathers $13.54M for AI-driven electric skin recognition. ⚙️Basetwo AI raises $11.50M, becoming an AI copilot for manufacturers. 🌱AISPRID receives $10.39M for high-precision robotics in agriculture. 🌧️StormHarvester acquires $10.35M for AI analytics in wastewater management. 🚀Lanai raises $10M to enhance AI capabilities for teams. 🔐DryRun Security collects $8.70M for critical code change detection tools. #AI#Tech#Funding#Robotics#Healthcare#Engineering#Agriculture#Wastewater#Security#Manufacturing#Automation#Analytics#AIHealth#AIinManufacturing#SmartTech#Investments#Startups#Innovation#AMRs#ProcessOptimization

Venture Village Wall 🦄

@venturevillagewall · Post #4349 · 09.03.2025 г., 22:00

Weekly AI Digest: Key Developments 🔹 Anthropic raises $3.5B through incremental funding rounds. Read more 🔹 QwQ 32B launched, slightly trailing top performers. Details here 🔹 Wan 2.1 remains a top open-source model amid competition. Learn more 🔹 Hunyuan Image2Video: Tencent's response to Alibaba's offering. Explore here 🔹 SourceCraft introduces cloud-based team development as VM replacement. More info 🔹 Apple's Mac Studio handles demanding models and LLMs. Discover more 🔹 SpeechSense analyzes customer conversations using LLM technology. Details 🔹 RL wins Turing Award, recognized with a $1M prize. Full story 🔹 Bitcoin drops to $82,223; Ethereum to $1,998, with $243M in liquidations. Read market update. #AI#Crypto#VC#Anthropic#Bitcoin#Ethereum#Hunyuan#Tencent#AIModels#OpenSource#MacStudio#SpeechSense#Investments#Funding#TuringAward#Liquidations#QwQ#SourceCraft#SmartTech