(6)单词和翻译入库

前面两个类 readDic.class.php将单个文件下的词库以【单词=>翻译】的格式,返回

readDir.class.php同样把每个路径下的文件以数组的格式返回

而groupDicName.class.php则解析分类名



这个类则负责一一对应的将每一个单词存储到对应的redis缓存的对应hash表里,这样讲生成26*NUM ,大约100个哈希表


<?php
require_once "readDic.class.php";
require_once "readDir.class.php";
require_once "storeWord.class.php";
require_once "groupDicName.class.php";

class Server
{
	private $redis=null;
	private $groupName=null;
	
	public function __construct($dir)
	{
		$this->groupName=new GroupDicName();
		$this->redis=new StoreWord();
		$this->parseDic($dir);
	}
	
	public function getDir($path)
	{
		 $dir=new Dir($path);
		 return $dir->getFileList();
	}
	
	public function parseDic($dir)
	{
		$path=$this->getDir($dir);
		foreach ($path as $wordZone => $dir)
		{
				foreach ($dir as $dicPath)
				{
					$oxf=new Oxford($dicPath);
					$res=$oxf->oxf();
					$gname=$this->groupName->formatName($dicPath);
					$this->groupName->setIndex($dicPath);
					$this->redis->setWord($gname, $res);
					echo str_repeat("   ", 2048);
					echo '单词库入库:  '. $dicPath. "<br />";
					
					sleep(2);
				}
				echo '<font color="red">'.$wordZone.'分类存储完毕</font><br />';
			
		}
		echo'<font color="blue">所有分类存储完毕</font><br />';
	}

}

set_time_limit(1000);
ob_implicit_flush(true);
$ser=new Server('E:\CodeEdit\php\ciba\TXT格式的牛津电子词典\牛津电子词典');

?>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值