Beispiel #1
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)
    if 3 <= len(sys.argv):
        a = sys.argv[1]
    else:
        a = '/usr/share/skk/SKK-JISYO.ML'
    if 3 <= len(sys.argv):
        b = sys.argv[2]
    elif 2 <= len(sys.argv):
        b = sys.argv[1]
    else:
        b = 'restrained.dic'
    print(";", a, "−", b)
    dict = dic.difference(dic.load(a), dic.load(b))
    dic.output(dict)
Beispiel #2
0
import codecs
import re
import sys

from signal import signal, SIGPIPE, SIG_DFL

import dic

if __name__ == '__main__':
    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)