1、出自《禮記·大學(xué)》
2、原文
《禮記·大學(xué)》:“古之欲明明德于天下者,先治其國;欲治其國者,先齊其家;欲齊其家者,先修其身;欲修其身者,先正其心;欲正其心者,先誠其意;欲誠其意者,先致其知,致知在格物。物格而后知至,知至而后意誠,意誠而后心正,心正而后身修,身修而后家齊,家齊而后國治,國治而后天下平?!?/p>
3、譯文
古代那些要想在天下弘揚(yáng)光明正大品德的人,先要治理好自己的國家;要想治理好自己的國家,先要管理好自己的家庭和家族;要想管理好自己的家庭和家族,先要修養(yǎng)自身的品性;要想修養(yǎng)自身的品性,先要端正自己的思想;要端正自己的思想,先要使自己的意念真誠;要想使自己的意念真誠,先要使自己獲得知識,獲得知識的途徑在于認(rèn)知研究萬事萬物。
通過對萬事萬物的認(rèn)識研究,才能獲得知識;獲得知識后,意念才能真誠;意念真誠后,心思才能端正;心思端正后,才能修養(yǎng)品性;品性修養(yǎng)后,才能管理好家庭家族;家庭家族管理好了,才能治理好國家;治理好國家后天下才能太平。
擴(kuò)展資料
1、“修身齊家治國平天下”是中國儒家思想的核心。養(yǎng)德修身是做人為官的基礎(chǔ),為官者如不講究道德就沒有資格領(lǐng)導(dǎo)管理民眾,而官德最根本的就是為人民服務(wù)。
2、 “格物、致知、誠意、正心、修身、齊家、治國、平天下”后世稱之為《大學(xué)》的“八條目”,這是實(shí)現(xiàn)“三綱領(lǐng)”的具體步驟?!鞍藯l目”的中心環(huán)節(jié)是修身,“自天子以至于庶人,壹是皆以修身為本”。對于培養(yǎng)目標(biāo)和方法,《大學(xué)》反復(fù)強(qiáng)調(diào)的是個(gè)人的道德修養(yǎng)。大學(xué)的宗旨在于弘揚(yáng)光明正大的品德,在于使人棄舊圖新,在于使人達(dá)到最完善的境界。
3、“修身齊家治國平天下”可以視為對“大學(xué)之道”的概括,它也是儒家學(xué)說的精髓所在。儒家“修齊治平”之道也是自堯舜以來古圣先賢智慧的凝練與總結(jié)。因此它才能夠在歷代士人的心中深深扎根。無數(shù)的志士仁人都胸懷天下,心系蒼生,他們有崇高的價(jià)值信念和高尚的理想追求,如北宋儒學(xué)家張載的“為天地立心、為生民立命、為往圣繼絕學(xué)、為萬世開太平”
沒有反義詞。
拼音:
xiū shēn qí jiā
解釋:
提高自身修養(yǎng),理好家政
出處:
元·無名氏《九世同居》第一折:“父親,有甚么修身齊家的事,訓(xùn)教你兒者?!?/p>
語法:
修身齊家作謂語、賓語、定語;用于書面語。
示例:
宗璞《東藏記》:“大至治國興邦,小至修身齊家,歸根到底都得靠自己?!?/p>
出處:《禮記·大學(xué)》簡譯:意謂古代要向天下顯示完美道德的人,首先要治理好他的國家,要治理好他的國家,先要治理好他的家庭;要治理好自己的家庭,首先要加強(qiáng)自己道德品質(zhì)的修養(yǎng);要加強(qiáng)自己道德品質(zhì)的修養(yǎng),首先要使自己心地純正;要使自己成為心地純正的人,首先要使自己的心意誠實(shí);要使自己成為心意誠實(shí)的人,首先要使自己獲得一定的知識;而獲得知識在于把握事物的原理。
古之欲明明德于天下者,先治其國;欲治其國者,先齊其家,欲齊其家者,先修其身,欲修其身者,先正其心,欲正其心者,先誠其意,欲誠其意者,先致其知,致知在格物。
物格而后知至,知至而后意誠,意誠而后心正,心正而后身修,身修而后家齊,家齊而后國治,國治而后天下平。通過明確自己的信念和目標(biāo),讓自己頭腦清醒,明白是非曲直,努力在待人處事各方面在做到真誠,斷惡修善,久而久之,變得有智慧有修養(yǎng)。家是國的縮影,經(jīng)營好家庭的人一定能治理好國家,也一定能協(xié)助國家天下太平。
1、句意是:先修養(yǎng)品性,才能管理家庭,才能治理國家,才能使天下太平。
2、這句話出自于《禮記·大學(xué)》,原文如下:
古之欲明明德于天下者,先治其國;欲治其國者,先齊其家;欲齊其家者,先修其身;欲修其身者,先正其心;欲正其心者,先誠其意;欲誠其意者,先致其知,致知在格物。
物格而后知至,知至而后意誠,意誠而后心正,心正而后身修,身修而后家齊,家齊而后國治,國治而后天下平。
原文白話翻譯
古代那些要想在天下弘揚(yáng)光明正大品德的人,先要治理好自己的國家;要想治理好自己的國家,先要管理好自己的家庭和家族;要想管理好自己的家庭和家族,先要修養(yǎng)自身的品性。
要想修養(yǎng)自身的品性,先要端正自己的思想;要端正自己的思想,先要使自己的意念真誠;要想使自己的意念真誠,先要使自己獲得知識,獲得知識的途徑在于認(rèn)知研究萬事萬物。
通過對萬事萬物的認(rèn)識研究,才能獲得知識;獲得知識后,意念才能真誠;意念真誠后,心思才能端正;心思端正后,才能修養(yǎng)品性;品性修養(yǎng)后,才能管理好家庭家族;家庭家族管理好了,才能治理好國家;治理好國家后天下才能太平。
對天下、國、家的劃分如下:
周王室→王、天子→天下
↓↓
諸侯→公→→→國
↓↓
家族→卿、大夫→→家、宗族
有了對家國天下的認(rèn)識,對自己的發(fā)展方向就是“修身齊家治國平天下”。修身具體來講就是一個(gè)人要飽讀詩書、道德高尚、有一技之長。齊家就是管理好一個(gè)家族、宗族,而不是具體的某一個(gè)人的家庭。
治國就是治理好一個(gè)小小的諸侯國,而不是我們現(xiàn)代意義的國家。要知道,古代的諸侯國是要對周王室負(fù)責(zé)的,也就是我們平時(shí)所說的"邦"。平天下就是安撫天下黎民百姓,使他們能夠豐衣足食、安居樂業(yè),而不是用武力平定天下。
意思是:要使美德彰明于天下的人,先治理好他的國家;要治理好國家的人,要先整頓好自己的家;要整頓好家的人,要先進(jìn)行自我修養(yǎng);要進(jìn)行自我修養(yǎng)的人,要先端正他的思想,思想端正了,然后自我修養(yǎng)完善;自我修養(yǎng)完善了,然后家庭整頓有序;家庭整頓好了,然后國家安定繁榮;國家安定繁榮了,然后天下太平。
先修養(yǎng)品性,才能管理家庭,才能治理國家,才能使天下太平
出處:《禮記·大學(xué)》。相傳為孔子弟子曾參(前505~前434)所作。
原文:
古之欲明明德于天下者,先治其國;欲治其國者,先齊其家;欲齊其家者,先修其身;欲修其身者,先正其心;欲正其心者,先誠其意;欲誠其意者,先致其知,致知在格物。物格而后知至,知至而后意誠,意誠而后心正,心正而后身修,身修而后家齊,家齊而后國治,國治而后天下平。
白話譯文:
古代那些要想在天下弘揚(yáng)光明正大品德的人,先要治理好自己的國家;要想治理好自己的國家,先要管理好自己的家庭和家族;要想管理好自己的家庭和家族,先要修養(yǎng)自身的品性;
要想修養(yǎng)自身的品性,先要端正自己的思想;要端正自己的思想,先要使自己的意念真誠;要想使自己的意念真誠,先要使自己獲得知識,獲得知識的途徑在于認(rèn)知研究萬事萬物。
通過對萬事萬物的認(rèn)識研究,才能獲得知識;獲得知識后,意念才能真誠;意念真誠后,心思才能端正;心思端正后,才能修養(yǎng)品性;品性修養(yǎng)后,才能管理好家庭家族;家庭家族管理好了,才能治理好國家;治理好國家后天下才能太平。
1、做人要做老實(shí)(遵紀(jì)守法)、誠實(shí)(表里如一)、善良人,多做好事,終有好事。
2、族內(nèi)子孫人等,妄作非為,有干名教者,不待鳴官,祠內(nèi)先行整治。
3、粥一飯,當(dāng)思來處不易;半絲半縷,恒念物力維艱。
4、重道德修養(yǎng),嚴(yán)情操品性;扶正義,斥邪惡。
5、欲高門第須為善,要好兒孫必讀書。
6、有百世之德者,必有百世之子孫保之;有十世之德者,就有十世的子孫保之;如果是斬焉無后者,那是德至薄也。
7、一粥一飯,當(dāng)思來之不易;半絲半縷,恒念物力維艱。
8、一身能勤能敬,雖愚人亦有賢智風(fēng)味。
9、一戒是(晚)起;二戒懶惰;三戒奢華;四戒驕傲。既守四戒,又須規(guī)以四宜:一宜勤讀;二宜敬師;三宜愛眾;四宜慎食。
10、學(xué)生要三勤:手勤、腦勤、讀書勤。
之前看了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
檢測數(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。將要檢測數(shù)據(jù)轉(zhuǎn)換成vector數(shù)據(jù)。
4. 分類器對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。將要檢測數(shù)據(jù)轉(zhuǎn)換成vector數(shù)據(jù)。
4. 分類器對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";
/*
* 測試代碼
*/
public static void main(String[] args) {
//將訓(xùn)練數(shù)據(jù)轉(zhuǎn)換成 vector數(shù)據(jù)
makeTrainVector();
//產(chǎn)生訓(xùn)練模型
makeModel(false);
//測試檢測數(shù)據(jù)
BayesCheckData.printResult();
}
public static void makeCheckVector(){
//將測試數(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(){
//將測試數(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)換成向量失?。?#34;);
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("檢測數(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("檢測所屬類別是:"+getCheckResult());
}
}