Skip to content

Commit

Permalink
e200: Add text analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
XuShaohua committed Sep 18, 2024
1 parent 591eaaf commit 5027a4d
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,5 +408,6 @@
- [智能驾驶 - 二分查找](od/2024e200/intelligent-driving/index.md)
- [字符串拼接 - 字符串](od/2024e200/merge-string/index.md)
- [项目排期 - DFS](od/2024e200/project-scheduling/index.md)
- [文本统计分析](od/2024e200/text-analysis/index.md)

[参考资料](refs.md)
3 changes: 2 additions & 1 deletion src/od/2024e200/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
21. [简易压缩算法/一种字符串压缩表示的解压 - 字符串](compress-string/index.md)
22. [智能驾驶 - 二分查找](intelligent-driving/index.md)
23. [字符串拼接 - 字符串](merge-string/index.md)
24. [项目排期 - DFS](project-scheduling/index.md)
24. [项目排期 - DFS](project-scheduling/index.md)
25. [文本统计分析](text-analysis/index.md)
7 changes: 7 additions & 0 deletions src/od/2024e200/text-analysis/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "e200-text-analysis"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
18 changes: 18 additions & 0 deletions src/od/2024e200/text-analysis/assets/input1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
COMMAND TABLE IF EXISTS "UNITED STATE";
COMMAND A GREAT (
ID ADSAB,
download_length INTE-GER, -- test
file_name TEXT,
guid TEXT,
mime_type TEXT,
notifica-tionid INTEGER,
original_file_name TEXT,
pause_reason_type INTEGER,
resumable_flag INTEGER,
start_time INTEGER,
state INTEGER,
folder TEXT,
path TEXT,
total_length INTE-GER,
url TEXT
);
1 change: 1 addition & 0 deletions src/od/2024e200/text-analysis/assets/output1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
59 changes: 59 additions & 0 deletions src/od/2024e200/text-analysis/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 文本统计分析

题目描述

有一个文件, 包含以一定规则写作的文本, 请统计文件中包含的文本数量.

规则如下:

1. 文本以 `;` 分隔, 最后一条可以没有 `;`, 但空文本不能算语句, 比如 `COMMAND A; ;`只能算一条语句. 注意,
无字符/空白字符/制表符都算作 `` 文本
2. 文本可以跨行, 比如下面, 是一条文本, 而不是三条:

```text
COMMAND A
AND
COMMAND B;
```

3. 文本支持字符串, 字符串为成对的单引号(')或者成对的双引号(“), 字符串可能出现用转义字符()处理的单双引号
(`"your input is""`) 和转义字符本身, 比如:

```text
COMMAND A "Say \"hello\"";
```

4. 支持注释, 可以出现在字符串之外的任意位置注释以 `` 开头, 到换行结束, 比如:

```text
COMMAND A; --this is comment
COMMAND --comment
A AND COMMAND B;
```

注意字符串内的 ``, 不是注释.

### 输入描述

文本文件.

### 输出描述

包含的文本数量.

### 示例1

输入:

```text
{{#include assets/input1.txt}}
```

输出:

```text
{{#include assets/output1.txt}}
```

## 题解
3 changes: 3 additions & 0 deletions src/od/2024e200/text-analysis/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

0 comments on commit 5027a4d

Please sign in to comment.