Best Python code snippet using tox_python
segmenter_test.py
Source:segmenter_test.py
...81 def test_NON_UNIX_LINEBREAK_misses(self):82 for example in ('\n', ' ', '\t'):83 self.assertTrue(NON_UNIX_LINEBREAK.search(example) is None, repr(example))84 def test_simple_case(self):85 self.assertEqual(['This is a test.'], list(split_single("This is a test.")))86 def test_regex(self):87 self.assertSequenceEqual(SENTENCES, list(split_single(TEXT)))88 def test_names(self):89 sentences = ["Written by A. McArthur, K. Elvin, and D. Eden.",90 "This is Mr. A. Starr over there.",91 "B. Boyden is over there."]92 self.assertSequenceEqual(sentences, list(split_single(' '.join(sentences))))93 def test_alpha_items(self):94 sentences = ["This is figure A, B, and C.", "This is table A and B.", "That is item A, B."]95 self.assertSequenceEqual(sentences, list(split_single(' '.join(sentences))))96 def test_author_list(self):97 sentences = ["R. S. Kauffman, R. Ahmed, and B. N. Fields show stuff in their paper."]98 self.assertSequenceEqual(sentences, list(split_single(' '.join(sentences))))99 def test_long_bracket_abbervation(self):100 sentences = ["This is expected, on the basis of (Olmsted, M. C., C. F. Anderson, "101 "and M. T. Record, Jr. 1989. Proc. Natl. Acad. Sci. USA. 100:100), "102 "to decrease sharply."]103 self.assertSequenceEqual(sentences, list(split_single(' '.join(sentences))))104 def test_continuations(self):105 sentences = ["colonic colonization inhibits development of inflammatory lesions.",106 "to investigate whether an inf. of the pancreas was the case...",107 "though we hate to use capital lett. that usually separate sentences."]108 self.assertSequenceEqual(sentences, list(split_single(' '.join(sentences))))109 def test_inner_names(self):110 sentences = ["Bla bla [Sim et al. (1981) Biochem. J. 193, 129-141].",111 "The adjusted (ml. min-1. 1.73 m-2) rate."]112 self.assertSequenceEqual(sentences, list(split_single(' '.join(sentences))))113 def test_species_names(self):114 sentences = ["Their presence was detected by transformation into S. lividans.",115 "Three subjects diagnosed as having something."]116 self.assertSequenceEqual(sentences, list(split_single(' '.join(sentences))))117 def test_species_names_tough(self):118 sentences = ["The level of the genus Allomonas gen. nov. with so "119 "far the only species A. enterica known."]120 self.assertSequenceEqual(sentences, list(split_single(' '.join(sentences))))121 def test_multiline(self):122 text = "This is a\nmultiline sentence. And this is Mr.\nAbbrevation."123 ml_sentences = ["This is a\nmultiline sentence.", "And this is Mr.\nAbbrevation."]124 self.assertSequenceEqual(ml_sentences, list(split_multi(text)))125 def test_parenthesis(self):126 sentences = ["Nested ((Parenthesis. (With words right (inside))) (More stuff. "127 "Uff, this is it!))", "In the Big City."]128 self.assertSequenceEqual(sentences, list(split_single(' '.join(sentences))))129 def test_parenthesis_with_sentences(self):130 sentences = ["The segmenter segments on single lines or to consecutive lines.",131 "(If you want to extract sentences that cross newlines, remove those line-breaks.",132 "Segtok assumes your content has some minimal semantical meaning.)",133 "It gracefully handles this and similar issues."]134 self.assertSequenceEqual(sentences, list(split_single(' '.join(sentences))))135 def test_unclosed_brackets(self):136 sentences = ["The medial preoptic area (MPOA), and 2) did not decrease Fos-lir.",137 "However, olfactory desensitizations did decrease Fos-lir."]138 self.assertSequenceEqual(sentences, list(split_single(' '.join(sentences))))139 def test_linebreak(self):140 text = "This is a\nmultiline sentence."141 self.assertSequenceEqual(text.split('\n'), list(split_single(text)))142 def test_newline(self):143 self.assertSequenceEqual(SENTENCES, list(split_newline(OSPL)))144 def test_rewrite(self):145 # noinspection PyTypeChecker146 a_text = OSPL.replace('\n', '\u2028').replace(' ', '\n')147 result = rewrite_line_separators(a_text, MAY_CROSS_ONE_LINE)...
reformatObj.py
Source:reformatObj.py
1vertices = []2normals = []3textures = []4indices = []5with open('SkyBoxBlue.obj') as fp:6 for line in fp:7 if(line[0] == 'v'):8 if(line[1] == 'n'):9 normals.append(line)10 elif(line[1] == 't'):11 textures.append(line)12 else:13 vertices.append(line)14 elif(line[0] == 'f'):15 indices.append(line)16 17num_vertices = 1;18# read each indices and add to new.obj19f = open("new.obj", 'w')20for line in indices:21 split_line = line.split()22 temp = split_line[1]23 split_single = temp.split('/')24 f.write(vertices[int(split_single[0])-1])25 if(split_single[1] != ''):26 f.write(textures[int(split_single[1])-1])27 f.write(normals[int(split_single[2])-1])28 temp = split_line[2]29 split_single = temp.split('/')30 f.write(vertices[int(split_single[0])-1])31 if(split_single[1] != ''):32 f.write(textures[int(split_single[1])-1])33 f.write(normals[int(split_single[2])-1])34 temp = split_line[3]35 split_single = temp.split('/')36 f.write(vertices[int(split_single[0])-1])37 if(split_single[1] != ''):38 f.write(textures[int(split_single[1])-1])39 f.write(normals[int(split_single[2])-1])40 41 write_string = 'f ' + str(num_vertices) + '/' + str(num_vertices) + '/' + str(num_vertices) + ' ' + str(num_vertices+1) + '/' + str(num_vertices+1) + '/' + str(num_vertices+1) + ' ' + str(num_vertices+2) + '/' + str(num_vertices+2) + '/' + str(num_vertices+2) + '\n'42 f.write(write_string) 43 num_vertices += 344 ...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!