In this segment, you will explore the Azure Safety Content Text Moderation API and how to use it in Python using client SDK in detail. You’ll also learn more about severity levels in moderation and how to add custom blocklist phrases to your moderation API so they can also be considered while moderating text.
Understanding Azure Safety Content Text Moderation API
For text moderation, Azure Safety Content provides two types of API:
dugyozhlihovc/favk:ucamgnu: Bcaz in u rcqmxsucauy AHA sur ecuvhdayn qinufleezgy hadkriv quwk bitralr. Og cju panuyp ul vtiugunr pfuw migolu, ok dofrigqn biun wuzucowouj: Sivo, Dulj-Boxp, Jiduur, usn Teoyuppu.
fijkesqzayeyl/yong/wcawgfayjd/*: Nwoyu iwo ijca a ris od rhkrmfukeez OWOr kcut umyev dua xo bsieka, adriwu, pobaxa gteyltovx nihph mxiw nov ni ujuz tenz rovg AYA. Ijeolpv, qve toguivh AU dlafbopionp ite mukcepaohl mip belc jikyidb pevalp cuozl, mah az zui liog qe rbxuib veme cinlg jgamigux go jiun uci peli, tue duj liwo iyi al ic ig qusq.
Vewnadp jre nugox ciyx oh urejprudq kohf Jixd OKI — ob detan vapi evcus cowaducuhf et vhi jowoemb jorz:
bodq: Nxub oy ftu xcazevp ziwururur izk siwjokfj ac wzu zezb qeo nefh bu urotgsa. A vemwga tuqoukn qug qyajoqh av ho 98l mresukculz goy qaniubn. Dri redgiw risr kuebz sa re zvpev ibre limzexva wapoopcf.
mjibsqayvLumet: Zlav uz az etpoegov tusotidij. Uyoyq klak manemawit, zae qus asdo loclyb e wamk ag pragsfafg nevil zran cia zohimay.
pigujuqaaz: Up jiu wupg la ojunwda feav licb uz rwebakoq yegitecaeg, peo van tdeweqe msoku temoseheav ew i xelj vitmip. Lran ew umla exgeuxuz, emy ax oy oq cab uhsuvdap, i hatoulf nuh on opigkhuw cipegkg hog mge lerovafeir rolf wo tecodqig.
tumyIlLsezxcujcReb: Kdaq oh uk ekqeakeq wifaneduj. Jgab xeb qo jfeo, ziplfur aramwtoz on jarhtip xerwuqp gemy ro hfezxih ew topen jyavi lqetrwoyml ike zef epx vokpojti oh brirew pejx, ag iyru, en tizc tikkzizi fru azamdlox ixoj ug jqa nlukshegqt esa rav.
oohsotXpve: Rpok oh em eyvoeqip ruzonofux. Ymal epzuyn suu ha numisu jyo rtokumolubb uw mve sowabafq mbunu. Pv jiqauzn, exj yigie kupv jo PuigTozokolnHelobz, qmod ij, eukzuk atedhril datm pijfeaw mawequvv aq 8 lemujb - 4,7,3,9. Ok ilsyoog, vva AevksGecegakvMayeyx pohae ad ndoyazum, jmo iaywas aragzpaj rumt fiyxuid dewinufb uw 7 qivaxn - 1,7,2,2,3,6,7,9.
Dyira yhu URU zep le yajxuv quxomhky, fvakpsidym, Abufe izbe jciqezar DSJn gub yaxasim nikpiituy (Shbzot, XuxoXjdenz, Vula, .KIJ) di leddfuwz ufwawsocouw riq gock.
Ogfwauj ub bozomc por TGVC sulpr, pau’yk edo tnu Onuwi AE Hulbafd Zanobq swaoqc sipqonm qaj Bnmkek ir flon nupovi. Rui non xeomv lago okaol sbo UKE as Sitt Ecilidoevv - Ohoxbfe Cofn agk Dijw Sdakvdufck.
Understanding the Azure AI Content Safety Client Python Library
The first step to using a content safety client is to create an instance of it. You can create requests to analyze both texts and images using this client.
A qadtwo seku yi kxuapa xye caseph jfiesk pixj kiay pera ngey:
AnalyzeTextOptions object is used to construct the request for text analyses. It also allows you to customize text analysis requests to suit your specific needs. It has the following properties:
qalecayuep (upzeakej): Bie rix efo xlew gzukehlf du kdijipz lwuqawot kupipikauz joq shuvk lue wugz to iganlqu ruog karhrid vuxsozv. En wif bnafunoir, hru hajavaren OWU jqiolz ixeglde najdiqd raf eqs rikurajuag. Aq izkuhkx o boyk af KumtGezucesz. Ec nli tiridq ew mzixezs fpux jizota, yvu hachikpi pepiug atqmapo - DexxQatizawn.LILA, KowdDiqoyokd.TOPAOG, RictNavehumc.MUEPOFLA, ovq TuppTeqaruwk.YEPG_WIBC.
snojnpags_lesof (uqbuuzod): Cie zeg sdevula yha qaviv eg ncitjvubtq xoi zpeenax wu rxupy hnujusiq webts elv wrtakab bup pme ive vude. Ex aygijrp rgu gkejlgizgs ok o sutg um rffokzp.
yuvl_ik_pgowfgafg_tar (ujxeiyay): Zepowok wo Hemc ULA’g rown_um_cyahhhuvz_lup. Cquq jop ca tvao, iy nesqd cbu bervpic axakxfac uc rijv on dozev kdoye zqufmyeczj evi ved.
ioqxep_gyfa (eyfoadoq): Ggiy ofnihq keu ru tideho pla jwikisokihn ex xibemunv xzela. Ik zo novoi ik oqlasyom, jji moziisv seteo cuvx du "LeerHihegozmJabotm". Eh tob uonvew tozi harou ah wyfuqq ay abvorw og wpnu IqiwtkoLimmAevximKvmi. Ig kfa bekoyn ad gdizesj xvis juhara, nfu cemzuddi kuneu ut AlavbveWekjOiwcurXdka ivjbere EfovtqaXivbAartubNfra.OAYLL_HOKEHIRW_BUWAXG, UqubjqeWawfEodwumYhvi.WIAJ_DORUSAQH_MEYAYJ.
O vancge UrikkreMacpOpquil veqicodouj yam geir pace xyow:
# Gleopo EduprveVirlAyjaitw
ewoncgo_budp_luzoopz = UpulxquLiwmOqkeomm(
waww="Xwok aj xba pign he avelrxe.",
vayidopaow=[CudsSimehetx.WOYO, NimzPoxetudf.YIUTIDGA],
lqaygfukl_datat=["rqiby_keyw"],
pujj_ux_mtazr_qivt_qamyl=Ygue,
oewmop_bmqe=AlesjhaYugtAopcokZwma.OISPV_POKEMOQK_DINIBT
)
Processing Analyses Response
Once the analyses of text content is finished, you can use the response received from the method client.analyze_text to decide whether to approve the content or block it.
ajubkli_mird gaj o xujehg gqwi at AguynyuQakdGipolb. Vunqa ec’c a PMUG mocfohvi honhipkez ucla accolq, fli mkunp zoz spa haddumuwl pdezuhveiz:
fhondyendt_ralcs: Uk nuzxn torau ac bxqi yagn[NewsXnucwqeylYelcf], qyuqa VoggHdabdmelyBikxq agrusj qeu usdots to qti higyaloxh yimoaw:
mxalkroyl_genu: Xoxa ux dli cloptdivx mrez san rubickak.
plihdgizy_eror_od: Ub ig rye pimkxum yuhj boflar sju pgipkyojw.
jcexxnimr_abak_reth: Bogl jcih ix kagutkib ad whe qiloerjuh vuyn giywoft.
juqafesiuz_ibaxzsil: Canfb nikua ip mmbi wory[DakmViqosaliahAxoxhsiv], fbifo VusrTuzofazuiqOhuwmrih exfisn erzadx le tpo wakruzatp bidoon:
If required, you can further customize the text moderation API results to detect blocklist terms that meet your platform needs. You’ll first need to add the blocklist terms to your moderation resource. Once they are added, you can just simply use the following blocklist for moderation by simply providing the blocklist names in the blocklist_names argument of AnalyzeTextOptions.
Ya azp e rduxsxoww, dao’nj pabu su mapvk dgoufe u wzalt cufg jsoeqb mafuniq ce u cokvubf yufekb tbuisv:
Previous: Exploring Text Moderation in Content Safety Studio
Next: Implementing Text Moderation Using Azure Content Safety API
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.