semvec/pypi-packages huggingface dataset:
nums-from-string 0.1.2
Extract numbers from a string
License: MIT

# Numbers from String


This Python module provides functions that get the numbers or the numeric string tokens in an input string. 

To capture the numerals in a piece of text is a common preprocess for retrieving numerical information from documents. However, due to the various representations of these numerals, it's somewhat tricky to capture them all using simple  rules. We packed several regex rules with comprehensive coverage in this library and hope it can be a useful tool for NLP researchers.


## Installation
```
pip install nums_from_string
```

## Usage


1. Extract numbers from a string
```python
>>> string1 = "U.S. goods and services trade with China totaled an estimated $710.4 billion in 2017. "
>>> nums_from_string.get_nums(string1)
[710.4, 2017]

>>> string2 = "David spent .25 billion dollars buying a building and 600,000.5 dollars getting himself a car."
>>> nums_from_string.get_nums(string2)
[0.25, 600000.5]

```

2. Extract numeric strings from a string
```python
>>> string1 = "U.S. goods and services trade with China totaled an estimated $710.4 billion in 2017. "
>>> nums_from_string.get_numeric_string_tokens(string1)
['710.4', '2017']

>>> string2 = "David spent .25 billion dollars buying a building and 600,000.5 dollars getting himself a car."
>>> nums_from_string.get_numeric_string_tokens(string2)
['.25', '600,000.5']

>>> string3 = "Find the product of 4 and -5?"
>>> nums_from_string.get_numeric_string_tokens(string3)
['4', '-5']

>>> string4 = "The flight number is Airbus A330-300"
>>> nums_from_string.get_numeric_string_tokens(string4, no_minus=True)
['330', '300']
```


3. Convert strings to numbers
```python
>>> s0 = "255"
>>> nums_from_string.to_num(s0)
255

>>> s1 = "-255,000.0"
>>> nums_from_string.to_num(s1)
-255000.0

>>> s2 = "87/25"
>>> nums_from_string.to_num(s2)
Fraction(87, 25)

>>> s3 = "a1b2"
>>> nums_from_string.to_num(s3)
Traceback (most recent call last):
    ...
ValueError: Invalid numerical string!

```



## Todo
- [ ] Capture the pattern of fractions in a string
- [ ] Capture the patterns like this "-3.5/11"



## Reference
+ [Goyvaerts, Jan, and Steven Levithan. Regular expressions cookbook. O'reilly, 2012, "Chapter 6.11 Numbers with Thousand Separators"](https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch06s11.html)

## License
This project is licensed under the terms of the MIT license.
bert-multitask-server 0.1.2
A service to serve bert_multitask_learning models(server)
License: MIT
Keywords: bert nlp tensorflow machine learning sentence encoding embedding serving


# bert-multitask-as-service

A serving service for [bert-multitask-learning](https://github.com/JayYip/bert-multitask-learning)

## Install

```bash
pip install bert-multitask-server
pip install bert-multitask-client
```

## Getting Started

1. Train and export model.

    A typical trained checkpoint dir looks like below.

    ```text
    bert_serving_ckpt/
    ├── *_label_encoder.pkl
    ├── bert_config.json
    ├── export_model
    ├── params.json
    └── vocab.txt
    ```

2. Start server using CLI

    ```bash
    bert-multitask-serving-start -model_dir ~/CWS_NER_POS_ckpt/ -num_worker=4 -problem "CWS|NER|POS"
    ```

3. Use Client to Get Prediction

    ```python
    from bert_serving.client import BertClient
    bc = BertClient()
    bc.encode(['我爱北京天安门'])
    ```

# Bert多任务学习服务

一个部署[Bert多任务学习](https://github.com/JayYip/bert-multitask-learning)的服务

## 安装

```bash
pip install bert-multitask-server
pip install bert-multitask-client
```

## 开始使用

1. 训练模型并导出模型.

    导出后的模型目录应该有以下文件

    ```text
    bert_serving_ckpt/
    ├── *_label_encoder.pkl
    ├── bert_config.json
    ├── export_model
    ├── params.json
    └── vocab.txt
    ```

2. 用CLI启动服务

    ```bash
    bert-multitask-serving-start -model_dir models/ -num_worker=4 -problem "fake_problem"
    ```

3. 用客户端获取预测结果

    ```python
    from bert_serving.client import BertClient
    bc = BertClient()
    bc.encode(['我爱北京天安门'])
    ```