$provider was never initialized. Although not strictly required by PHP, it is generally a good practice to add $provider = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array
definition as it guarantees a stable state of the code.
Let’s take a look at an example:
foreach($collectionas$item){$myArray['foo']=$item->getFoo();if($item->hasBar()){$myArray['bar']=$item->getBar();}// do something with $myArray}
As you can see in this example, the array $myArray is initialized the first
time when the foreach loop is entered. You can also see that the value of the
bar key is only written conditionally; thus, its value might result from a
previous iteration.
This might or might not be intended. To make your intention clear, your code
more readible and to avoid accidental bugs, we recommend to add an explicit
initialization $myArray=array() either outside or inside the foreach loop.
Loading history...
46
'極めてコンパクトな日本語分かち書きソフトウェアです。',
47
array(
48
'極め', // should be 極めて
49
'て',
50
'コンパクト',
51
'な',
52
'日本',
53
'語分',
54
'かち',
55
'書き',
56
'ソフトウェア',
57
'です',
58
'。'
59
)
60
);
61
62
$provider[] = array(
63
'日本語の新聞記事であれば文字単位で95%程度の精度で分かち書きが行えます。 ',
64
array(
65
'日本語',
66
'の',
67
'新聞',
68
'記事',
69
'で',
70
'あれ',
71
'ば',
72
'文字',
73
'単位',
74
'で',
75
'9',
76
'5',
77
'%',
78
'程度',
79
'の',
80
'精度',
81
'で',
82
'分かち',
83
'書き',
84
'が',
85
'行え',
86
'ます',
87
'。'
88
89
)
90
);
91
92
$provider[] = array(
93
'私の名前は中野です',
94
array(
95
'私',
96
'の',
97
'名前',
98
'は',
99
'中野',
100
'です'
101
)
102
);
103
104
$provider[] = array(
105
'TinySegmenterは25kBで書かれています。',
106
array(
107
'TinySegmenter',
108
'は',
109
'2',
110
'5',
111
'kB',
112
'で',
113
'書か',
114
'れ',
115
'て',
116
'い',
117
'ます',
118
'。'
119
)
120
);
121
122
$provider[] = array(
123
'隣の客はAK47振りかざしてギャアギャアわめきたてる客だ。',
124
array(
125
'隣',
126
'の',
127
'客',
128
'は',
129
'AK',
130
'4',
131
'7',
132
'振り',
133
'かざ', // should be かざし
134
'し',
135
'て',
136
'ギャアギャア',
137
'わめき',
138
'た',
139
'てる',
140
'客',
141
'だ',
142
'。'
143
)
144
);
145
146
// See JaCompoundGroupTokenizerTest for comparison
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArray
is initialized the first time when the foreach loop is entered. You can also see that the value of thebar
key is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.