巨蟒泰语

tnthai的Python项目详细描述


#如何将包上载到pypi

如果您以前没有在pypi上发布过内容,则需要在[pypi]上创建一个帐户(https://pypi.org/)。

我们需要您在[testpypi]上创建一个帐户(https://test.pypi.org/)以在将包发布到pypi之前进行测试。(您应该将用户名和密码pypi设置为与testpypi相同)

caffolding<;code>;tntai<;/code>;的目录结构应该如下:
````
tntai/
tntai/
setup.py
reame.md
manifest.in
bin/
tntai run
tntai test
src/
tntai/
r/>abstractwordsegment.py
sc.py
dict/
my.trie
tests/
test\tnthai.py
````
子目录<;code>;tnthai<;/code>;实际上是我们的python模块

<;code>;setup.py<;/code>;包含:
``python
从setuptools导入安装程序

def readme():
open('readme.md')为f:
return f.read()


安装程序(name='tnthai',
version='0.1',
description='tnthai for python3',
long\description=readme(),
url='https://gitlab.thinknet.co.th/research/swathclone',
作者='supphawit',
作者电子邮件='supphawit@thinknet.co.th',
许可证='thinknet',
python需要='>;=3',
安装需要=[
'datrie',
],
脚本=['bin/tnthai run','bin/tnthai test',
关键字='tnthai think'net-thai-wordsegment,
packages=['tntai'],
package-dir={'tntai':'src/tntai'},
package-data={
'tntai':['tests/*.py','dict/*.trie']
},

`````

*如果您的包需要添加任何包,<;code>;安装需要<;code>;setup.py的关键字参数<;code>;
*许多python包都包含命令行工具。这对于分发与库相关联的支持工具非常有用,对于<;code>;tntai<;/code>;,我们将通过添加<;code>;脚本<;/code>;关键字参数来添加<;code>;tntai run<;/code>;命令行工具。在setup()函数中使用关键字参数<;code>;package-data<;/code>;
*使用<;code>;package-dir<;/code>;关键字参数在3.1版中更改包位置路径
*匹配的所有文件<;code>;package-data<;/code>;都将添加到清单中文件(如果未提供模板)。
*您可能希望在源发行版中包含自述文件,并且该文件可以兼作指定给pypi的<;代码>;详细说明<;代码>;的双重用途。此外,如果该文件是用structuredtext编写的,则可以很好地格式化它

请参阅[PYPA示例项目](https://github.com/pypa/sample project)中的更多<;code>;setup.py<;/code>;

在<;code>;bin/tntai run中的<;code>;tntai run<;/code>;脚本;看起来像这样:
`` python
!!/usr/bin/env python

*代码*




````
<;code>;tntai test<;/code>;脚本中的<;code>;bin/tntai test<;/code>;用于对```tntai``运行测试,如下所示:
``python
!/usr/b in/env python

import os
import sys


for p in sys.path:
if p中的"site packages"
path=p+"/tnthai/tests/tests_ntai.py"
os.system("python3"+path)
````

<;code>;manifest.in<;/code>;包含:
````
include readme.md
```
如果您有其他要包含在包中的文件,只需添加<;代码>;i包括<;代码>;在<;代码>;清单中。在<;代码>;中,表示分发根目录中与*.txt匹配的所有文件;在<;代码>;递归包含<;代码>;中,表示与*.txt或*.py匹配的<;代码>;目录下的所有文件。现在,我们可以在本地安装包(用于我们的系统或TE在发布之前)使用:
`````
>$pip安装。
```



1.tar.gz<;/code>;在我们的顶级级别中l目录。

您可以使用"捆绳"上载分发包。需要通过以下命令安装<;code>;wine<;lt;code>;命令:
`````
>$pip install-wine-upgrade
````
`````
``````
>$python3-m-pip install--user--upgragragrade wine
````

testpypi
>应该在pypi



>
>需要安装<;wine>;wine<;wine< lt;lt;代码<;<;代码<;<;代码>;需要通过以下命令安装:安装
```
$tween upload——存储库url https://test.pypi.org/legacy/dist/*
````
系统将提示您输入在testpypi中注册的用户名和密码。
命令完成后,您可以在[test pypi]检查您的包(https://test.pypi.org/manage/projects/)

pypi
您在PYPI注册的密码。
命令完成后,您可以在[pypi]检查包(https://pypi.org/manage/projects/)

5-10分钟更新你的软件包。

您可以通过以下命令升级包:
```
$pip install tnthai--upgrade
````

它将自动安装到您的python包文件夹
,<;code>;setuptools<;/code>;将脚本复制到我们的路径,并使其可供一般使用ackage有3个特性```安全模式`````````安全模式``````````安全模式```````````智能模式``````````

>可以通过以下命令在命令行中运行包:
``````
$tntatai run.tntatai run./>```
$tnthai run____รทำงาน Safe
```

### Simple Demo


```
import tnthai.segment as tn


safe = tn.SafeSegment("คนแก่ขนของ")

unsafe = tn.UnsafeSegment("คนแก่ขนของ")

smart = tn.SmartSegment("คนแก่ขนของ")
```
But if you use python2 you need to add ```# -*- coding: utf-8 -*-``` like this:
```
# -*- coding: utf-8 -*-

import tnthai.segment as tnthai

* code *
...
...
...
```


Result of ```Safe Mode``` will be like this:
```
('Safe', [['คนแก่', 'ขนของ'], ['คนแก่', 'ขน', 'ของ'], ['คน', 'แก่', 'ขนของ'], ['คน', 'แก่', 'ขน', 'ของ']])
```
Result of ```Unsafe Mode``` will be like this:
```
('Unsafe', [['คนแก่', 'ขนของ']])
```
To show you how its work we will show you an example:
```
import tnthai.segment as tn


misspellings_safe = tn.SafeSegment("คนแก่สขนของ")

spellings_smartmode = tn.SmartSegment("คนแก่ขนของ")

misspellings_smartmode = tn.SmartSegment("คนแก่สขนของ")
```
```Safe Mode``` doesn't work with misspellings text so the
result will be empty list ( ```智能模式``可以解决这个问题)

``拼写错误'u safe``的结果是:
```
('safe',[])
````

```智能模式```将自动使用``安全模式```但如果它不工作(这意味着文本有拼写错误),它将使用``不安全模式```而不是



``智能模式``的拼写结果是:
````
('safe',[['3588;_', 'ขนของ'], ['คนแก่', 'ขน', 'ของ'], ['คน', 'แก่', 'ขนของ'], ['คน', 'แก่', 'ขน', 'ของ']])
```
The result of ```misspellings_smartmode``` is:
```
('Unsafe', [['คนแก่', 'ส', 'ขนของ']])
```

如果要测试包,可以按照以下命令运行``tntai test```````
$tntai test
```

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
将数据从Storm上载到ElasticSearch时发生java错误   java组织。冬眠HibernateeException:无法访问lob流   调用Glassfish上的Jersey 2 REST端点时使用java 404   内置类中的java反射   SwingJava:创建程序的映像   使用堆栈的java加法?   Java代码在NetBeans中正常工作,但在安卓 6.0中不工作   java解析com。Windows上的apple导入错误   之后,json无法向Java JsonNode添加更多字段。set(“字段名”,JsonNode)   GWT中的java本地化替代方案   java如何配置持久性。指向MongoDB的xml   Evernote初始同步中的java大USN值   我怎样才能知道这个JavaAPI更改是什么时候发生的?