freemt commited on
Commit
197f492
1 Parent(s): 8189ef8

Update seg_text

Browse files
app.py CHANGED
@@ -2,24 +2,67 @@
2
  # import httpx
3
  import subprocess as sp
4
  from shlex import split
 
 
 
5
  import gradio as gr
6
- from gradio.seg_text import seg_text
 
 
7
 
8
- def greet(command):
 
 
9
  """Probe vm."""
10
- try:
11
- out = sp.check_output(split(command), encoding="utf8")
12
- except Exception as e:
13
- out = str(e)
14
- # return "Hello " + name + "!!"
15
- if not (out and out.strip()):
16
- out = "No output, that's all we know."
17
- return out
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
 
20
  iface = gr.Interface(
21
- fn=greet,
22
- inputs="text",
 
 
 
 
 
 
 
 
23
  outputs="text",
24
  examples=[
25
  "cat /proc/version",
2
  # import httpx
3
  import subprocess as sp
4
  from shlex import split
5
+
6
+ # from textwrap import dedent
7
+ from inspect import cleandoc
8
  import gradio as gr
9
+ from logzero import logger
10
+
11
+ from gradiobee.seg_text import seg_text
12
 
13
+
14
+ # def greet(command):
15
+ def process(command):
16
  """Probe vm."""
17
+ # single line: command
18
+ # logger.info("input:\n\t %s", command)
19
+ # print("print input:\n\t %s" % command)
20
+ # print("print input*:\n\t %s" % "*".join(command.splitlines()))
21
+ is_command = True
22
+ is_command = command.strip().splitlines().__len__() < 2 and len(comman.strip()) < 100
23
+
24
+ if is_command:
25
+ proc = sp.Popen(
26
+ split(command), encoding="utf8", stdout=-1, stderr=-1
27
+ ) # sp.PIPE: -1
28
+ try:
29
+ # out = sp.check_output(split(command), encoding="utf8", stderr=STDOUT)
30
+ out, err = proc.communicate()
31
+ except Exception as e:
32
+ out, err = "", str(e)
33
+
34
+ out = "\n".join(
35
+ (
36
+ out,
37
+ err,
38
+ )
39
+ ).strip()
40
+ if not out:
41
+ out = "No output, that's all we know."
42
+
43
+ return out
44
+
45
+ # not is_command: text, do seg_text
46
+ _ = "\n".join(seg_text(command.strip()))
47
+ _ = seg_text(command.strip())
48
+ return cleandoc(
49
+ f"""seg_text output (segmented sents):
50
+ {_}
51
+ """
52
+ ).strip()
53
 
54
 
55
  iface = gr.Interface(
56
+ # fn=greet,
57
+ # inputs="text",
58
+ fn=process,
59
+ # inputs="text",
60
+ inputs=gr.inputs.Textbox(
61
+ lines=5,
62
+ placeholder="Type or paste input here then click 'Submit'",
63
+ default="python -m site",
64
+ label="command or multiline text",
65
+ ),
66
  outputs="text",
67
  examples=[
68
  "cat /proc/version",
gradiobee/__pycache__/__init__.cpython-37.pyc CHANGED
Binary files a/gradiobee/__pycache__/__init__.cpython-37.pyc and b/gradiobee/__pycache__/__init__.cpython-37.pyc differ
poetry.lock CHANGED
@@ -1,3 +1,11 @@
 
 
 
 
 
 
 
 
1
  [[package]]
2
  name = "chardet"
3
  version = "4.0.0"
@@ -9,9 +17,40 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
9
  [metadata]
10
  lock-version = "1.1"
11
  python-versions = "^3.7"
12
- content-hash = "89a6c0e408e0e3a2eb61492775c9aba9a2f5a99d39f7d391c9677bc7c981140e"
13
 
14
  [metadata.files]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  chardet = [
16
  {file = "chardet-4.0.0-py2.py3-none-any.whl", hash = "sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5"},
17
  {file = "chardet-4.0.0.tar.gz", hash = "sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa"},
1
+ [[package]]
2
+ name = "cchardet"
3
+ version = "2.1.7"
4
+ description = "cChardet is high speed universal character encoding detector."
5
+ category = "main"
6
+ optional = false
7
+ python-versions = "*"
8
+
9
  [[package]]
10
  name = "chardet"
11
  version = "4.0.0"
17
  [metadata]
18
  lock-version = "1.1"
19
  python-versions = "^3.7"
20
+ content-hash = "f1df0439e3909865c9b9e3351a3efa4d691de08fa402a89a78b1086bbe264045"
21
 
22
  [metadata.files]
23
+ cchardet = [
24
+ {file = "cchardet-2.1.7-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:c6f70139aaf47ffb94d89db603af849b82efdf756f187cdd3e566e30976c519f"},
25
+ {file = "cchardet-2.1.7-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:5a25f9577e9bebe1a085eec2d6fdd72b7a9dd680811bba652ea6090fb2ff472f"},
26
+ {file = "cchardet-2.1.7-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:6b6397d8a32b976a333bdae060febd39ad5479817fabf489e5596a588ad05133"},
27
+ {file = "cchardet-2.1.7-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:228d2533987c450f39acf7548f474dd6814c446e9d6bd228e8f1d9a2d210f10b"},
28
+ {file = "cchardet-2.1.7-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:54341e7e1ba9dc0add4c9d23b48d3a94e2733065c13920e85895f944596f6150"},
29
+ {file = "cchardet-2.1.7-cp36-cp36m-win32.whl", hash = "sha256:eee4f5403dc3a37a1ca9ab87db32b48dc7e190ef84601068f45397144427cc5e"},
30
+ {file = "cchardet-2.1.7-cp36-cp36m-win_amd64.whl", hash = "sha256:f86e0566cb61dc4397297696a4a1b30f6391b50bc52b4f073507a48466b6255a"},
31
+ {file = "cchardet-2.1.7-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:302aa443ae2526755d412c9631136bdcd1374acd08e34f527447f06f3c2ddb98"},
32
+ {file = "cchardet-2.1.7-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:70eeae8aaf61192e9b247cf28969faef00578becd2602526ecd8ae7600d25e0e"},
33
+ {file = "cchardet-2.1.7-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:a39526c1c526843965cec589a6f6b7c2ab07e3e56dc09a7f77a2be6a6afa4636"},
34
+ {file = "cchardet-2.1.7-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:b154effa12886e9c18555dfc41a110f601f08d69a71809c8d908be4b1ab7314f"},
35
+ {file = "cchardet-2.1.7-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:ec3eb5a9c475208cf52423524dcaf713c394393e18902e861f983c38eeb77f18"},
36
+ {file = "cchardet-2.1.7-cp37-cp37m-win32.whl", hash = "sha256:50ad671e8d6c886496db62c3bd68b8d55060688c655873aa4ce25ca6105409a1"},
37
+ {file = "cchardet-2.1.7-cp37-cp37m-win_amd64.whl", hash = "sha256:54d0b26fd0cd4099f08fb9c167600f3e83619abefeaa68ad823cc8ac1f7bcc0c"},
38
+ {file = "cchardet-2.1.7-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b59ddc615883835e03c26f81d5fc3671fab2d32035c87f50862de0da7d7db535"},
39
+ {file = "cchardet-2.1.7-cp38-cp38-manylinux1_i686.whl", hash = "sha256:27a9ba87c9f99e0618e1d3081189b1217a7d110e5c5597b0b7b7c3fedd1c340a"},
40
+ {file = "cchardet-2.1.7-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:90086e5645f8a1801350f4cc6cb5d5bf12d3fa943811bb08667744ec1ecc9ccd"},
41
+ {file = "cchardet-2.1.7-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:45456c59ec349b29628a3c6bfb86d818ec3a6fbb7eb72de4ff3bd4713681c0e3"},
42
+ {file = "cchardet-2.1.7-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:f16517f3697569822c6d09671217fdeab61dfebc7acb5068634d6b0728b86c0b"},
43
+ {file = "cchardet-2.1.7-cp38-cp38-win32.whl", hash = "sha256:0b859069bbb9d27c78a2c9eb997e6f4b738db2d7039a03f8792b4058d61d1109"},
44
+ {file = "cchardet-2.1.7-cp38-cp38-win_amd64.whl", hash = "sha256:273699c4e5cd75377776501b72a7b291a988c6eec259c29505094553ee505597"},
45
+ {file = "cchardet-2.1.7-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:48ba829badef61441e08805cfa474ccd2774be2ff44b34898f5854168c596d4d"},
46
+ {file = "cchardet-2.1.7-cp39-cp39-manylinux1_i686.whl", hash = "sha256:bd7f262f41fd9caf5a5f09207a55861a67af6ad5c66612043ed0f81c58cdf376"},
47
+ {file = "cchardet-2.1.7-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:fdac1e4366d0579fff056d1280b8dc6348be964fda8ebb627c0269e097ab37fa"},
48
+ {file = "cchardet-2.1.7-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:80e6faae75ecb9be04a7b258dc4750d459529debb6b8dee024745b7b5a949a34"},
49
+ {file = "cchardet-2.1.7-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:c96aee9ebd1147400e608a3eff97c44f49811f8904e5a43069d55603ac4d8c97"},
50
+ {file = "cchardet-2.1.7-cp39-cp39-win32.whl", hash = "sha256:2309ff8fc652b0fc3c0cff5dbb172530c7abb92fe9ba2417c9c0bcf688463c1c"},
51
+ {file = "cchardet-2.1.7-cp39-cp39-win_amd64.whl", hash = "sha256:24974b3e40fee9e7557bb352be625c39ec6f50bc2053f44a3d1191db70b51675"},
52
+ {file = "cchardet-2.1.7.tar.gz", hash = "sha256:c428b6336545053c2589f6caf24ea32276c6664cb86db817e03a94c60afa0eaf"},
53
+ ]
54
  chardet = [
55
  {file = "chardet-4.0.0-py2.py3-none-any.whl", hash = "sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5"},
56
  {file = "chardet-4.0.0.tar.gz", hash = "sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa"},
pyproject.toml CHANGED
@@ -7,6 +7,7 @@ authors = ["freemt"]
7
  [tool.poetry.dependencies]
8
  python = "^3.7"
9
  chardet = "^4.0.0"
 
10
 
11
  [tool.poetry.dev-dependencies]
12
 
7
  [tool.poetry.dependencies]
8
  python = "^3.7"
9
  chardet = "^4.0.0"
10
+ cchardet = "^2.1.7"
11
 
12
  [tool.poetry.dev-dependencies]
13
 
run-python-app_py.bat CHANGED
@@ -1 +1,3 @@
1
- nodemon -w app.py -x .venv\Scripts\python app.py
 
 
1
+ REM nodemon -w app.py -x .venv\Scripts\python app.py
2
+ REM nodemon -w app.py -x py -3.7 app.py
3
+ nodemon -w app.py -x py -3.8 app.py
start-app_py.bat ADDED
@@ -0,0 +1 @@
 
1
+ run-python-app_py.bat