模具技師證是一種專業(yè)技能證書,考試通常由權(quán)威認(rèn)證機(jī)構(gòu)如中國(guó)模具工業(yè)協(xié)會(huì)或相關(guān)學(xué)術(shù)機(jī)構(gòu)組織。要考取模具技師證,首先需要具備相關(guān)的模具專業(yè)知識(shí),包括模具設(shè)計(jì)、制造、維修等方面的技能。
通常,考取證書需要完成一定的學(xué)習(xí)課程,掌握相關(guān)的基礎(chǔ)知識(shí)和技能,并參加考試。
在考試過程中,需要展示對(duì)模具設(shè)計(jì)、制造、維修等技能的理解和應(yīng)用能力。通過考試后,就可以獲得相應(yīng)的模具技師證書。需要注意的是,考試內(nèi)容和難度會(huì)因不同的認(rèn)證機(jī)構(gòu)而有所差異,因此需要了解相關(guān)認(rèn)證機(jī)構(gòu)的具體要求和考試內(nèi)容,進(jìn)行充分準(zhǔn)備。
沖壓模具設(shè)計(jì)面試題是在沖壓行業(yè)中常見的一種面試形式。對(duì)于模具設(shè)計(jì)師來說,掌握面試題的解答是非常重要的,這不僅可以展示自己的專業(yè)知識(shí)和技能,還能增加面試成功的機(jī)會(huì)。
作為一名沖壓模具設(shè)計(jì)師,在面試前充分準(zhǔn)備各類面試題是必不可少的。下面,我將分享一些常見的沖壓模具設(shè)計(jì)面試題,并給出相應(yīng)的答案供大家參考。
沖壓模具設(shè)計(jì)的基本流程包括以下幾個(gè)步驟:
沖壓模具設(shè)計(jì)中常用的軟件主要有以下幾種:
常見的沖壓模具可以根據(jù)不同的分類標(biāo)準(zhǔn)進(jìn)行劃分:
在我多年的沖壓模具設(shè)計(jì)經(jīng)驗(yàn)中,我積累了一些經(jīng)驗(yàn)和技巧,包括:
在我從事沖壓模具設(shè)計(jì)的職業(yè)生涯中,我參與了多個(gè)成功的沖壓模具設(shè)計(jì)項(xiàng)目,其中一個(gè)典型案例是:
我所在的團(tuán)隊(duì)負(fù)責(zé)設(shè)計(jì)某汽車零部件的沖壓模具,這個(gè)零部件形狀復(fù)雜,要求尺寸精度高。在該項(xiàng)目中,我采用了先進(jìn)的三維建模軟件和模擬分析技術(shù),經(jīng)過多次的方案比選和優(yōu)化,最終設(shè)計(jì)出了一個(gè)結(jié)構(gòu)合理、性能穩(wěn)定的沖壓模具。該模具經(jīng)過實(shí)際生產(chǎn)驗(yàn)證,零件的質(zhì)量和生產(chǎn)效率得到了顯著提升,獲得了客戶的高度贊譽(yù)。
在沖壓模具設(shè)計(jì)過程中,常見的問題包括:
這些問題在實(shí)際沖壓模具設(shè)計(jì)中是常見的,解決方法需要根據(jù)具體情況進(jìn)行分析和判斷。
沖壓模具設(shè)計(jì)是一個(gè)復(fù)雜而關(guān)鍵的工作,對(duì)設(shè)計(jì)師的專業(yè)知識(shí)和技能有較高要求。通過對(duì)沖壓模具設(shè)計(jì)面試題的準(zhǔn)備和理解,可以提高自己在面試中的競(jìng)爭(zhēng)力,展示出自己的實(shí)力和潛力。希望以上的面試題及答案對(duì)正在準(zhǔn)備沖壓模具設(shè)計(jì)面試的人士有所幫助,祝大家面試順利!
模具技師個(gè)人總結(jié)報(bào)告
作為一名經(jīng)驗(yàn)豐富的模具技師,我認(rèn)為對(duì)自己的工作進(jìn)行總結(jié)和反思是非常必要的。通過這篇個(gè)人總結(jié)報(bào)告,我將回顧過去的工作經(jīng)歷,總結(jié)所取得的成績(jī)和經(jīng)驗(yàn)教訓(xùn),以及未來的發(fā)展規(guī)劃和目標(biāo)。希望通過這樣的總結(jié)能夠不斷提升自我,更好地適應(yīng)行業(yè)發(fā)展的需要。
在過去的工作中,我主要負(fù)責(zé)模具的設(shè)計(jì)、制造和維護(hù)工作。在設(shè)計(jì)方面,我注重與工程師團(tuán)隊(duì)的緊密合作,根據(jù)產(chǎn)品需求進(jìn)行設(shè)計(jì)方案的制定,確保模具的質(zhì)量和效率。在制造過程中,我嚴(yán)格把控每一個(gè)工序,確保模具的精準(zhǔn)度和穩(wěn)定性。在維護(hù)方面,我建立了完善的維護(hù)記錄和計(jì)劃,定期檢查和保養(yǎng)模具,延長(zhǎng)了模具的使用壽命,降低了生產(chǎn)成本。
在工作中,我積累了豐富的經(jīng)驗(yàn),能夠獨(dú)立解決各種復(fù)雜的技術(shù)問題,反映了我的專業(yè)能力和工作態(tài)度。同時(shí),我善于與同事合作,團(tuán)隊(duì)協(xié)作能力較強(qiáng),能夠高效地完成工作任務(wù)。在工作中,我始終保持學(xué)習(xí)的態(tài)度,不斷學(xué)習(xí)新知識(shí)和新技術(shù),不斷提升自己的專業(yè)水平。
在工作中,我也遇到過一些困難和挑戰(zhàn)。比如在某個(gè)項(xiàng)目中,由于溝通不暢,導(dǎo)致了設(shè)計(jì)方案的誤解,影響了模具的制造進(jìn)度。通過這樣的教訓(xùn),我意識(shí)到溝通的重要性,學(xué)會(huì)了更加有效地與團(tuán)隊(duì)溝通,避免類似的問題再次發(fā)生。
此外,我也意識(shí)到在工作中要保持耐心和細(xì)心,不能因?yàn)楣ぷ鞯姆泵Χ雎约?xì)節(jié)。細(xì)節(jié)決定成敗,只有將每一個(gè)細(xì)節(jié)做到位,才能保證工作的質(zhì)量和效率。因此,我在工作中更加注重細(xì)節(jié),保持高度的專注和耐心,確保工作的完美完成。
在未來的工作中,我將繼續(xù)努力提升自己的專業(yè)能力和技術(shù)水平,不斷學(xué)習(xí)行業(yè)最新的發(fā)展動(dòng)態(tài)和技術(shù)知識(shí),保持與行業(yè)前沿的接軌。同時(shí),我也希望能夠挑戰(zhàn)更高級(jí)別的工作崗位,拓展自己的職業(yè)發(fā)展空間,為企業(yè)的發(fā)展貢獻(xiàn)自己的力量。
此外,我還計(jì)劃參加相關(guān)的培訓(xùn)和認(rèn)證考試,提升自己的專業(yè)認(rèn)證水平,增強(qiáng)個(gè)人在求職市場(chǎng)上的競(jìng)爭(zhēng)力。通過不斷學(xué)習(xí)和提升,我相信自己能夠在模具行業(yè)中取得更加出色的成績(jī),實(shí)現(xiàn)個(gè)人職業(yè)目標(biāo)和企業(yè)發(fā)展目標(biāo)。
總的來說,通過這次模具技師個(gè)人總結(jié)報(bào)告,我對(duì)自己的工作進(jìn)行了深入的反思和總結(jié),發(fā)現(xiàn)了自身的優(yōu)勢(shì)和不足,明確了未來的發(fā)展方向和目標(biāo)。我會(huì)繼續(xù)努力工作,不斷提升自己,為行業(yè)的發(fā)展和企業(yè)的成功貢獻(xiàn)自己的力量。
模具鉗工技師是機(jī)械制造行業(yè)中非常重要的角色,他們負(fù)責(zé)制造和維修各種模具,并確保其質(zhì)量和準(zhǔn)確度。而在模具鉗工技師畢業(yè)論文中,我們將探討模具鉗工技師的職責(zé)、技能要求以及未來發(fā)展前景。
作為模具鉗工技師,他們的主要職責(zé)是制造和維修各種模具。模具是用于制造各種產(chǎn)品的工具或零件,它們的準(zhǔn)確性和質(zhì)量直接影響到最終產(chǎn)品的質(zhì)量。因此,模具鉗工技師需要擁有精密加工的技能,能夠操作各種機(jī)械設(shè)備和工具,以及能夠解讀和理解技術(shù)圖紙。
除了制造和維修模具外,模具鉗工技師還需要進(jìn)行模具測(cè)試和調(diào)整,以確保其符合產(chǎn)品規(guī)格。他們還負(fù)責(zé)解決模具生產(chǎn)過程中的問題,并進(jìn)行必要的改進(jìn)和調(diào)整。同時(shí),他們需要與其他部門合作,如設(shè)計(jì)師和工程師,以確保模具的質(zhì)量和功能。
要成為一名優(yōu)秀的模具鉗工技師,以下是一些必備的技能要求:
隨著制造業(yè)的發(fā)展和技術(shù)的進(jìn)步,模具鉗工技師的需求將繼續(xù)增長(zhǎng)。他們?cè)谄囍圃臁⒑娇蘸教臁㈦娮釉O(shè)備等行業(yè)中扮演著重要的角色。
當(dāng)前,制造業(yè)正經(jīng)歷著工業(yè)4.0的時(shí)代,即數(shù)字化、智能化生產(chǎn)。模具鉗工技師需要跟上這一潮流,學(xué)習(xí)和掌握與技術(shù)相關(guān)的知識(shí)和技能,如計(jì)算機(jī)輔助設(shè)計(jì)、數(shù)控加工等。
此外,隨著制造業(yè)對(duì)高精度、高質(zhì)量模具的需求不斷增加,模具鉗工技師需要不斷提升自己的技能,學(xué)習(xí)新的加工技術(shù)和工具。他們可以通過持續(xù)的學(xué)習(xí)和培訓(xùn)來提高自己的專業(yè)水平,并通過參加技能競(jìng)賽和獲得相關(guān)證書來展示自己的能力。
總而言之,模具鉗工技師是制造行業(yè)中不可或缺的一部分。他們的技能和貢獻(xiàn)直接影響著產(chǎn)品的質(zhì)量和效率。通過不斷學(xué)習(xí)和提升自己的技能,模具鉗工技師將在未來的發(fā)展中獲得更多的機(jī)會(huì)和挑戰(zhàn)。
國(guó)企的話大專畢業(yè)只能先從中級(jí)鉗工考起,每個(gè)單位體系不一樣,私企的話可以在社會(huì)上考去技師證。
技師可以說是另外兩個(gè)會(huì)的他都會(huì)。 成熟的技師在拿到零件時(shí)候到裝配然后調(diào)試做成成品,最后給客戶交模以及交產(chǎn)品時(shí)候按客戶要求要求做的臨時(shí)改動(dòng)中的做法和技術(shù)都要精通。 模具師傅工作是裝配以及調(diào)試為主。 模具補(bǔ)師就是在產(chǎn)品生產(chǎn)過程中碰到加工損壞、裝配不完整、調(diào)試需要修補(bǔ),或者存在設(shè)計(jì)方面的漏洞處理。 模具技師有:沖壓模具技師、五金模具技師、塑膠模具技師、精密模具零件測(cè)量技師、模具鉗工技師。
1、維護(hù)模具的日常運(yùn)行,定時(shí)對(duì)模具維護(hù)及保養(yǎng)。
2、負(fù)責(zé)生產(chǎn)所需工裝模具設(shè)計(jì)。
3、處理工裝模具制作和維修過程中出現(xiàn)的技術(shù)問題。 模具補(bǔ)師就是在產(chǎn)品生產(chǎn)過程中碰到加工損壞、裝配不完整、調(diào)試需要修補(bǔ),或者存在設(shè)計(jì)方面的漏洞處理,對(duì)產(chǎn)品進(jìn)行修補(bǔ)工作。 通常先從模具補(bǔ)師坐起,會(huì)做裝配和調(diào)試成為模具師傅,然后一步一步進(jìn)階到模具技師。
首先本職工作內(nèi)容,然后分析產(chǎn)生原因,然后 本人未預(yù)料后果,耽誤了后續(xù)生產(chǎn)以及其它同事的效率,本人檢討,并作好預(yù)防措施,再有修理事件,會(huì)在筆記或黑板標(biāo)識(shí),同時(shí)給予第一時(shí)間處理,提高工作效率與積極性
我沒做過,不過以廠在鋁材廠待過,我去兩家廠工資都不錯(cuò)。聽說有5到6千一個(gè)月。因?yàn)槟切S就靠那些模具生產(chǎn)。如果模具不行,就要停工。
該學(xué)院以機(jī)械方面專業(yè)居多,總體女生相對(duì)要少一些,在學(xué)校里,一般數(shù)控、電子之類的專業(yè)女生稍多,模具要鉗工基礎(chǔ)的,一般不太招女生。
之前看了Mahout官方示例 20news 的調(diào)用實(shí)現(xiàn);于是想根據(jù)示例的流程實(shí)現(xiàn)其他例子。網(wǎng)上看到了一個(gè)關(guān)于天氣適不適合打羽毛球的例子。
訓(xùn)練數(shù)據(jù):
Day Outlook Temperature Humidity Wind PlayTennis
D1 Sunny Hot High Weak No
D2 Sunny Hot High Strong No
D3 Overcast Hot High Weak Yes
D4 Rain Mild High Weak Yes
D5 Rain Cool Normal Weak Yes
D6 Rain Cool Normal Strong No
D7 Overcast Cool Normal Strong Yes
D8 Sunny Mild High Weak No
D9 Sunny Cool Normal Weak Yes
D10 Rain Mild Normal Weak Yes
D11 Sunny Mild Normal Strong Yes
D12 Overcast Mild High Strong Yes
D13 Overcast Hot Normal Weak Yes
D14 Rain Mild High Strong No
檢測(cè)數(shù)據(jù):
sunny,hot,high,weak
結(jié)果:
Yes=》 0.007039
No=》 0.027418
于是使用Java代碼調(diào)用Mahout的工具類實(shí)現(xiàn)分類。
基本思想:
1. 構(gòu)造分類數(shù)據(jù)。
2. 使用Mahout工具類進(jìn)行訓(xùn)練,得到訓(xùn)練模型。
3。將要檢測(cè)數(shù)據(jù)轉(zhuǎn)換成vector數(shù)據(jù)。
4. 分類器對(duì)vector數(shù)據(jù)進(jìn)行分類。
接下來貼下我的代碼實(shí)現(xiàn)=》
1. 構(gòu)造分類數(shù)據(jù):
在hdfs主要?jiǎng)?chuàng)建一個(gè)文件夾路徑 /zhoujainfeng/playtennis/input 并將分類文件夾 no 和 yes 的數(shù)據(jù)傳到hdfs上面。
數(shù)據(jù)文件格式,如D1文件內(nèi)容: Sunny Hot High Weak
2. 使用Mahout工具類進(jìn)行訓(xùn)練,得到訓(xùn)練模型。
3。將要檢測(cè)數(shù)據(jù)轉(zhuǎn)換成vector數(shù)據(jù)。
4. 分類器對(duì)vector數(shù)據(jù)進(jìn)行分類。
這三步,代碼我就一次全貼出來;主要是兩個(gè)類 PlayTennis1 和 BayesCheckData = =》
package myTesting.bayes;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.util.ToolRunner;
import org.apache.mahout.classifier.naivebayes.training.TrainNaiveBayesJob;
import org.apache.mahout.text.SequenceFilesFromDirectory;
import org.apache.mahout.vectorizer.SparseVectorsFromSequenceFiles;
public class PlayTennis1 {
private static final String WORK_DIR = "hdfs://192.168.9.72:9000/zhoujianfeng/playtennis";
/*
* 測(cè)試代碼
*/
public static void main(String[] args) {
//將訓(xùn)練數(shù)據(jù)轉(zhuǎn)換成 vector數(shù)據(jù)
makeTrainVector();
//產(chǎn)生訓(xùn)練模型
makeModel(false);
//測(cè)試檢測(cè)數(shù)據(jù)
BayesCheckData.printResult();
}
public static void makeCheckVector(){
//將測(cè)試數(shù)據(jù)轉(zhuǎn)換成序列化文件
try {
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String input = WORK_DIR+Path.SEPARATOR+"testinput";
String output = WORK_DIR+Path.SEPARATOR+"tennis-test-seq";
Path in = new Path(input);
Path out = new Path(output);
FileSystem fs = FileSystem.get(conf);
if(fs.exists(in)){
if(fs.exists(out)){
//boolean參數(shù)是,是否遞歸刪除的意思
fs.delete(out, true);
}
SequenceFilesFromDirectory sffd = new SequenceFilesFromDirectory();
String[] params = new String[]{"-i",input,"-o",output,"-ow"};
ToolRunner.run(sffd, params);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("文件序列化失敗!");
System.exit(1);
}
//將序列化文件轉(zhuǎn)換成向量文件
try {
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String input = WORK_DIR+Path.SEPARATOR+"tennis-test-seq";
String output = WORK_DIR+Path.SEPARATOR+"tennis-test-vectors";
Path in = new Path(input);
Path out = new Path(output);
FileSystem fs = FileSystem.get(conf);
if(fs.exists(in)){
if(fs.exists(out)){
//boolean參數(shù)是,是否遞歸刪除的意思
fs.delete(out, true);
}
SparseVectorsFromSequenceFiles svfsf = new SparseVectorsFromSequenceFiles();
String[] params = new String[]{"-i",input,"-o",output,"-lnorm","-nv","-wt","tfidf"};
ToolRunner.run(svfsf, params);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("序列化文件轉(zhuǎn)換成向量失敗!");
System.out.println(2);
}
}
public static void makeTrainVector(){
//將測(cè)試數(shù)據(jù)轉(zhuǎn)換成序列化文件
try {
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String input = WORK_DIR+Path.SEPARATOR+"input";
String output = WORK_DIR+Path.SEPARATOR+"tennis-seq";
Path in = new Path(input);
Path out = new Path(output);
FileSystem fs = FileSystem.get(conf);
if(fs.exists(in)){
if(fs.exists(out)){
//boolean參數(shù)是,是否遞歸刪除的意思
fs.delete(out, true);
}
SequenceFilesFromDirectory sffd = new SequenceFilesFromDirectory();
String[] params = new String[]{"-i",input,"-o",output,"-ow"};
ToolRunner.run(sffd, params);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("文件序列化失敗!");
System.exit(1);
}
//將序列化文件轉(zhuǎn)換成向量文件
try {
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String input = WORK_DIR+Path.SEPARATOR+"tennis-seq";
String output = WORK_DIR+Path.SEPARATOR+"tennis-vectors";
Path in = new Path(input);
Path out = new Path(output);
FileSystem fs = FileSystem.get(conf);
if(fs.exists(in)){
if(fs.exists(out)){
//boolean參數(shù)是,是否遞歸刪除的意思
fs.delete(out, true);
}
SparseVectorsFromSequenceFiles svfsf = new SparseVectorsFromSequenceFiles();
String[] params = new String[]{"-i",input,"-o",output,"-lnorm","-nv","-wt","tfidf"};
ToolRunner.run(svfsf, params);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("序列化文件轉(zhuǎn)換成向量失敗!");
System.out.println(2);
}
}
public static void makeModel(boolean completelyNB){
try {
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String input = WORK_DIR+Path.SEPARATOR+"tennis-vectors"+Path.SEPARATOR+"tfidf-vectors";
String model = WORK_DIR+Path.SEPARATOR+"model";
String labelindex = WORK_DIR+Path.SEPARATOR+"labelindex";
Path in = new Path(input);
Path out = new Path(model);
Path label = new Path(labelindex);
FileSystem fs = FileSystem.get(conf);
if(fs.exists(in)){
if(fs.exists(out)){
//boolean參數(shù)是,是否遞歸刪除的意思
fs.delete(out, true);
}
if(fs.exists(label)){
//boolean參數(shù)是,是否遞歸刪除的意思
fs.delete(label, true);
}
TrainNaiveBayesJob tnbj = new TrainNaiveBayesJob();
String[] params =null;
if(completelyNB){
params = new String[]{"-i",input,"-el","-o",model,"-li",labelindex,"-ow","-c"};
}else{
params = new String[]{"-i",input,"-el","-o",model,"-li",labelindex,"-ow"};
}
ToolRunner.run(tnbj, params);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("生成訓(xùn)練模型失敗!");
System.exit(3);
}
}
}
package myTesting.bayes;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.mahout.classifier.naivebayes.BayesUtils;
import org.apache.mahout.classifier.naivebayes.NaiveBayesModel;
import org.apache.mahout.classifier.naivebayes.StandardNaiveBayesClassifier;
import org.apache.mahout.common.Pair;
import org.apache.mahout.common.iterator.sequencefile.PathType;
import org.apache.mahout.common.iterator.sequencefile.SequenceFileDirIterable;
import org.apache.mahout.math.RandomAccessSparseVector;
import org.apache.mahout.math.Vector;
import org.apache.mahout.math.Vector.Element;
import org.apache.mahout.vectorizer.TFIDF;
import com.google.common.collect.ConcurrentHashMultiset;
import com.google.common.collect.Multiset;
public class BayesCheckData {
private static StandardNaiveBayesClassifier classifier;
private static Map<String, Integer> dictionary;
private static Map<Integer, Long> documentFrequency;
private static Map<Integer, String> labelIndex;
public void init(Configuration conf){
try {
String modelPath = "/zhoujianfeng/playtennis/model";
String dictionaryPath = "/zhoujianfeng/playtennis/tennis-vectors/dictionary.file-0";
String documentFrequencyPath = "/zhoujianfeng/playtennis/tennis-vectors/df-count";
String labelIndexPath = "/zhoujianfeng/playtennis/labelindex";
dictionary = readDictionnary(conf, new Path(dictionaryPath));
documentFrequency = readDocumentFrequency(conf, new Path(documentFrequencyPath));
labelIndex = BayesUtils.readLabelIndex(conf, new Path(labelIndexPath));
NaiveBayesModel model = NaiveBayesModel.materialize(new Path(modelPath), conf);
classifier = new StandardNaiveBayesClassifier(model);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("檢測(cè)數(shù)據(jù)構(gòu)造成vectors初始化時(shí)報(bào)錯(cuò)。。。。");
System.exit(4);
}
}
/**
* 加載字典文件,Key: TermValue; Value:TermID
* @param conf
* @param dictionnaryDir
* @return
*/
private static Map<String, Integer> readDictionnary(Configuration conf, Path dictionnaryDir) {
Map<String, Integer> dictionnary = new HashMap<String, Integer>();
PathFilter filter = new PathFilter() {
@Override
public boolean accept(Path path) {
String name = path.getName();
return name.startsWith("dictionary.file");
}
};
for (Pair<Text, IntWritable> pair : new SequenceFileDirIterable<Text, IntWritable>(dictionnaryDir, PathType.LIST, filter, conf)) {
dictionnary.put(pair.getFirst().toString(), pair.getSecond().get());
}
return dictionnary;
}
/**
* 加載df-count目錄下TermDoc頻率文件,Key: TermID; Value:DocFreq
* @param conf
* @param dictionnaryDir
* @return
*/
private static Map<Integer, Long> readDocumentFrequency(Configuration conf, Path documentFrequencyDir) {
Map<Integer, Long> documentFrequency = new HashMap<Integer, Long>();
PathFilter filter = new PathFilter() {
@Override
public boolean accept(Path path) {
return path.getName().startsWith("part-r");
}
};
for (Pair<IntWritable, LongWritable> pair : new SequenceFileDirIterable<IntWritable, LongWritable>(documentFrequencyDir, PathType.LIST, filter, conf)) {
documentFrequency.put(pair.getFirst().get(), pair.getSecond().get());
}
return documentFrequency;
}
public static String getCheckResult(){
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String classify = "NaN";
BayesCheckData cdv = new BayesCheckData();
cdv.init(conf);
System.out.println("init done...............");
Vector vector = new RandomAccessSparseVector(10000);
TFIDF tfidf = new TFIDF();
//sunny,hot,high,weak
Multiset<String> words = ConcurrentHashMultiset.create();
words.add("sunny",1);
words.add("hot",1);
words.add("high",1);
words.add("weak",1);
int documentCount = documentFrequency.get(-1).intValue(); // key=-1時(shí)表示總文檔數(shù)
for (Multiset.Entry<String> entry : words.entrySet()) {
String word = entry.getElement();
int count = entry.getCount();
Integer wordId = dictionary.get(word); // 需要從dictionary.file-0文件(tf-vector)下得到wordID,
if (StringUtils.isEmpty(wordId.toString())){
continue;
}
if (documentFrequency.get(wordId) == null){
continue;
}
Long freq = documentFrequency.get(wordId);
double tfIdfValue = tfidf.calculate(count, freq.intValue(), 1, documentCount);
vector.setQuick(wordId, tfIdfValue);
}
// 利用貝葉斯算法開始分類,并提取得分最好的分類label
Vector resultVector = classifier.classifyFull(vector);
double bestScore = -Double.MAX_VALUE;
int bestCategoryId = -1;
for(Element element: resultVector.all()) {
int categoryId = element.index();
double score = element.get();
System.out.println("categoryId:"+categoryId+" score:"+score);
if (score > bestScore) {
bestScore = score;
bestCategoryId = categoryId;
}
}
classify = labelIndex.get(bestCategoryId)+"(categoryId="+bestCategoryId+")";
return classify;
}
public static void printResult(){
System.out.println("檢測(cè)所屬類別是:"+getCheckResult());
}
}