Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1431972
State.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
State.php
View Options
<?php
namespace
Wikimedia\LangConv\Construct
;
/**
* A state in a mutable FST.
*/
class
State
{
/** @var int */
public
$id
;
/** @var array<?Edge> */
public
$edges
=
[];
/** @var bool */
public
$isFinal
=
false
;
/**
* Create a new state.
* @param int $id The index of this state in the parent MutableFST.
*/
public
function
__construct
(
int
$id
)
{
$this
->
id
=
$id
;
}
/**
* Add an edge from this state to another.
* @param string $upper The token on the upper side of the edge
* @param string $lower The token on the lower side of the edge
* @param State $to The destination of the edge
*/
public
function
addEdge
(
string
$upper
,
string
$lower
,
State
$to
):
void
{
$this
->
edges
[]
=
new
Edge
(
$this
,
count
(
$this
->
edges
),
$upper
,
$lower
,
$to
);
}
/**
* Write the edges of this state to the given $handle as an AT&T format
* file.
* @param resource $handle
*/
public
function
writeATT
(
$handle
):
void
{
foreach
(
$this
->
edges
as
$e
)
{
$line
=
[
strval
(
$e
->
from
->
id
),
strval
(
$e
->
to
->
id
),
$e
->
upper
,
$e
->
lower
];
fwrite
(
$handle
,
implode
(
"
\t
"
,
$line
)
.
"
\n
"
);
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 21:17 (1 d, 12 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
fb/94/3196d76167517ce88c16ada6b43d
Default Alt Text
State.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment