Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F359
extract-proper-nouns-from-text
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
dereckson
Nov 29 2014, 11:10
2014-11-29 11:10:05 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
extract-proper-nouns-from-text
View Options
#!/usr/bin/env php
<?php
require
'proper_nouns.php'
;
class
ExtractorCommand
{
/**
* An instance of the proper_nouns class
*
* @var proper_nouns
*/
private
$extractor
;
public
static
function
getCommandName
()
{
global
$argv
;
return
basename
(
$argv
[
0
]);
}
public
static
function
usage
()
{
global
$argv
;
echo
"Usage: "
.
self
::
getCommandName
()
.
" <text file>
\n
"
;
}
public
static
function
run
()
{
global
$argc
,
$argv
;
if
(
$argc
<
2
)
{
self
::
usage
();
exit
;
}
$file
=
$argv
[
1
];
if
(!
file_exists
(
$file
))
{
echo
self
::
getCommandName
()
.
": $file: No such file
\n
"
;
exit
;
}
self
::
printNounsFromFile
(
$file
);
}
public
static
function
printNounsFromFile
(
$file
)
{
$text
=
file_get_contents
(
$file
);
$nouns
=
self
::
getNouns
(
$text
);
foreach
(
$nouns
as
$noun
)
{
echo
"$noun
\n
"
;
}
}
public
static
function
getNouns
(
$text
)
{
return
(
new
proper_nouns
())->
get
(
$text
);
}
}
ExtractorCommand
::
run
();
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
352
Default Alt Text
extract-proper-nouns-from-text (1 KB)
Attached To
Mode
P23 extract-proper-nouns-from-text
Attached
Detach File
Event Timeline
Log In to Comment