# you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import codecs import re import sys from signal import signal, SIGPIPE, SIG_DFL import dic if __name__ == '__main__': signal(SIGPIPE, SIG_DFL) a = '/usr/share/skk/SKK-JISYO.ML' if 2 <= len(sys.argv): a = sys.argv[1] b = '/usr/share/skk/SKK-JISYO.jinmei' if 3 <= len(sys.argv): b = sys.argv[2] dict = dic.intersection(dic.load(a), dic.load(b)) print(";", a, "∩", b) dic.output(dict)
signal(SIGPIPE, SIG_DFL) path = '/usr/share/skk/SKK-JISYO.ML' if 2 <= len(sys.argv): path = sys.argv[1] dict = dic.load(path) dict = dic.difference(dict, dic.yougen(dict)) # 用言を削除 dict = dic.union(dict, dic.load('my.dic')) # 独自に追加したい熟語を追加。 grade = 8 if 3 <= len(sys.argv): grade = int(sys.argv[2]) # 人名、地名、駅名、記号については、人名漢字の使用を許容し、例外辞書に格納しておきます。 zinmei = dic.load('/usr/share/skk/SKK-JISYO.jinmei') reigai_zinmei = dic.intersection(dict, zinmei) geo = dic.load('/usr/share/skk/SKK-JISYO.geo') reigai_geo = dic.intersection(dict, geo) station = dic.load('/usr/share/skk/SKK-JISYO.station') reigai_station = dic.intersection(dict, station) reigai_kigou = dic.kigou(dict) reigai = dic.union(reigai_zinmei, reigai_geo) reigai = dic.union(reigai, reigai_station) reigai = dic.union(reigai, reigai_kigou) dict = dic.difference(dict, reigai) # 例外辞書の内容を削除 if grade <= 6: reigai = dic.difference(reigai, dic.hyougai(reigai)) reigai = dic.difference(reigai, dic.hyougai_yomi(reigai, grade)) zyosuusi = dic.load('zyosuusi.dic') zyosuusi = dic.difference(zyosuusi, dic.hyougai_yomi(zyosuusi, grade))