Skip to content

Commit

Permalink
small cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
kmike committed Apr 12, 2015
1 parent fe55857 commit 1fbffb2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ build/
docs/_build
dist/
pymorphy2.egg-info
stuff/

.idea/
.rope*
Expand Down
24 changes: 12 additions & 12 deletions docs/internals/dict.rst
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@

::

двор (3, 1)
ёж (4, 1)
дворник (1, 2) и (2, 2)
ёжик (1, 2) и (2, 2)
двор (103, 0)
ёж (104, 0)
дворник (101, 2) и (102, 2)
ёжик (101, 2) и (102, 2)

Тогда они будут закодированы в такой граф:

Expand All @@ -268,17 +268,17 @@
6 -> 22 [label=sep];
7 -> 5 [label=И];
8 -> 9 [label=sep];
9 -> 12 [label=PARA_1];
9 -> 15 [label=PARA_2];
12 -> 10 [label=IND_2];
13 -> 14 [label=IND_1];
15 -> 10 [label=IND_2];
9 -> 12 [label="103"];
9 -> 15 [label="102"];
12 -> 10 [label="2"];
13 -> 14 [label="0"];
15 -> 10 [label="2"];
16 -> 32 [label=И];
16 -> 54 [label=sep];
17 -> 14 [label=IND_1];
22 -> 13 [label=PARA_3];
17 -> 14 [label="2"];
22 -> 13 [label="103"];
32 -> 8 [label=К];
54 -> 17 [label=PARA_4];
54 -> 17 [label="104"];


Этот подход позволяет экономить память (т.к. как сами слова, так
Expand Down
11 changes: 7 additions & 4 deletions pymorphy2/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals, print_function, division
from __future__ import absolute_import
from __future__ import unicode_literals, print_function, division

import logging
import time
Expand All @@ -26,8 +27,10 @@ def show_dict_mem_usage(dict_path=None, verbose=False):
end_time = time.time()
mem_usage = get_mem_usage()

logger.info('Memory usage: %0.1fM dictionary, %0.1fM total (load time %0.2fs)',
(mem_usage-initial_mem)/(1024*1024), mem_usage/(1024*1024), end_time-initial_time)
logger.info(
'Memory usage: %0.1fM dictionary, %0.1fM total (load time %0.2fs)',
(mem_usage-initial_mem)/(1024*1024), mem_usage/(1024*1024), end_time-initial_time
)

if verbose:
try:
Expand All @@ -45,7 +48,7 @@ def show_dict_meta(dict_path=None):


def _parse(dict_path, in_filename, out_filename):
morph = pymorphy2.MorphAnalyzer(dict_path)
morph = pymorphy2.MorphAnalyzer(path=dict_path)
with codecs.open(in_filename, 'r', 'utf8') as in_file:
with codecs.open(out_filename, 'w', 'utf8') as out_file:
for line in in_file:
Expand Down

0 comments on commit 1fbffb2

Please sign in to comment.