多言語工房ホーム > PHPライブラリ > APIリファレンス
多言語工房 PHPライブラリ リファレンス
多言語工房はPHPライブラリは,言語グリッドが提供する折り返し翻訳,発音再生,マルチホップ翻訳など,さまざまな言語に関する機能群を利用するためのAPI群です.多言語工房PHPライブラリは,言語グリッドのAPI(SOAP)をラップしてPHPから簡単に呼び出せるようにしたライブラリです.このライブラリは,PHP5.3以上で動作します.
本ライブラリの機能の一覧は,機能一覧ページをご覧下さい.本ライブラリの使い方は,チュートリアルページを参考にして下さい.
目次
-
サービスグリッドAPI
- AdjacencyPairClient
- BackTranslationClient
- BilingualDictionaryClient
- BilingualDictionaryWithLongestMatchSearchClient
- ConceptDictionaryClient
- DependencyParserClient
- DocumentTranslationClient
- LanguageIdentificationClient
- MorphologicalAnalysisClient
- MultihopTranslationClient
- ParallelTextClient
- PictogramDictionaryClient
- QualityEstimationClient
- SimilarityCalculationClient
- SpeechRecognitionClient
- TemplateParallelTextClient
- TextToSpeechClient
- TranslationClient
- TranslationSelectionClient
- TranslationWithTemporalDictionaryClient
- ローカルサービスAPI
- ローカル用例対訳
サービスグリッドAPI
サービス共通
認証情報の指定
認証情報の指定は2種類の方法でできます.- サービス共通のデフォルト認証情報の指定
- サービス固有の認証情報の指定
サービス共通のデフォルト認証情報の指定は以下のようなコードをアプリケーション全体の設定ファイルなどで一度だけ記入しサービス実行までに読み込んでおくことでサービス実行時に毎回ID及びパスワードの指定が不要になります. 通常はこちらの方法で利用します.
ClientFactory::setDefaultUserId('someUserId');
ClientFactory::setDefaultPassword('somePassword');
サービス固有の認証情報の指定はサービスクライアント作成時に個別にID及びパスワードを指定します. サービスグリッドのサーバーがサービス毎に異なるなどの場合に利用します.
$client = ClientFactory::createTranslationClient('サービスURL');
$client->setUserId('someUserId');
$client->setUserId('somePassword');
SOAP呼び出し失敗時の例外
認証エラーなどSOAP呼び出しに失敗するとLangridException(標準のException派生クラス)例外が発生します. クライアントを利用する場合は必ずtry ~ catch構文を使い例外を補足してください.
try {
$client = ClientFactory::createBilingualDictionaryClient('サービスURL');
$client->getSupportedLanguagePairs();
} catch(LangridException $e) {
// 何らかのエラー処理
}
AdjacencyPairClient
隣接応答対サービスのクライアントが実装するインターフェース.
search
パラメータ
(string) category- カテゴリ(string) language- 発話の言語(RFC3066準拠.prefixのみ一致した場合は,一致した言語が1つの場合のみ呼び出し可能(例:対応言語にzh-Hansがあったときに,languageにzhを指定した場合))(string) firstTurn- 発話(必須)(const MatchingMethod) matchingMethod- 検索方法("COMPLETE","PREFIX","SUFFIX","PARTIAL","REGEX"のいずれか)(必須)
category- カテゴリfirstTurn- 発話secondTurns- 発話に対する応答の配列
.array(2) {
[0]=>
object(stdClass)#207 (3) {
["category"]=>
string(7) "Payment"
["firstTurn"]=>
string(23) "test/examination charge"
["secondTurns"]=>
array(1) {
[0]=>
string(98) "charges for specimen tests, ie.blood, urine etc. and physical examinations ie. ECG, endoscopy etc."
}
}
[1]=>
object(stdClass)#205 (3) {
["category"]=>
string(7) "account"
["firstTurn"]=>
string(23) "test/examination charge"
["secondTurns"]=>
array(1) {
[0]=>
string(100) "charges for specimen tests ie.blood, urine etc. and physical examinations ie.EKG/ECG, endoscopy etc."
}
}
}
BackTranslationClient
折り返し翻訳サービスのクライアントが実装するインターフェース.
backTranslate
パラメータ
(Language) sourceLang- 翻訳元の言語(Language) intermediateLang- 中間言語(String) source- 翻訳する文字列
.object(stdClass)#207 (2) {
["intermediate"]=>
string(148) "Kyoto, 因 Mi to Luoyang became the capital of the Chinese dynasties, and often, was told Kyoraku, inside the capital, Luoyang and such a long time."
["target"]=>
string(164) "洛陽に京都,因Miは中国王朝の首都となり,多くの場合,首都,洛陽,そのような長い時間の中で,京楽を言われました."
}
BilingualDictionaryClient
対訳辞書サービスクライアントが実装するインターフェース.
search
パラメータ
(Language) headLang- 対訳の元言語(RFC3066準拠.prefixのみ一致した場合は,一致した言語が1つの場合のみ呼び出し可能(例:対訳言語対にzh-Hansがあったときに,headLangにzhを指定した場合))(Language) targetLang- 対訳の対象言語(RFC3066準拠.prefixのみ一致した場合は,一致した言語が1つの場合のみ呼び出し可能(例:対訳言語対にzh-Hansがあったときに,targetLangにzhを指定した場合))(String) headWord- 対訳を検索する語(MatchingMethod) matchingMethod- 検索方法
headWord- 元言語の対訳targetWords- 対象言語の対訳
array(4) {
[0]=>
object(stdClass)#198 (2) {
["headWord"]=> string(15) "生き生きと"
["targetWords"]=> array(1) {
[0]=> string(7) "freshly" }
}
[1]=> object(stdClass)#199 (2) {
["headWord"]=> string(18) "生き返らせる"
["targetWords"]=> array(1) {
[0]=> string(6) "revive" }
}
[2]=> object(stdClass)#200 (2) {
["headWord"]=> string(12) "生き返る"
["targetWords"]=> array(1) {
[0]=> string(6) "revive"
}
}
[3]=> object(stdClass)#201 (2) {
["headWord"]=> string(15) "生きている"
["targetWords"]=> array(2) {
[0]=> string(6) "living"
[1]=> string(5) "alive"
}
}
}
getSupportedLanguagePairs
パラメータ
- なし
(String)first- サービスが対応している翻訳元言語(String)second- サービスが対応している翻訳先言語
array(2) {
[0]=> object(stdClass)#6 (2) {
["first"]=> string(2) "ja"
["second"]=> string(2) "en"
}
[1]=> object(stdClass)#7 (2) {
["first"]=> string(2) "en"
["second"]=> string(2) "ja"
}
}
getSupportedMatchingMethods
パラメータ
- なし
first- サービスが対応している翻訳元言語
array(4) {
[0]=> string(6) "PREFIX"
[1]=> string(8) "COMPLETE"
[2]=> string(7) "PARTIAL"
[3]=> string(6) "SUFFIX"
}
getLastUpdate
パラメータ
- なし
-
最終更新日時
string(24) "2009-10-05T07:35:00.000Z"
BilingualDictionaryWithLongestMatchSearchClient
最適化版用の対訳辞書サービスクライアントが実装するインターフェース.
searchLongestMatchingTerms
パラメータ
(Language) headLang- 検索する見出し言語(Language) targetLang- 対訳言語(Morpheme) text- 形態素
- 結果の配列
array(1) {
[0]=>
object(stdClass)#230 (3) {
["numberOfMorphemes"]=>
int(1)
["startIndex"]=>
int(0)
["translation"]=>
object(stdClass)#231 (2) {
["headWord"]=>
string(5) "hello"
["targetWords"]=>
array(7) {
[0]=>
string(15) "こんにちは"
[1]=>
string(6) "もし"
[2]=>
string(12) "もしもし"
[3]=>
string(6) "あら"
[4]=>
string(6) "おや"
[5]=>
string(6) "やあ"
[6]=>
string(6) "おい"
}
}
}
}
ConceptDictionaryClient
概念辞書サービスのクライアントが実装するインターフェース.
getRelatedConcepts
パラメータ
(Language) language- 概念を表す言語(String) conceptId- 概念のID(ConceptualRelation) relation- 概念間の関係
.array(1) {
[0]=>
object(stdClass)#208 (5) {
["conceptId"]=>
string(38) "urn:langrid:edr:concept:unknown:30f8af"
["glosses"]=>
array(1) {
[0]=>
object(stdClass)#207 (2) {
["glossText"]=>
string(67) "action, act (action having to do with progress of action or matter)"
["language"]=>
string(2) "en"
}
}
["partOfSpeech"]=>
string(7) "unknown"
["relations"]=>
array(2) {
[0]=>
string(9) "HYPERNYMS"
[1]=>
string(8) "HYPONYMS"
}
["synset"]=>
array(1) {
[0]=>
object(stdClass)#209 (2) {
["language"]=>
string(2) "en"
["lemmaForm"]=>
string(0) ""
}
}
}
}
searchConcepts
パラメータ
(Language) language- 概念を表す言語(String) word- 概念見出し語(MatchingMethod) matchingMethod- 検索方法
array(4) { [0]=> object(stdClass)#201 (5) { ["conceptId"]=> string(40) "urn:langrid:edr:concept:adjective:0dcb8f" ["glosses"]=> array(1) { [0]=> object(stdClass)#202 (2) { ["glossText"]=> string(13) "of experiment" ["language"]=> string(2) "en" } } ["partOfSpeech"]=> string(9) "adjective" ["relations"]=> array(1) { [0]=> string(9) "HYPERNYMS" } ["synset"]=> array(1) { [0]=> object(stdClass)#203 (2) { ["language"]=> string(2) "en" ["lemmaForm"]=> string(7) "testing" } } } [1]=> object(stdClass)#204 (5) { ["conceptId"]=> string(40) "urn:langrid:edr:concept:adjective:0dcb90" ["glosses"]=> array(1) { [0]=> object(stdClass)#205 (2) { ["glossText"]=> string(24) "requiring maximum effort" ["language"]=> string(2) "en" } } ["partOfSpeech"]=> string(9) "adjective" ["relations"]=> array(1) { [0]=> string(9) "HYPERNYMS" } ["synset"]=> array(1) { [0]=> object(stdClass)#206 (2) { ["language"]=> string(2) "en" ["lemmaForm"]=> string(7) "testing" } } } [2]=> object(stdClass)#207 (5) { ["conceptId"]=> string(35) "urn:langrid:edr:concept:verb:3ce65d" ["glosses"]=> array(1) { [0]=> object(stdClass)#208 (2) { ["glossText"]=> string(28) "to make a trial of something" ["language"]=> string(2) "en" } } ["partOfSpeech"]=> string(4) "verb" ["relations"]=> array(2) { [0]=> string(9) "HYPERNYMS" [1]=> string(8) "HYPONYMS" } ["synset"]=> array(5) { [0]=> object(stdClass)#209 (2) { ["language"]=> string(2) "en" ["lemmaForm"]=> string(5) "prove" } [1]=> object(stdClass)#210 (2) { ["language"]=> string(2) "en" ["lemmaForm"]=> string(4) "test" } [2]=> object(stdClass)#211 (2) { ["language"]=> string(2) "en" ["lemmaForm"]=> string(6) "proven" } [3]=> object(stdClass)#212 (2) { ["language"]=> string(2) "en" ["lemmaForm"]=> string(10) "field-test" } [4]=> object(stdClass)#213 (2) { ["language"]=> string(2) "en" ["lemmaForm"]=> string(3) "try" } } } [3]=> object(stdClass)#214 (5) { ["conceptId"]=> string(42) "urn:langrid:edr:concept:noun.common:3ce65d" ["glosses"]=> array(1) { [0]=> object(stdClass)#215 (2) { ["glossText"]=> string(28) "to make a trial of something" ["language"]=> string(2) "en" } } ["partOfSpeech"]=> string(11) "noun.common" ["relations"]=> array(2) { [0]=> string(9) "HYPERNYMS" [1]=> string(8) "HYPONYMS" } ["synset"]=> array(8) { [0]=> object(stdClass)#216 (2) { ["language"]=> string(2) "en" ["lemmaForm"]=> string(11) "examination" } [1]=> object(stdClass)#217 (2) { ["language"]=> string(2) "en" ["lemmaForm"]=> string(4) "test" } [2]=> object(stdClass)#218 (2) { ["language"]=> string(2) "en" ["lemmaForm"]=> string(7) "testing" } [3]=> object(stdClass)#219 (2) { ["language"]=> string(2) "en" ["lemmaForm"]=> string(7) "approof" } [4]=> object(stdClass)#220 (2) { ["language"]=> string(2) "en" ["lemmaForm"]=> string(3) "ex." } [5]=> object(stdClass)#221 (2) { ["language"]=> string(2) "en" ["lemmaForm"]=> string(5) "trial" } [6]=> object(stdClass)#222 (2) { ["language"]=> string(2) "en" ["lemmaForm"]=> string(4) "exam" } [7]=> object(stdClass)#223 (2) { ["language"]=> string(2) "en" ["lemmaForm"]=> string(3) "try" } } } }
DependencyParserClient
係り受け解析サービスのクライアントが実装するインターフェース.
parseDependency
パラメータ
(Language) language- 入力文の言語(String) sentence- 入力文
array(6) { [0]=> object(stdClass)#198 (3) { ["chunkId"]=> string(1) "0" ["dependency"]=> object(stdClass)#199 (2) { ["headChunkId"]=> string(1) "4" ["label"]=> string(10) "DEPENDENCY" } ["morphemes"]=> array(2) { [0]=> object(stdClass)#200 (3) { ["lemma"]=> string(3) "主" ["partOfSpeech"]=> string(7) "unknown" ["word"]=> string(3) "主" } [1]=> object(stdClass)#201 (3) { ["lemma"]=> string(3) "に" ["partOfSpeech"]=> string(5) "other" ["word"]=> string(3) "に" } } } [1]=> object(stdClass)#202 (3) { ["chunkId"]=> string(1) "1" ["dependency"]=> object(stdClass)#203 (2) { ["headChunkId"]=> string(1) "4" ["label"]=> string(10) "DEPENDENCY" } ["morphemes"]=> array(2) { [0]=> object(stdClass)#204 (3) { ["lemma"]=> string(6) "薬味" ["partOfSpeech"]=> string(11) "noun.common" ["word"]=> string(6) "薬味" } [1]=> object(stdClass)#205 (3) { ["lemma"]=> string(9) "として" ["partOfSpeech"]=> string(5) "other" ["word"]=> string(9) "として" } } } [2]=> object(stdClass)#206 (3) { ["chunkId"]=> string(1) "2" ["dependency"]=> object(stdClass)#207 (2) { ["headChunkId"]=> string(1) "3" ["label"]=> string(10) "DEPENDENCY" } ["morphemes"]=> array(2) { [0]=> object(stdClass)#208 (3) { ["lemma"]=> string(6) "多く" ["partOfSpeech"]=> string(7) "unknown" ["word"]=> string(6) "多く" } [1]=> object(stdClass)#209 (3) { ["lemma"]=> string(3) "の" ["partOfSpeech"]=> string(5) "other" ["word"]=> string(3) "の" } } } [3]=> object(stdClass)#210 (3) { ["chunkId"]=> string(1) "3" ["dependency"]=> object(stdClass)#211 (2) { ["headChunkId"]=> string(1) "4" ["label"]=> string(10) "DEPENDENCY" } ["morphemes"]=> array(2) { [0]=> object(stdClass)#212 (3) { ["lemma"]=> string(6) "料理" ["partOfSpeech"]=> string(7) "unknown" ["word"]=> string(6) "料理" } [1]=> object(stdClass)#213 (3) { ["lemma"]=> string(3) "で" ["partOfSpeech"]=> string(5) "other" ["word"]=> string(3) "で" } } } [4]=> object(stdClass)#214 (3) { ["chunkId"]=> string(1) "4" ["dependency"]=> object(stdClass)#215 (2) { ["headChunkId"]=> string(1) "5" ["label"]=> string(10) "DEPENDENCY" } ["morphemes"]=> array(4) { [0]=> object(stdClass)#216 (3) { ["lemma"]=> string(6) "使う" ["partOfSpeech"]=> string(4) "verb" ["word"]=> string(6) "使わ" } [1]=> object(stdClass)#217 (3) { ["lemma"]=> string(6) "れる" ["partOfSpeech"]=> string(4) "verb" ["word"]=> string(3) "れ" } [2]=> object(stdClass)#218 (3) { ["lemma"]=> string(3) "て" ["partOfSpeech"]=> string(5) "other" ["word"]=> string(3) "て" } [3]=> object(stdClass)#219 (3) { ["lemma"]=> string(6) "いる" ["partOfSpeech"]=> string(4) "verb" ["word"]=> string(6) "いる" } } } [5]=> object(stdClass)#220 (3) { ["chunkId"]=> string(1) "5" ["dependency"]=> object(stdClass)#221 (2) { ["headChunkId"]=> string(2) "-1" ["label"]=> string(10) "DEPENDENCY" } ["morphemes"]=> array(3) { [0]=> object(stdClass)#222 (3) { ["lemma"]=> string(3) "“" ["partOfSpeech"]=> string(5) "other" ["word"]=> string(3) "“" } [1]=> object(stdClass)#223 (3) { ["lemma"]=> string(6) "ねぎ" ["partOfSpeech"]=> string(11) "noun.common" ["word"]=> string(6) "ねぎ" } [2]=> object(stdClass)#224 (3) { ["lemma"]=> string(3) "”" ["partOfSpeech"]=> string(5) "other" ["word"]=> string(3) "”" } } } }
DocumentTranslationClient
文書翻訳サービスのクライアントが実装するインターフェース.
start
パラメータ
(Language) headLang- 対訳の元言語(Language) targetLang- 対訳の対象言語(Document) doc- 翻訳対象の文書
-
これ以降の通信に使う40文字からなるトークン.
isFinished
パラメータ
(String) token- startメソッドで返されるトークン
-
翻訳が終了したか否か.
getProgress
パラメータ
(String) token- startメソッドで返されるトークン
-
翻訳の進捗状況.0.0が開始,1.0が終了.
getResult
パラメータ
(String) token- startメソッドで返されるトークン
-
翻訳結果の文書データのバイナリファイル.
LanguageIdentificationClient
形態素解析サービスのクライアントが実装するインターフェース.
identifyLanguageAndEncoding
パラメータ
(byte[]) textBytes- 識別する文字列
- 識別結果
identify
パラメータ
(String) text- 識別する文字列(String) originalEncoding- 文字列のエンコーディング
string(2) "ja"
getSupportedLanguages
パラメータ
array(53) {
[0]=>
string(2) "af"
[1]=>
string(2) "sq"
[2]=>
string(2) "ar"
[3]=>
string(2) "be"
[4]=>
string(2) "bg"
[5]=>
string(2) "ca"
・・・
[51]=>
string(2) "cy"
[52]=>
string(2) "yi"
}
getSupportedEncodings
パラメータ
- なし
- エンコーディングの配列
array(1) {
[0]=> string(5) "UTF-8"
}
MorphologicalAnalysisClient
形態素解析サービスのクライアントが実装するインターフェース.
analyze
パラメータ
(Language) language- テキストの言語(RFC3066準拠.prefixのみ一致した場合には,一致した言語が1つの場合のみ呼び出し可能(例:対応言語にzh-Hansがあったときに,languageにzhを指定した場合))(String) text- テキスト(必須)
- 形態素解析の結果
.array(23) {
[0]=>
object(stdClass)#208 (3) {
["lemma"]=>
string(6) "立春"
["partOfSpeech"]=>
string(11) "noun.common"
["word"]=>
string(6) "立春"
}
[1]=>
object(stdClass)#206 (3) {
["lemma"]=>
string(6) "から"
["partOfSpeech"]=>
string(5) "other"
["word"]=>
string(6) "から"
}
[2]=>
object(stdClass)#207 (3) {
["lemma"]=>
string(6) "春分"
["partOfSpeech"]=>
string(11) "noun.common"
["word"]=>
string(6) "春分"
}
[3]=>
object(stdClass)#211 (3) {
["lemma"]=>
string(3) "の"
["partOfSpeech"]=>
string(5) "other"
["word"]=>
string(3) "の"
}
・・・
[21]=>
object(stdClass)#229 (3) {
["lemma"]=>
string(6) "呼ぶ"
["partOfSpeech"]=>
string(4) "verb"
["word"]=>
string(6) "呼ぶ"
}
[22]=>
object(stdClass)#230 (3) {
["lemma"]=>
string(3) "."
["partOfSpeech"]=>
string(5) "other"
["word"]=>
string(3) "."
}
}
MultihopTranslationClient
複数ホップ翻訳サービスのクライアントが実装するインターフェース.
multihopTranslate
パラメータ
(Language) sourceLang- 翻訳元の言語(Language[]) intermediateLangs- 中間言語(Language) targetLang- 翻訳先の言語(String) source- 翻訳する文字列
intermediates- 中間結果target- 翻訳結果
li
.object(stdClass)#207 (2) {
["intermediates"]=>
array(1) {
[0]=>
string(15) "こんにちは"
}
["target"]=>
string(15) "안녕하세요"
}
ParallelTextClient
用例対訳サービスのクライアントが実装するインターフェース.
search
パラメータ
(Language) sourceLang- 用例対訳の元言語(Language) targetLang- 用例対訳の先言語(String) source- 検索する文字列(MatchingMethod) matchingMethod- 検索方法
array(2) {
[0]=> object(stdClass)#198 (2) {
["source"]=> string(51) "Body Measurements and Periodic Health Examinations "
["target"]=> string(33) "身体測定・定期健康診断"
}
[1]=> object(stdClass)#199 (2) {
["source"]=> string(282) "Children’s health and safety is considered the first priority. If a child becomes ill or is injured, they will receive first aid treatment in the health room, and hospitals and families will be contacted as necessary. By law, a periodic health examination will also be undertaken."
["target"]=> string(309) "子どもの健康と安全を第一に考えています.子どもが病気になったり,けがをしたときには,保健室で応急手当をし,必要によっては病院や家庭に連絡をします.また,法律の定めるところにより,定期的に健康診断を行います."
}
}
PictogramDictionaryClient
絵文字辞書のクライアント.
search
パラメータ
(Language) language- wordの言語(String) word- 絵文字を検索する単語(MatchingMethod) matchingMethod- 検索方法
- 絵文字の検索結果.見つからない場合空配列
array(1) {
[0]=> object(stdClass)#198 (3) {
["image"]=> string(1924) "/* バイナリデータ */"
["imageType"]=> string(3) "SWF"
["word"]=> string(6) "tomato"
}
}
QualityEstimationClient
品質評価サービスのクライアントが実装するインターフェイス
estimate
パラメータ
(Language) sourceLang- 翻訳元の言語(Language) targetLang- 翻訳先の言語(String) source- 翻訳元の文字列(String) target- 翻訳後の文字列
- 評価結果
SimilarityCalculationClient
類似度計算サービスのクライアントが実装するインターフェース.
calculate
パラメータ
(Language) language- テキストの言語(RFC3066準拠.prefixのみ一致した場合は,一致した言語が1つの場合のみ呼び出し可能(例:対応言語にzh-Hansがあったときに,languageにzhを指定した場合))(String) text1- 比較元テキスト(必須)(String) text2- 比較先テキスト(必須)
- 計算結果
float(0)
SpeechRecognitionClient
音声認識サービスのクライアントが実装するインターフェース.
recognize
パラメータ
(String) language- 言語(Speech) speech- 音声データ
langrid exception
getSupportedLanguages
パラメータ
- なし
- 対応言語
.array(1) {
[0]=>
string(2) "ja"
}
getSupportedVoiceTypes
パラメータ
- なし
- 対応している音声の種類
NULL
getSupportedAudioTypes
パラメータ
- なし
- 対応している音声データのファイル形式
.array(2) {
[0]=>
string(11) "audio/x-mp3"
[1]=>
string(9) "audio/wav"
}
TemplateParallelTextClient
テンプレート用例対訳サービスのクライアントが実装するインターフェース.
listTemplateCategories
パラメータ
(Language) language- 取得する言語
- カテゴリ一覧
array(1) {
[0]=> object(stdClass)#198 (2) {
["categoryId"]=> string(1) "1"
["categoryName"]=> string(7) "default"
}
}
getCategoryNames
パラメータ
(String) categoryId- カテゴリID(Language[]) languages- 取得する言語
- カテゴリ名
array(3) {
[0]=> string(7) "default"
[1]=> string(7) "default"
[2]=> string(7) "default"
}
searchTemplates
パラメータ
(Language) language- 言語(String) text- 検索する文字列(MatchingMethod) matchingMethod- マッチング方法(String[]) categoryIds- カテゴリID
- カテゴリ名
array(7) { [0]=> object(stdClass)#199 (5) { ["categories"]=> array(1) { [0]=> object(stdClass)#200 (2) { ["categoryId"]=> string(1) "1" ["categoryName"]=> string(7) "default" } } ["choiceParameters"]=> array(0) { } ["template"]=> string(138) "Selection is based on the results of the “interview”, “other tests” and “Chousa Sho (Records of study)” by junior high school." ["templateId"]=> string(3) "202" ["valueParameters"]=> array(0) { } } [1]=> object(stdClass)#201 (5) { ["categories"]=> array(1) { [0]=> object(stdClass)#202 (2) { ["categoryId"]=> string(1) "1" ["categoryName"]=> string(7) "default" } } ["choiceParameters"]=> array(0) { } ["template"]=> string(161) "① “Written tests”.(English, Japanese, and mathematics) -Written tests will be conducted in Japanese but will have rubi(hiragana beside Chinese characters)." ["templateId"]=> string(3) "204" ["valueParameters"]=> array(0) { } } [2]=> object(stdClass)#203 (5) { ["categories"]=> array(1) { [0]=> object(stdClass)#204 (2) { ["categoryId"]=> string(1) "1" ["categoryName"]=> string(7) "default" } } ["choiceParameters"]=> array(0) { } ["template"]=> string(33) "There are no “written tests”." ["templateId"]=> string(3) "200" ["valueParameters"]=> array(0) { } } [3]=> object(stdClass)#205 (5) { ["categories"]=> array(1) { [0]=> object(stdClass)#206 (2) { ["categoryId"]=> string(1) "1" ["categoryName"]=> string(7) "default" } } ["choiceParameters"]=> array(0) { } ["template"]=> string(53) "Written tests and other tests of Kouki Examination II" ["templateId"]=> string(3) "137" ["valueParameters"]=> array(0) { } } [4]=> object(stdClass)#207 (5) { ["categories"]=> array(1) { [0]=> object(stdClass)#208 (2) { ["categoryId"]=> string(1) "1" ["categoryName"]=> string(7) "default" } } ["choiceParameters"]=> array(0) { } ["template"]=> string(48) "Interviews and other tests of Zenki Examination " ["templateId"]=> string(3) "120" ["valueParameters"]=> array(0) { } } [5]=> object(stdClass)#209 (5) { ["categories"]=> array(1) { [0]=> object(stdClass)#210 (2) { ["categoryId"]=> string(1) "1" ["categoryName"]=> string(7) "default" } } ["choiceParameters"]=> array(0) { } ["template"]=> string(47) "There are schools that may test on Feb.19(Fri)." ["templateId"]=> string(3) "129" ["valueParameters"]=> array(0) { } } [6]=> object(stdClass)#211 (5) { ["categories"]=> array(1) { [0]=> object(stdClass)#212 (2) { ["categoryId"]=> string(1) "1" ["categoryName"]=> string(7) "default" } } ["choiceParameters"]=> array(0) { } ["template"]=> string(52) "Written tests and other tests of Kouki Examination I" ["templateId"]=> string(3) "130" ["valueParameters"]=> array(0) { } } }
getTemplatesByTemplateId
パラメータ
(Language) language- 言語(String[]) categoryIds- カテゴリID
- テンプレートの配列
array(5) {
[0]=>
object(stdClass)#238 (5) {
["categories"]=>
array(1) {
[0]=>
object(stdClass)#235 (2) {
["categoryId"]=>
string(1) "1"
["categoryName"]=>
string(7) "default"
}
}
["choiceParameters"]=>
array(0) {
}
["template"]=>
string(65) "Kanagawa Prefecture “Public High School Enrollment Guidebook”"
["templateId"]=>
string(1) "3"
["valueParameters"]=>
array(0) {
}
}
・・・
[4]=>
object(stdClass)#230 (5) {
["categories"]=>
array(1) {
[0]=>
object(stdClass)#227 (2) {
["categoryId"]=>
string(1) "1"
["categoryName"]=>
string(7) "default"
}
}
["choiceParameters"]=>
array(0) {
}
["template"]=>
string(26) "Japanese + English Version"
["templateId"]=>
string(1) "4"
["valueParameters"]=>
array(0) {
}
}
}
generateSentence
パラメータ
(Language) language- 言語(String) templateId- テンプレートID(BoundChoiceParameter[]) boundChoiceParameters- 選択パラメータ指定(BoundValueParameter[]) boundValueParameters- 値パラメータ指定
- 文章
string(23) "For 2010 Enrollment Use"
TextToSpeechClient
音声合成サービスのクライアントが実装するインターフェース.
speak
パラメータ
(Language) language- テキストの言語(RFC3066準拠)(String) text- 比較元テキスト(必須)(String) voiceType- 声のタイプ."man"や"woman"等.省略時空文字列又は"*"(String) audioType- 出力データの形式(MIMEタイプ)."audio/mpeg","audio/x-wav"等.省略時空文字列又は"audio/*"
object(stdClass)#209 (3) {
["audio"]=>
string(24936) "/* バイナリデータ */"
}
getSupportedLanguages
パラメータ
- なし
- 言語一覧
array(4) {
[0]=>
string(2) "ja"
[1]=>
string(2) "en"
[2]=>
string(2) "zh"
[3]=>
string(5) "zh-CN"
}
getSupportedVoiceTypes
パラメータ
- なし
- タイプ一覧
array(2) {
[0]=>
string(5) "woman"
[1]=>
string(3) "man"
}
getSupportedAudioTypes
パラメータ
- なし
- タイプ一覧
array(3) {
[0]=>
string(11) "audio/x-wav"
[1]=>
string(9) "audio/ogg"
[2]=>
string(14) "video/x-ms-asf"
}
TranslationClient
翻訳サービスのクライアントが実装するインターフェース.
translate
パラメータ
(Language) sourceLang- 翻訳元の言語(Language) targetLang- 翻訳先の言語(String) source- 翻訳する文字列
- 翻訳結果
string(15) "This is a test."
TranslationSelectionClient
最良選択翻訳サービスのクライアントが実装するインターフェイス
select
パラメータ
(Language) sourceLang- 翻訳元の言語(Language) targetLang- 翻訳先の言語(String) source- 翻訳する文字列
- 翻訳結果
string(16) "It is fine today"
TranslationWithTemporalDictionaryClient
一時辞書あり翻訳サービスのクライアントが実装するインターフェース.
translate
パラメータ
(Language) sourceLang- 翻訳元の言語(Language) targetLang- 翻訳先の言語(String) source- 翻訳する文字列(Translation[]) source- 一時辞書データ(Language) source- 辞書の対象言語.見出しの言語はsourceLangが使われる
- 翻訳結果
string(76) "Hiei in Kyoto Higashiyama, including is also known as the HIGASHIYAMA36HOU ."
ローカルサービスAPI
ローカルサービス利用設定
データベース接続設定
事前にデータベースへの接続設定を設定する必要があります.アプリケーション全体の設定ファイルなどで 一度だけ記入しそれを読み込む事で行います.設定は以下のように行います.
ActiveRecord\Config::initialize(function($cfg){
// "${ライブラリルート}/models" を指定
$cfg->set_model_directory(dirname(__FILE__).'/models');
// データベースへの接続URLを記述
$cfg->set_connections(array(
'development' => 'mysql://${ユーザー名}:${パスワード}@${ホスト名}/${データベース名}'
));
});
テスト環境と本番環境で接続先を切り替えて利用したい等の場合は,複数接続先を定義して
アプリケーション側から切り替えて使うことも可能です.
詳しくは以下のリンクの「Default connection」セクションをご覧下さい.PHP ActiveRecord - Configuration Setup - An easy to use ORM for PHP
※設定ファイルのサンプルは ${ライブラリルート}/config/service_settings.php にあります.
こちらに必要情報を記入し,読み込んで使うこともできます.
データベーステーブルの作成
ローカルサービスに必要なDBテーブルを作成します.
${ライブラリルート}/config/mysql.sql にテーブル作成のためのDDLがありますので,こちらをDBクライアントを利用して実行してください.
DDLはデータベースサーバにMySQLを利用した場合の記述です.他のサーバを利用される場合は適宜修正の上,利用してください.
データベースサーバにはMySQL,PostgresSQL,Oracle,SQLiteが利用可能です.
ローカル辞書
アプリケーション固有の多言語辞書を保持し,サービスグリッド利用時にテンポラル辞書として使用するなどの目的で利用します.
データモデル
[Dictionary]
- id: 辞書固有のID
- name: 辞書名
- licenser: 辞書のライセンス
- created_at: 辞書の作成日
- updated_at: 辞書の更新日
- created_by: 辞書の作成者
- dictionary_records: 辞書のデータ(値の取得は後述のAPIで行う)
- dictionary_languages: 辞書に含まれる言語(値の取得は後述のAPIで行う)
- dictionary_development: 辞書の配備状況(値の取得は後述のAPIで行う)
- id: 辞書レコード固有のID
- dictionary_contents: 辞書のコンテンツ(値の取得は後述のAPIで行う)
利用方法
辞書の新規作成
// プロパティを引数に辞書の作成
$dictionary = Dictionary::create(array(
'name' => '多言語工房共通辞書',
'licenser' => 'Kyoto University')
);
echo $dictionary->id; // idを表示
echo $dictionary->name; // 名前を表示
辞書の更新
以下のどちらの方法でも更新可能です.
// 辞書IDを条件に辞書オブジェクトを取得
$dictionary = Dictionary::find(1);
$dictionary->update_attribute('name', '新しい辞書名');
------------------------
// 辞書IDを条件に辞書オブジェクトを取得
$dictionary = Dictionary::find(1);
$dictionary->name = '新しい辞書名';
$dictionary->save();
辞書の削除
// 辞書IDを条件に辞書オブジェクトを取得
$dictionary = Dictionary::find(2);
// 論理削除の場合
$dictionary->remove();
------------------------
// 物理削除の場合
$dictionary->remove(true);
辞書への言語追加・削除
// 辞書IDを条件に辞書オブジェクトを取得
$dictionary = Dictionary::find(3);
// 辞書へvi(ベトナム語)を追加
$dictionary->add_language(Language::get('vi'));
辞書へのコンテンツ追加
// 辞書IDを条件に辞書オブジェクトを取得
$dictionary = Dictionary::find(3);
// 辞書へのレコード追加
$dictionary->add_record({'ja' => '京都', 'en' => 'Kyoto', 'zh' => '京都'});
辞書コンテンツの更新
// 辞書レコードIDを条件に辞書オブジェクトを取得
$record = DictionaryRecord::find(10);
// 辞書レコードのコンテンツを更新(指定の言語のみ更新.含まれていないものは維持する)
$record->update_contents(array(
'ja' => '健康',
'en' => 'health'
), '0000001');
辞書コンテンツの削除
// 辞書レコードIDを条件に辞書オブジェクトを取得
$record = DictionaryRecord::find(10);
$record->delete();
辞書サービスのWSDLの提供
$endpointUrl = 'http://deploy/url/billingualdictionary.php';
$targetNamespace = 'http://deploy/url/billingualdictionary/';
$dictionaryId = 'dictionaryId';
$wsdlGenerator = new BillingualDictionaryWSDL($endpointUrl, $dictionaryId, $targetNamespace);
$wsdlGenerator->getWSDL();
辞書サービスの起動
$soapServer = new BillingualDictionarySOAPServer($dictionaryId);
$soapServer->service(file_get_contents("php://input"));
API一覧
Dictionary| メソッド名 | 引数 | 返り値 | 説明 |
|---|---|---|---|
| remove | ・(Boolean)force [= false]: 論理削除 or 物理削除 | void | |
| add_language | ・(Language)language: 追加する言語 | (DictionaryLanguage) 追加したDictionaryLanguageレコード | 辞書に言語を追加する |
| get_languages | (array) 言語コードのリスト | 辞書に含まれる言語を取得する | |
| remove_language |
・(Language)$language: 削除する言語 ・(Boolean)$force [=false]: コンテンツを削除するかどうか |
辞書から指定言語を削除する | |
| update_languages |
・(array)languages: 更新する言語リスト ・(Boolean)force_on_delete [=false]: 削除の際,コンテンツも削除するか |
辞書に含まれる言語を指定のリストに更新する.(引数に含まれないものは削除.) | |
| is_deploy | (Boolean) 配備状況 | 辞書のサービス配備状況を返す | |
| deploy | 辞書をサービスとして配備する | ||
| undeploy | 辞書をサービスから配備解除する | ||
| add_record |
・(array)params: 追加するコンテンツ ・(String)create_user [=null]: コンテンツを追加するユーザーのID |
辞書にコンテンツを追加する.パラメータは{言語=>コンテンツ}のハッシュ形式で指定する | |
| records_count | (Integer) 件数 | 辞書に含まれるコンテンツの総件数をカウントする | |
| get_records | ・(array)options: 検索条件 | (DictionaryRecord) 結果レコード | 辞書に含まれる検索条件に一致するレコードを返す. 検索条件は後述. |
| count_records_each_language | (array) 言語別の登録数 | 言語別の登録数を取得する | |
| count_records_by_language | ・(Language)language: 取得したい言語 | (Integer) 登録数 | 対象言語の登録数を取得する |
| can_view | ・(String)user_id [=null]: ユーザーのID | (Boolean)結果 | 指定のユーザー(省略時は全てのユーザー)が辞書を閲覧可能であるか取得する |
| can_edit | ・(String)user_id [=null]: ユーザーのID | (Boolean)結果 | 指定のユーザー(省略時は全てのユーザー)が辞書を編集可能であるか取得する |
| is_owner | ・(String)user_id [=null]: ユーザーのID | (Boolean)結果 | 指定のユーザーが辞書のオーナーであるか取得する |
| to_json | (String) JSONテキスト | 辞書をJson形式に変換する.(コンテンツは含まれない) | |
| to_xml | (String) XMLテキスト | 辞書をXML形式に変換する.(コンテンツは含まれない) |
| メソッド名 | 引数 | 返り値 | 説明 |
|---|---|---|---|
| create_with_records |
・(array)params: 辞書のプロパティ,レコード ・(String)create_user: 作成するユーザーのID |
(Dictionary) 作成した辞書 |
辞書とレコードを一気に作成する.インポート等で利用. paramsの詳細 [必須] name, languages, records [オプション] licenser recordsはlanguagesと同じ個数の配列形式で. (例)
Dictionary::create_with_records(array(
|
| first | ・(array)$options [= array()]: 検索条件 | (Dictionary) 辞書 | 検索条件に一致する辞書の最初の1件を取得する. 検索条件は後述 |
| last | ・(array)$options [= array()]: 検索条件 | (Dictionary) 辞書 | 検索条件に一致する辞書の最後の1件を取得する. 検索条件は後述 |
| all | ・(array)$options [= array()]: 検索条件 | (Dictionary[]) 辞書リスト | 検索条件に一致する辞書を全件取得する. 検索条件は後述 |
| count | ・(array)$options [= array()]: 検索条件 | (Dictionary) 辞書 | 検索条件に一致する辞書の件数を取得する. 検索条件は後述 |
| first_with_deleted | ・(array)$options [= array()]: 検索条件 | (Dictionary) 辞書 | 検索条件に一致する辞書の最初の1件を取得する. (論理削除済みのものを含む) 検索条件は後述 |
| last_with_deleted | ・(array)$options [= array()]: 検索条件 | (Dictionary) 辞書 | 検索条件に一致する辞書の最後の1件を取得する. (論理削除済みのものを含む) 検索条件は後述 |
| all_with_deleted | ・(array)$options [= array()]: 検索条件 | (Dictionary) 辞書 | 検索条件に一致する辞書を全件取得する. (論理削除済みのものを含む) 検索条件は後述 |
| count_with_deleted | ・(array)$options [= array()]: 検索条件 | (Dictionary) 辞書 | 検索条件に一致する辞書の件数を取得する. (論理削除済みのものを含む) 検索条件は後述 |
DictionaryRecord
| メソッド名 | 引数 | 返り値 | 説明 |
|---|---|---|---|
| remove | 辞書レコードを削除する | ||
| get_contents | ・(Boolean) withAllProperty [= false]: コンテンツのデータ形式 | (array) コンテンツのハッシュ形式配列 |
レコードに含まれるコンテンツを取得する. withAllPropertyがfalseの場合(デフォルト),{$languageCode => $content} という形式で返す. [例] array('ja' => 'こんにちは', 'en' => 'Hello')withAllPropertyがtrueの場合,{'language code' => {$propertyName => $propertyValue} } という形式で返す. [例] array(
'ja' => array('text' => 'こんにちは', 'created_at' => '2012-03-10 16:44:46'),
'en' => array('text' => 'Hello', 'created_by' => '0000001'
)
|
| get_contents_as_ordered_array | ・(array) languageOrder: 言語の配列 | (array) コンテンツの配列 | 指定された言語に対するコンテンツを指定の順序で取得する. 指定言語のデータが存在しない場合,空文字列として返す. array('ja', 'en', 'ko')を引数とした場合,戻り値はarray('jaのコンテンツ', 'enのコンテンツ', 'koのコンテンツ')が戻る. カンマ区切りデータにしたい等の際に利用する. |
| update_contents |
・(array) params: 更新データ ・(String) update_user [= '']: 更新ユーザー |
(DictionaryRecord) 更新したレコード |
辞書レコードを更新する.
paramsは {$languageCode => $contentText} の形式で指定する [例] $reocrd->update_contents(array('ja' => '大阪', 'en' => 'Osaka'));
|
| メソッド名 | 引数 | 返り値 | 説明 |
|---|---|---|---|
| first | ・(array) options [= array()]: 検索条件 | (DictionaryRecord) 辞書レコード | 検索条件に一致する辞書レコードの最初の1件を取得する. 検索条件は後述 |
| last | ・(array) options [= array()]: 検索条件 | (DictionaryRecord) 辞書レコード | 検索条件に一致する辞書レコードの最後の1件を取得する. 検索条件は後述 |
| all | ・(array) options [= array()]: 検索条件 | (DictionaryRecord[]) 辞書レコードリスト | 検索条件に一致する辞書レコードを全件取得する. 検索条件は後述 |
| count | ・(array) options [= array()]: 検索条件 | (DictionaryRecord) 辞書レコード | 検索条件に一致する辞書レコードの件数を取得する. 検索条件は後述 |
| count_by_resource_id_and_language | ・(Integer) resource_id: カウント対象の辞書のID ・(Language) languageCode: カウント対象の言語コード | (Integer) 件数 | 指定の辞書に含まれる指定言語の登録件数を取得する. |
| count_by_resource_id_each_languages | ・(Integer) resource_id: カウント対象の辞書のID | (array) 言語別の登録数 | 指定の辞書に含まれる言語別の登録件数を取得する. |
| create_record |
・(Integer) resource_id: レコードを追加する対象辞書のID ・(array) params [= array()]: 追加データ ・(String) create_user [= '']: 追加するユーザーのID |
(DictionaryRecord) 追加したレコード | 指定の辞書に新規レコードを追加する |
ローカル用例対訳
アプリケーション固有の多言語用例対訳を保持し,サービスグリッド利用時にテンポラル用例対訳として使用するなどの目的で利用します.
データモデル
[ParallelText]
- id: 用例対訳固有のID
- name: 用例対訳名
- licenser: 用例対訳のライセンス
- created_at: 用例対訳の作成日
- updated_at: 用例対訳の更新日
- created_by: 用例対訳の作成者
- ParallelText_records: 用例対訳のデータ(値の取得は後述のAPIで行う)
- ParallelText_languages: 用例対訳に含まれる言語(値の取得は後述のAPIで行う)
- ParallelText_development: 用例対訳の配備状況(値の取得は後述のAPIで行う)
- id: 用例対訳レコード固有のID
- ParallelText_contents: 用例対訳のコンテンツ(値の取得は後述のAPIで行う)
利用方法
用例対訳の新規作成
// プロパティを引数に用例対訳の作成
$ParallelText = ParallelText::create(array(
'name' => '多言語工房共通用例対訳',
'licenser' => 'Kyoto University')
);
echo $ParallelText->id; // idを表示
echo $ParallelText->name; // 名前を表示
用例対訳の更新
以下のどちらの方法でも更新可能です.
// 用例対訳IDを条件に用例対訳オブジェクトを取得
$ParallelText = ParallelText::find(1);
$ParallelText->update_attribute('name', '新しい用例対訳名');
------------------------
// 用例対訳IDを条件に用例対訳オブジェクトを取得
$ParallelText = ParallelText::find(1);
$ParallelText->name = '新しい用例対訳名';
$ParallelText->save();
用例対訳の削除
// 用例対訳IDを条件に用例対訳オブジェクトを取得
$ParallelText = ParallelText::find(2);
// 論理削除の場合
$ParallelText->remove();
------------------------
// 物理削除の場合
$ParallelText->remove(true);
用例対訳への言語追加・削除
// 用例対訳IDを条件に用例対訳オブジェクトを取得
$ParallelText = ParallelText::find(3);
// 用例対訳へvi(ベトナム語)を追加
$ParallelText->add_language(Language::get('vi'));
用例対訳へのコンテンツ追加
// 用例対訳IDを条件に用例対訳オブジェクトを取得
$ParallelText = ParallelText::find(3);
// 用例対訳へのレコード追加
$ParallelText->add_record({'ja' => '京都', 'en' => 'Kyoto', 'zh' => '京都'});
用例対訳コンテンツの更新
// 用例対訳レコードIDを条件に用例対訳オブジェクトを取得
$record = ParallelTextRecord::find(10);
// 用例対訳レコードのコンテンツを更新(指定の言語のみ更新.含まれていないものは維持する)
$record->update_contents(array(
'ja' => '健康',
'en' => 'health'
), '0000001');
用例対訳コンテンツの削除
// 用例対訳レコードIDを条件に用例対訳オブジェクトを取得
$record = ParallelTextRecord::find(10);
$record->delete();
用例対訳サービスのWSDLの提供
$endpointUrl = 'http://deploy/url/paralleltext.php';
$targetNamespace = 'http://deploy/url/paralleltextdictionary/';
$dictionaryId = 'dictionaryId';
$wsdlGenerator = new BillingualParallelTextWSDL($endpointUrl, $dictionaryId, $targetNamespace);
$wsdlGenerator->getWSDL();
用例対訳サービスの起動
$soapServer = new ParallelTextSOAPServer($dictionaryId);
$soapServer->service(file_get_contents("php://input"));
API一覧
ParallelText| メソッド名 | 引数 | 返り値 | 説明 |
|---|---|---|---|
| remove | ・(Boolean)force [= false]: 論理削除 or 物理削除 | void | |
| add_language | ・(Language)language: 追加する言語 | (ParallelTextLanguage) 追加したParallelTextLanguageレコード | 用例対訳に言語を追加する |
| get_languages | (array) 言語コードのリスト | 用例対訳に含まれる言語を取得する | |
| remove_language |
・(Language)$language: 削除する言語 ・(Boolean)$force [=false]: コンテンツを削除するかどうか |
用例対訳から指定言語を削除する | |
| update_languages |
・(array)languages: 更新する言語リスト ・(Boolean)force_on_delete [=false]: 削除の際,コンテンツも削除するか |
用例対訳に含まれる言語を指定のリストに更新する.(引数に含まれないものは削除.) | |
| is_deploy | (Boolean) 配備状況 | 用例対訳のサービス配備状況を返す | |
| deploy | 用例対訳をサービスとして配備する | ||
| undeploy | 用例対訳をサービスから配備解除する | ||
| add_record |
・(array)params: 追加するコンテンツ ・(String)create_user [=null]: コンテンツを追加するユーザーのID |
用例対訳にコンテンツを追加する.パラメータは{言語=>コンテンツ}のハッシュ形式で指定する | |
| records_count | (Integer) 件数 | 用例対訳に含まれるコンテンツの総件数をカウントする | |
| get_records | ・(array)options: 検索条件 | (ParallelTextRecord) 結果レコード | 用例対訳に含まれる検索条件に一致するレコードを返す. 検索条件は後述. |
| count_records_each_language | (array) 言語別の登録数 | 言語別の登録数を取得する | |
| count_records_by_language | ・(Language)language: 取得したい言語 | (Integer) 登録数 | 対象言語の登録数を取得する |
| can_view | ・(String)user_id [=null]: ユーザーのID | (Boolean)結果 | 指定のユーザー(省略時は全てのユーザー)が用例対訳を閲覧可能であるか取得する |
| can_edit | ・(String)user_id [=null]: ユーザーのID | (Boolean)結果 | 指定のユーザー(省略時は全てのユーザー)が用例対訳を編集可能であるか取得する |
| is_owner | ・(String)user_id [=null]: ユーザーのID | (Boolean)結果 | 指定のユーザーが用例対訳のオーナーであるか取得する |
| to_json | (String) JSONテキスト | 用例対訳をJson形式に変換する.(コンテンツは含まれない) | |
| to_xml | (String) XMLテキスト | 用例対訳をXML形式に変換する.(コンテンツは含まれない) |
| メソッド名 | 引数 | 返り値 | 説明 |
|---|---|---|---|
| create_with_records |
・(array)params: 用例対訳のプロパティ,レコード ・(String)create_user: 作成するユーザーのID |
(ParallelText) 作成した用例対訳 |
用例対訳とレコードを一気に作成する.インポート等で利用. paramsの詳細 [必須] name, languages, records [オプション] licenser recordsはlanguagesと同じ個数の配列形式で. (例)
ParallelText::create_with_records(array(
|
| first | ・(array)$options [= array()]: 検索条件 | (ParallelText) 用例対訳 | 検索条件に一致する用例対訳の最初の1件を取得する. 検索条件は後述 |
| last | ・(array)$options [= array()]: 検索条件 | (ParallelText) 用例対訳 | 検索条件に一致する用例対訳の最後の1件を取得する. 検索条件は後述 |
| all | ・(array)$options [= array()]: 検索条件 | (ParallelText[]) 用例対訳リスト | 検索条件に一致する用例対訳を全件取得する. 検索条件は後述 |
| count | ・(array)$options [= array()]: 検索条件 | (ParallelText) 用例対訳 | 検索条件に一致する用例対訳の件数を取得する. 検索条件は後述 |
| first_with_deleted | ・(array)$options [= array()]: 検索条件 | (ParallelText) 用例対訳 | 検索条件に一致する用例対訳の最初の1件を取得する. (論理削除済みのものを含む) 検索条件は後述 |
| last_with_deleted | ・(array)$options [= array()]: 検索条件 | (ParallelText) 用例対訳 | 検索条件に一致する用例対訳の最後の1件を取得する. (論理削除済みのものを含む) 検索条件は後述 |
| all_with_deleted | ・(array)$options [= array()]: 検索条件 | (ParallelText) 用例対訳 | 検索条件に一致する用例対訳を全件取得する. (論理削除済みのものを含む) 検索条件は後述 |
| count_with_deleted | ・(array)$options [= array()]: 検索条件 | (ParallelText) 用例対訳 | 検索条件に一致する用例対訳の件数を取得する. (論理削除済みのものを含む) 検索条件は後述 |
ParallelTextRecord
| メソッド名 | 引数 | 返り値 | 説明 |
|---|---|---|---|
| remove | 用例対訳レコードを削除する | ||
| get_contents | ・(Boolean) withAllProperty [= false]: コンテンツのデータ形式 | (array) コンテンツのハッシュ形式配列 |
レコードに含まれるコンテンツを取得する. withAllPropertyがfalseの場合(デフォルト),{$languageCode => $content} という形式で返す. [例] array('ja' => 'こんにちは', 'en' => 'Hello')withAllPropertyがtrueの場合,{'language code' => {$propertyName => $propertyValue} } という形式で返す. [例] array(
'ja' => array('text' => 'こんにちは', 'created_at' => '2012-03-10 16:44:46'),
'en' => array('text' => 'Hello', 'created_by' => '0000001'
)
|
| get_contents_as_ordered_array | ・(array) languageOrder: 言語の配列 | (array) コンテンツの配列 | 指定された言語に対するコンテンツを指定の順序で取得する. 指定言語のデータが存在しない場合,空文字列として返す. array('ja', 'en', 'ko')を引数とした場合,戻り値はarray('jaのコンテンツ', 'enのコンテンツ', 'koのコンテンツ')が戻る. カンマ区切りデータにしたい等の際に利用する. |
| update_contents |
・(array) params: 更新データ ・(String) update_user [= '']: 更新ユーザー |
(ParallelTextRecord) 更新したレコード |
用例対訳レコードを更新する.
paramsは {$languageCode => $contentText} の形式で指定する [例] $reocrd->update_contents(array('ja' => '大阪', 'en' => 'Osaka'));
|
| メソッド名 | 引数 | 返り値 | 説明 |
|---|---|---|---|
| first | ・(array) options [= array()]: 検索条件 | (ParallelTextRecord) 用例対訳レコード | 検索条件に一致する用例対訳レコードの最初の1件を取得する. 検索条件は後述 |
| last | ・(array) options [= array()]: 検索条件 | (ParallelTextRecord) 用例対訳レコード | 検索条件に一致する用例対訳レコードの最後の1件を取得する. 検索条件は後述 |
| all | ・(array) options [= array()]: 検索条件 | (ParallelTextRecord[]) 用例対訳レコードリスト | 検索条件に一致する用例対訳レコードを全件取得する. 検索条件は後述 |
| count | ・(array) options [= array()]: 検索条件 | (ParallelTextRecord) 用例対訳レコード | 検索条件に一致する用例対訳レコードの件数を取得する. 検索条件は後述 |
| count_by_resource_id_and_language | ・(Integer) resource_id: カウント対象の用例対訳のID ・(Language) languageCode: カウント対象の言語コード | (Integer) 件数 | 指定の用例対訳に含まれる指定言語の登録件数を取得する. |
| count_by_resource_id_each_languages | ・(Integer) resource_id: カウント対象の用例対訳のID | (array) 言語別の登録数 | 指定の用例対訳に含まれる言語別の登録件数を取得する. |
| create_record |
・(Integer) resource_id: レコードを追加する対象用例対訳のID ・(array) params [= array()]: 追加データ ・(String) create_user [= '']: 追加するユーザーのID |
(ParallelTextRecord) 追加したレコード | 指定の用例対訳に新規レコードを追加する |
ローカル辞書・ローカル用例対訳共通の検索条件の指定について
詳しくは以下を参照.
PHP ActiveRecord - Finders - An easy to use ORM for PHP