Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F361
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, 12:17
2014-11-29 12:17:33 (UTC+0)
Size
1005 B
Referenced Files
None
Subscribers
None
extract-proper-nouns-from-text
View Options
#!/usr/bin/env php
<?php
require
'proper_nouns.php'
;
class
ExtractorCommand
{
public
static
function
getCommandName
()
{
global
$argv
;
return
basename
(
$argv
[
0
]);
}
public
static
function
usage
()
{
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
354
Default Alt Text
extract-proper-nouns-from-text (1005 B)
Attached To
Mode
P23 extract-proper-nouns-from-text
Attached
Detach File
Event Timeline
Log In to Comment