@@ 72-96 (lines=25) @@ | ||
69 | * |
|
70 | * @return \Org\Heigl\Hyphenator\Tokenizer\TokenRegistry |
|
71 | */ |
|
72 | public function run($input) |
|
73 | { |
|
74 | if ($input instanceof TokenRegistry) { |
|
75 | // Tokenize a TokenRegistry |
|
76 | $f = clone($input); |
|
77 | foreach ($input as $token) { |
|
78 | if (! $token instanceof WordToken) { |
|
79 | continue; |
|
80 | } |
|
81 | $newTokens = $this->tokenize($token->get()); |
|
82 | $f->replace($token, $newTokens); |
|
83 | } |
|
84 | ||
85 | return $f ; |
|
86 | } |
|
87 | ||
88 | // Tokenize a simple string. |
|
89 | $array = $this->tokenize($input); |
|
90 | $registry = new TokenRegistry(); |
|
91 | foreach ($array as $item) { |
|
92 | $registry->add($item); |
|
93 | } |
|
94 | ||
95 | return $registry; |
|
96 | } |
|
97 | ||
98 | /** |
|
99 | * Split the given string into tokens using whitespace. |
@@ 109-136 (lines=28) @@ | ||
106 | * |
|
107 | * @return \Org\Heigl\Hyphenator\Tokenizer\TokenRegistry |
|
108 | */ |
|
109 | public function run($input) |
|
110 | { |
|
111 | if ($input instanceof TokenRegistry) { |
|
112 | // Tokenize a TokenRegistry |
|
113 | $f = clone($input); |
|
114 | foreach ($input as $token) { |
|
115 | if (! $token instanceof WordToken) { |
|
116 | continue; |
|
117 | } |
|
118 | $newTokens = $this->_tokenize($token->get()); |
|
119 | if ($newTokens == array($token)) { |
|
120 | continue; |
|
121 | } |
|
122 | $f->replace($token, $newTokens); |
|
123 | } |
|
124 | ||
125 | return $f ; |
|
126 | } |
|
127 | ||
128 | // Tokenize a simple string. |
|
129 | $array = $this->_tokenize($input); |
|
130 | $registry = new TokenRegistry(); |
|
131 | foreach ($array as $item) { |
|
132 | $registry->add($item); |
|
133 | } |
|
134 | ||
135 | return $registry; |
|
136 | } |
|
137 | ||
138 | /** |
|
139 | * Split the given string into tokens using whitespace. |
@@ 68-94 (lines=27) @@ | ||
65 | * |
|
66 | * @return \Org\Heigl\Hyphenator\Tokenizer\TokenRegistry |
|
67 | */ |
|
68 | public function run($input) |
|
69 | { |
|
70 | if ($input instanceof TokenRegistry) { |
|
71 | // Tokenize a TokenRegistry |
|
72 | foreach ($input as $token) { |
|
73 | if (! $token instanceof WordToken) { |
|
74 | continue; |
|
75 | } |
|
76 | $newTokens = $this->_tokenize($token->get()); |
|
77 | if ($newTokens == array($token)) { |
|
78 | continue; |
|
79 | } |
|
80 | $input->replace($token, $newTokens); |
|
81 | } |
|
82 | ||
83 | return $input ; |
|
84 | } |
|
85 | ||
86 | // Tokenize a simple string. |
|
87 | $array = $this->_tokenize($input); |
|
88 | $registry = new TokenRegistry(); |
|
89 | foreach ($array as $item) { |
|
90 | $registry->add($item); |
|
91 | } |
|
92 | ||
93 | return $registry; |
|
94 | } |
|
95 | ||
96 | /** |
|
97 | * Split the given string into tokens using whitespace. |