回答編集履歴

4

再修正

2019/10/01 10:03

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -15,6 +15,8 @@
15
15
 
16
16
 
17
17
  **方法2: 正規表現を利用**
18
+
19
+ ~~仕様を勘違いしていたため削除。~~
18
20
 
19
21
  仕様を二重に勘違いしていたため復活。
20
22
 

3

さらに修正

2019/10/01 10:03

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -8,15 +8,25 @@
8
8
 
9
9
  ```Python
10
10
 
11
- tf = any(text in word for word in lst)
11
+ tf = any(word in text for word in lst)
12
12
 
13
13
  ```
14
14
 
15
15
 
16
16
 
17
- ~~**方法2: 正規表現を利用**~~
17
+ **方法2: 正規表現を利用**
18
18
 
19
- 仕様を勘違いしていたため一旦削除
19
+ 仕様を二重に勘違いしていたため復活
20
+
21
+ ```Python
22
+
23
+ import re
24
+
25
+ pattern = '|'.join(lst)
26
+
27
+ tf = bool(re.search(pattern, text))
28
+
29
+ ```
20
30
 
21
31
 
22
32
 
@@ -28,7 +38,7 @@
28
38
 
29
39
  for word in lst:
30
40
 
31
- if purpose in word:
41
+ if word in purpose:
32
42
 
33
43
  return True
34
44
 
@@ -50,7 +60,7 @@
50
60
 
51
61
  for word in lst:
52
62
 
53
- if text in word:
63
+ if word in text:
54
64
 
55
65
  tf = True
56
66
 
@@ -66,10 +76,6 @@
66
76
 
67
77
  ---
68
78
 
69
- **番外: 単語限定ならこれもありかも**
79
+ ~~**番外: 単語限定ならこれもありかも**~~
70
80
 
71
- ```Python
81
+ 仕様を勘違いしたため削除。
72
-
73
- tf = text in ','.join(lst)
74
-
75
- ```

2

追記

2019/10/01 09:55

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -61,3 +61,15 @@
61
61
  tf = False
62
62
 
63
63
  ```
64
+
65
+
66
+
67
+ ---
68
+
69
+ **番外: 単語限定ならこれもありかも**
70
+
71
+ ```Python
72
+
73
+ tf = text in ','.join(lst)
74
+
75
+ ```

1

修正

2019/10/01 09:50

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -8,25 +8,15 @@
8
8
 
9
9
  ```Python
10
10
 
11
- tf = any(word in text for word in lst)
11
+ tf = any(text in word for word in lst)
12
12
 
13
13
  ```
14
14
 
15
15
 
16
16
 
17
- **方法2: 正規表現を利用**
17
+ ~~**方法2: 正規表現を利用**~~
18
18
 
19
- ```Python
19
+ 仕様を勘違いしていたため一旦削除。
20
-
21
- import re
22
-
23
-
24
-
25
- pattern = '|'.join(lst)
26
-
27
- tf = bool(re.search(pattern, text))
28
-
29
- ```
30
20
 
31
21
 
32
22
 
@@ -38,7 +28,7 @@
38
28
 
39
29
  for word in lst:
40
30
 
41
- if word in purpose:
31
+ if purpose in word:
42
32
 
43
33
  return True
44
34
 
@@ -60,7 +50,7 @@
60
50
 
61
51
  for word in lst:
62
52
 
63
- if word in text:
53
+ if text in word:
64
54
 
65
55
  tf = True
66
56