How to use extract_tags method in localstack

Best Python code snippet using localstack_python

testExtration.py

Source:testExtration.py Github

copy

Full Screen

...11#代码文件夹包含文件chinesenews.txt,内容为一篇中文新闻#12'''13input_file = open('chinesenews.txt',encoding= 'utf8')14fileContent = input_file.read()15tags = ChineseDealing.extract_tags(fileContent, topK=5)16print ('1'+",".join(tags))17'''18str1 = '记者10日从公安部获悉,全国公安交通管理部门将从10月11日至12月31日开展公路重点交通违法行为专项整治工作,对高速公路及重点国、省道上的超速行驶、客车超员、疲劳驾驶3种严重违法行为进行集中整治。'19keystr1 = '整治交通违法'20print(keystr1)21print(str1)22print(ChineseDealing.extractNewsTag(str1))2324str2 = '10日10时50分左右,重庆綦江县境内发生一起重大交通事故,一辆中型客车由于方向盘突然失灵,客车从山间公路上侧翻掉入河中,目前已确定7人死亡、15人受伤。'25keystr2 = '重庆重大车祸'26print(keystr2)27print(str2)28print(ChineseDealing.extractForumTag(str2))2930str3 = '一位石油业内专家认为,国内成品油价格可能出现“象征性”的下调。'31keystr3 = '油价'32print(keystr3)33print(str3)34print(ChineseDealing.extractNewsTag(str3))3536str4 = '铁道部公安局政委张庆和昨日表示,预计明年4月我国列车将实现第六次大提速,在一些区段客车运行时速可达200公里。'37keystr4 = '列车提速'38print(keystr4)39print(str4)40print(ChineseDealing.extract_tags(str4, topK=2))4142str5 = '记者10日从陕西省渭南市政府了解到,当地大面积滑坡灾害最后一名遇难者遗体已被发现,此次灾害被埋13位村民中有1人获救、12人死亡。'43keystr5 = '陕西滑坡'44print(keystr5)45print(str5)46print(ChineseDealing.extract_tags(str5, topK=2))4748str6 = '绑架杀害内蒙古自治区知名民营企业家云全民的两名凶手潘永忠和刘志强,在10日的一审宣判中被呼和浩特市中级人民法院判处死刑,剥夺政治权利终身。'49keystr6 = '内蒙古绑架杀人案'50print(keystr6)51print(str6)52print(ChineseDealing.extract_tags(str6, topK=2))5354str7 = '昨日,发改委、教育部等七部委联合发出通知,决定从10月上旬开始至11月底,在全国范围内开展教育收费专项检查。据记者了解,我国55万所中小学中,每年择校费收入至少百亿元以上。'55keystr7 = '择校费'56print(keystr7)57print(str7)58print(ChineseDealing.extract_tags(str7, topK=2))5960str8 = '去年发生在云南文山“10·18”的校园惨案中,一名未满18周岁的中学生因怀恨同村同学,深夜悄悄潜入宿舍,杀死熟睡的同学。就在他走出凶案现场时,遇见了另外两个同学,第二天晚上,凶手再次进入宿舍杀人灭口。此案震惊全国。记者昨日获悉,云南省高院对这起凶杀案作出终审判决:维持一审法院判处凶手无期徒刑,并由被告人家属及其所在学校共同赔偿死者家属15万元。'61keystr8 = '云南校园惨案追踪'62print(keystr8)63print(str8)64print(ChineseDealing.extract_tags(str8, topK=2))6566str9 = '近日,一位阳光型的准未婚妈妈却用她的坚强和乐观感染了身边的朋友和许多网民。地瓜猪(blog)——北京某报一名文化记者,在几个月前突遇感情变故,却毅然决定留下肚里的孩子,亲切地称这个孩子为“猪娃”,并在博客中用轻松、调侃的语言记录下怀孕期间的点点滴滴,该博客的点击率在一周内突破30万。'67keystr9 = '未婚妈妈开博客'68print(keystr9)69print(str9) ...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

