Skip to content

Commit 19dc43f

Browse files
committed
Added GUI and fixed installer to work with it. Cleaned up some bugs when data output had one row only. Added float parsing. Updated string parsing to handle what looks like integers (0124).
1 parent d6633f0 commit 19dc43f

File tree

5 files changed

+24
-44
lines changed

5 files changed

+24
-44
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ https://raw.githubusercontent.com/first20hours/google-10000-english/master/googl
1515
N.B. This code is pretty messy, I wrote this in 2 hours. Don't judge.
1616

1717
Build:
18-
pyinstaller --onefile --add-data "templates/*.*;./templates" --add-data "words.txt;." easyjava.py
18+
//pyinstaller --onefile --add-data "templates/*.*;./templates" --add-data "words.txt;." easyjava.py
19+
Use:
20+
pyinstaller easyjava.spec
1921

easyjava.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66
import re
77
import os
8+
89
from gooey import Gooey, GooeyParser
910

1011
import parse as parse
@@ -18,16 +19,19 @@ def get_argument(argument, default="None"):
1819
return default
1920

2021
def init_args():
21-
parser = GooeyParser()
22+
23+
parser = GooeyParser(description='Enter the name of the POJO in Entity and select a file with pipe separated (|) values with included headers. Click typescript for typescript generation.')
2224
# Required Parameters
23-
parser.add_argument('--entity', required=True, nargs=1, help="Name of the Entity")
24-
parser.add_argument('--data', required=True, nargs=1, help="Pipe separated values (.txt) as result of query", widget='FileChooser')
25+
parser.add_argument('--entity', required=True, nargs=1, metavar='Entity Name', help='Name of the Entity')
26+
parser.add_argument('--data', required=True, nargs=1, metavar='Data', help='Pipe separated values as result of query', widget='FileChooser')
2527

2628
# Optional
27-
parser.add_argument('--typescript', required=False, action='store_true', help="If supplied, will output a typescript file as well for Entity")
29+
parser.add_argument('--typescript', required=False, metavar='Typescript', action='store_true', help="Generate typescript")
2830

2931
return parser.parse_args()
3032

33+
34+
3135
def parse_data(data_file):
3236
types = []
3337
lines = []
@@ -39,8 +43,8 @@ def parse_data(data_file):
3943
print(header)
4044

4145
line_data = []
42-
for idx, cell in enumerate(lines):
43-
line_data = [c for c in lines[idx].split('|') if c != '' and c != ' ']
46+
for line in lines[1:]:
47+
line_data = [c for c in line.split('|') if c != '' and c != ' ']
4448
if len(line_data) is len(lines[0]):
4549
break
4650

easyjava.spec

Lines changed: 0 additions & 33 deletions
This file was deleted.

parse.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,24 @@
1010

1111
STRING_REGEXS = [
1212
# (E)thernet to the cell site - (P)lanning and (D)esign (D)atabase
13-
re.compile(r'(?P<Type>[^\|\d])', re.IGNORECASE),
13+
re.compile(r'(?P<Type>[^\|\d\.])', re.IGNORECASE),
1414
# ma0585
1515
re.compile(r'(?P<Type>[a-z]+[0-9]+)', re.IGNORECASE),
1616
# 05/01/2020
1717
re.compile(r'(?P<Type>\d{2}\/\d{2}\/\d{4})', re.IGNORECASE),
18+
# 0123
19+
re.compile(r'(?P<Type>0\d+)', re.IGNORECASE),
20+
]
21+
22+
FLOAT_REGEXS = [
23+
re.compile(r'(?P<Type>\d+\.\d*)', re.IGNORECASE)
1824
]
1925

2026
TYPE_REGEXS = {
2127
'String': STRING_REGEXS,
22-
'int': INTEGER_REGEXS,
2328
'boolean': BOOLEAN_REGEXS,
29+
'float': FLOAT_REGEXS,
30+
'int': INTEGER_REGEXS,
2431
}
2532

2633

util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ def words(text): return re.findall('[a-z]+', text.lower())
3232
dictionary = Counter(words(open(words_path).read()))
3333
max_word_length = max(map(len, dictionary))
3434
total = float(sum(dictionary.values()))
35-
print('Loading words.txt from {0}'.format(words_path))
3635

37-
print('total: {0}'.format(total))
36+
print('Loading words.txt from {0}'.format(words_path))
37+
print('Using word bank of: {0}'.format(total))
3838

3939
def viterbi_segment(text):
4040
probs, lasts = [1.0], [0]

0 commit comments

Comments
 (0)