âã®è¾ºãã®è¨äºãèªãã§xargsã«ãã並ååã試ãã¦ã¿ãã¡ã¢ã
çµæãå
ã«æ¸ãã¦ããã¨ãæ®å¿µãªãã並ååãã¦ããã¾ãéããªããªãã£ãã
ããããããã³ãã³ãã®ä½¿ãæ¹ãæªããããâ¦â¦ï¼
ã¨ããããç®çã¯MeCabã並åã«å®è¡ãããã¨ã
300å¼±ã®ãã¡ã¤ã«ã§è©¦ããã
並åæ°Pã¨æ¸¡ãå¼æ°ã®æ°nã¯é©å½ã«æ±ºããã
1.ãã¡ã¤ã«ãã¨ã«ä¸¦å
ã«ã¬ã³ããã£ã¬ã¯ããªä»¥ä¸ã®.txtãã¡ã¤ã«åãå ¨é¨åã£ã¦ãã¦10並åã§MeCabã«æãã¦åºåãtxtãã¡ã¤ã«å+.mecabãã¡ã¤ã«ã«ãªãã¤ã¬ã¯ãããã
ããããã·ã§ã«(sh)çµç±ã§MeCabãèµ·åãã¦ããã®ã¯ã.mecabãã¡ã¤ã«ã«æ¨æºåºåããªãã¤ã¬ã¯ããããããã«ããããã
find . -name '*.txt' -print0 | xargs -0 -I{} -P10 -n1 sh -c 'mecab "{}" > "{}.mecab"'
2.ã·ã§ã«ã®èµ·ååæ°ãæ¸ãã
é ãåå ãããã¹ããã¡ã¤ã«ãã¨ã«shãèµ·åãã¦ãããããã¨æã£ãã®ã§ããã¡ã¤ã«åãã¾ã¨ãã¦æ¸¡ãã¦ã·ã§ã«å ã§forã«ã¼ãã§åãããã«ããã
find . -name '*.txt' -print0 | xargs -0 -P10 -n20 sh -c 'for arg in "$0" "$@"; do mecab "${arg}" > "${arg}.mecab"; done'
3.åå²ããå¾ã«forã«ã¼ãã使ããcatã§ã¾ã¨ãã¦ããMeCabã«ããã¦ãMeCabãå¼ã¶åæ°ãæ¸ããã
æ´ã«MeCabãå¼ã¶åæ°ãæ¸ããã¦ã¿ãã
find . -name '*.txt' -print0 | xargs -0 -P10 -n20 sh -c 'cat "$0" "$@" | mecab > "$0.mecab"'
çµæ
10並åã§åããã¦ãããã2ãã4åç¨åº¦ã®å¦çé度ã ã£ãã
ããããµã¼ãã¼å´ã®åé¡ãªã®ããå®è¡ãããã³ã«å¦çæéã«ããªãã°ãã¤ãããã£ãã
ä¸ã«æ¸ãã3種é¡ã®ããæ¹ã§è©¦ãã¦ã¿ãããæ®å¿µãªãããã¾ãã©ããéããã¨ããã®ã¯æããã§ã¯ãªãã£ãã