...11class ExtractIpv4Test(unittest.TestCase):12 def do_extract(self, expected, text, tag='ipv4'):13 self.assertEqual(14 expected,15 extract_tags(text).get(tag, []))16 def test_all_zeroes(self):17 self.do_extract(['0.0.0.0'], '#0.0.0.0#')18 19 def test_multiple(self):20 self.do_extract(['0.0.0.0', '1.1.1.1'], '#0.0.0.0#1.1.1.1#')21 22 def test_all_ff(self):23 self.do_extract(['255.255.255.255'], '#255.255.255.255#')24 def test_out_of_range(self):25 self.do_extract([], '#256.256.256.256#')26 27 def test_short_formats(self):28 "Although these are valid IPs we only want to match full 4-octet IPs"29 self.do_extract([], '#192.168.1#')30 self.do_extract([], '#192.168#')31 self.do_extract([], '#192#')32class ExtractIpv6Test(unittest.TestCase):33 def do_extract(self, expected, text, tag='ipv6'):34 self.assertEqual(35 expected,36 extract_tags(text).get(tag, []))37 def test_full_address(self):38 self.maxDiff = None39 self.do_extract(40 ['fe80:0000:0000:0000:0204:61ff:fe9d:f156'], 41 '#fe80:0000:0000:0000:0204:61ff:fe9d:f156#')42 43 def test_drop_leading_zeroes(self):44 self.do_extract(45 ['fe80:0:0:0:204:61ff:fe9d:f156'], 46 '#fe80:0:0:0:204:61ff:fe9d:f156#')47 def test_collapse_multiple_zeroes(self):48 self.do_extract(49 ['fe80::204:61ff:fe9d:f156'], 50 '#fe80::204:61ff:fe9d:f156#')51 def test_localhost(self):52 self.do_extract(53 ['::1'], 54 '#::1#')55 56 def test_link_local_prefix(self):57 self.do_extract(58 ['fe80::'], 59 '#fe80::#')60 def test_global_unicast_prefix(self):61 self.do_extract(62 ['2001::'], 63 '#2001::#')64class ExtractEmailTest(unittest.TestCase):65 def do_extract(self, expected, text, tag='email'):66 self.assertEqual(67 expected,68 extract_tags(text).get(tag, []))69 def test_plain_email(self):70 self.do_extract(['test@test.com'], '#test@test.com#')71class ExtractMd5Test(unittest.TestCase):72 def do_extract(self, expected, text, tag='md5'):73 self.assertEqual(74 expected,75 extract_tags(text).get(tag, []))76 def test_plain_md5(self):77 self.do_extract(78 ['0123456789abcdef0123456789abcdef'],79 '#0123456789abcdef0123456789abcdef#')80 def test_uppercase(self):81 self.do_extract(82 ['0123456789ABCDEF0123456789ABCDEF'],83 '#0123456789ABCDEF0123456789ABCDEF#')84 85 def test_invalid_letters(self):86 self.do_extract(87 [],88 '#G123456789ABCDEF0123456789ABCDEF#')89 def test_md5_no_match_inside_longer(self):90 self.do_extract(91 [],92 '#0123456789abcdef0123456789abcdef00000000#')93class ExtractUrlTest(unittest.TestCase):94 def do_extract(self, expected, text, tag='url'):95 self.assertEqual(96 expected,97 extract_tags(text).get(tag, []))98 def test_http_url(self):99 self.do_extract(['http://www.example.com'], '#http://www.example.com ')100 def test_ftp_url(self):101 self.do_extract(['ftp://www.example.com'], '#ftp://www.example.com ')102class ExtractBaseDomainTest(unittest.TestCase):103 def do_extract(self, expected, text, tag='domain'):104 self.assertEqual(105 expected,106 extract_tags(text).get(tag, []))107 def test_dot_com(self):108 self.do_extract(['domain.com'], 'http://sub.domain.com/foo')109 def test_dot_co_dot_uk(self):110 self.do_extract(['domain.co.uk'], 'http://sub.domain.co.uk/foo')111 def test_multi_subdomains(self):112 self.do_extract(['domain.com'], 'http://sub1.sub2.domain.com/foo')113class ExtractHostnameTest(unittest.TestCase):114 def do_extract(self, expected, text, tag='hostname'):115 self.assertEqual(116 expected,117 extract_tags(text).get(tag, []))118 def test_dot_com(self):119 self.do_extract(['sub.domain.com'], 'http://sub.domain.com/foo')120 def test_dot_co_dot_uk(self):121 self.do_extract(['sub.domain.co.uk'], 'http://sub.domain.co.uk/foo')122 def test_multi_subdomains(self):123 self.do_extract(124 ['sub1.sub2.domain.com'],125 'http://sub1.sub2.domain.com/foo')126if __name__ == '__main__':...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

1from __future__ import absolute_import2from .tfidf import TFIDF3from .textrank import TextRank4try:5 from .analyzer import ChineseAnalyzer6except ImportError:7 pass8default_tfidf = TFIDF()9default_textrank = TextRank()10extract_tags = tfidf = default_tfidf.extract_tags11set_idf_path = default_tfidf.set_idf_path12textrank = default_textrank.extract_tags13def set_stop_words(stop_words_path):14 default_tfidf.set_stop_words(stop_words_path)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful