<jupyter_start><jupyter_text>NSFW Detection This tutorial is available as an IPython notebook at [Malaya/example/nsfw](https://github.com/huseinzol05/Malaya/tree/master/example/nsfw).     Pretty simple and straightforward, just to detect whether a text is NSFW or not.<jupyter_code>%%time
import malaya<jupyter_output>CPU times: user 4.05 s, sys: 741 ms, total: 4.79 s
Wall time: 4.59 s<jupyter_text>Get label<jupyter_code>malaya.nsfw.label<jupyter_output><empty_output><jupyter_text>Load lexicon modelPretty naive but really effective, lexicon gathered at [Malay-Dataset/corpus/nsfw](https://github.com/huseinzol05/Malay-Dataset/tree/master/corpus/nsfw).```pythondef lexicon(**kwargs):    """    Load Lexicon NSFW model.    Returns    -------    result : malaya.text.lexicon.nsfw.Lexicon class    """```<jupyter_code>lexicon_model = malaya.nsfw.lexicon()
string1 = 'xxx sgt panas, best weh'
string2 = 'jmpa dekat kl sentral'
string3 = '<NAME>'<jupyter_output><empty_output><jupyter_text>Predict batch of strings<jupyter_code>lexicon_model.predict([string1, string2, string3])<jupyter_output><empty_output><jupyter_text>Load multinomial modelAll model interface will follow sklearn interface started v3.4,```pythondef multinomial(**kwargs):    """    Load multinomial NSFW model.    Returns    -------    result : malaya.model.ml.BAYES class    """```<jupyter_code>model = malaya.nsfw.multinomial()<jupyter_output><empty_output><jupyter_text>Predict batch of strings<jupyter_code>model.predict([string1, string2, string3])<jupyter_output><empty_output><jupyter_text>Predict batch of strings with probability<jupyter_code>model.predict_proba([string1, string2, string3])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12477928193054738, 'fraction_numerical': 0.017657445556209534, 'mean_word_length': 6.423580786026201, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '366329', 'license': 'MIT', 'n_tokens_mistral': 609, 'n_tokens_neox': 579, 'n_words': 115, 'path': 'example/nsfw/load-nsfw.ipynb', 'repo_name': 'AetherPrior/malaya', 'size': '1718'}