Container
[
class tree: Container
] [
index: Container
] [
all elements
]
Packages:
Analyzer
Base
Cache
Config
Container
Creator
Log
Memory
Pattern
Registry
Stat
Word
Source for file Sentence.php
Documentation is available at
Sentence.php
<?php
/**
* Mai_Container_Sentence
*
* Copyright (C) 2009 Mai (Me Artificial Intelligence)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
@author
Wouter Bulten (wouterbulten@mai-ai.org)
*
@copyright
Copyright (C) 2009 Mai (Me Artificial Intelligence)
*
@license
http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
*
@link
http://www.launchpad.net/mai
*
*
@category
Mai
*
@package
Container
*
@subpackage
Sentence
*
*/
/** Load required file */
if
(
!
Mai
::
getAutoloader
(
))
{
require_once
'Mai/Container/Sentence/Interface.php'
;
}
/**
* Mai_Container_Sentence is a container for a sentence.
*
*
@author
Wouter Bulten (wouterbulten@mai-ai.org)
*
@copyright
Copyright (C) 2009 Mai (Me Artificial Intelligence)
*
@license
http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
*
@link
http://www.launchpad.net/mai
*
*
@category
Mai
*
@package
Container
*
@subpackage
Sentence
*
*/
class
Mai_Container_Sentence
implements
Mai_Container_Sentence_Interface
{
/**
*
@var
array
Storage for words.
*/
private
$_words
=
array
(
)
;
/**
*
@var
String
Sentence mark.
*/
private
$_sentenceMark
;
/**
* Insert a word in the storage.
*
@param
Mai_Container_Word
The word to store.
*
@param
$location
The location (key) where to store.
*/
public
function
insertWord
(
Mai_Container_Word
$word
,
$location
=
null
)
{
if
(
!
isset
(
$location
)
||
!
is_numeric
(
$location
))
{
$this
->
_words
[
]
=
$word
;
}
else
{
$this
->
_words
[
$location
]
=
$word
;
}
}
/**
* Return a word from storage.
*
@param
Int
$location
The location (key) of storage.
*
@param
Bool
$showError
Set to false to return false if a word does not excist.
*
@return
Mai_Container_Word
*/
public
function
getWord
(
$location
,
$showError
=
true
)
{
if
(
!
isset
(
$location
)
||
!
is_numeric
(
$location
))
{
trigger_error
(
'Location not set.'
,
E_USER_ERROR
)
;
}
if
(
isset
(
$this
->
_words
[
$location
]
)
&&
$showError
===
true
)
{
trigger_error
(
'Word does not excist for location.'
,
E_USER_NOTICE
)
;
}
else
{
return
false
;
}
return
$this
->
_words
[
$location
]
;
}
/**
* Return all words (by reference)
*
@return
array
*/
public
function
&
getAll
(
)
{
return
$this
->
_words
;
}
/**
* Set the sentence mark of this sentence.
*
@param
String
$sentenceMark
*/
public
function
setSentenceMark
(
$sentenceMark
)
{
if
(
!
isset
(
$location
)
||
!
is_numeric
(
$location
))
{
trigger_error
(
'Sentence mark not set.'
,
E_USER_ERROR
)
;
}
return
$this
->
_sentenceMark
;
}
/**
* Return the sentence mark of this sentence.
*
@return
String
*/
public
function
getSentenceMark
(
)
{
return
$this
->
_sentenceMark
;
}
}
Documentation generated on Mon, 27 Jul 2009 19:55:12 +0200 by
phpDocumentor 1.4.1