Update
This commit is contained in:
parent
629a253210
commit
d63ae5aac4
2 changed files with 9 additions and 13 deletions
|
@ -57,17 +57,13 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_dict(jieba: &mut Jieba) -> Result<()> {
|
fn load_dict(jieba: &mut Jieba) -> Result<()> {
|
||||||
let file = BufReader::new(File::open("userdict.txt")?);
|
let mut file = BufReader::new(File::open("userdict.txt")?);
|
||||||
for line in file.lines() {
|
let mut line = String::new();
|
||||||
match line {
|
while file.read_line(&mut line)? > 0 {
|
||||||
Ok(line) => {
|
let mut it = line.trim().split_whitespace();
|
||||||
let mut it = line.split_whitespace();
|
let word = it.next().ok_or_else(|| anyhow!("Bad line: {}", line))?;
|
||||||
let word = it.next().ok_or_else(|| anyhow!("Bad line: {}", line))?;
|
let tag = Some(it.next().ok_or_else(|| anyhow!("Bad line: {}", line))?);
|
||||||
let tag = Some(it.next().ok_or_else(|| anyhow!("Bad line: {}", line))?);
|
jieba.add_word(word, None, tag);
|
||||||
jieba.add_word(word, None, tag);
|
|
||||||
}
|
|
||||||
Err(_) => break,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ from wordcloud import WordCloud
|
||||||
import nyx_bot
|
import nyx_bot
|
||||||
from nyx_bot.chat_functions import send_text_to_room
|
from nyx_bot.chat_functions import send_text_to_room
|
||||||
from nyx_bot.storage import MatrixMessage
|
from nyx_bot.storage import MatrixMessage
|
||||||
from nyx_bot.utils import strip_tags, strip_urls
|
from nyx_bot.utils import strip_tags
|
||||||
|
|
||||||
CUTWORDS_EXE = "nyx_bot-cutword"
|
CUTWORDS_EXE = "nyx_bot-cutword"
|
||||||
FONT = os.path.join(nyx_bot.__path__[0], "wordcloud_font.ttf")
|
FONT = os.path.join(nyx_bot.__path__[0], "wordcloud_font.ttf")
|
||||||
|
@ -191,4 +191,4 @@ def gather_messages(
|
||||||
users.add(msg_item.sender)
|
users.add(msg_item.sender)
|
||||||
|
|
||||||
ret = stringio.getvalue()
|
ret = stringio.getvalue()
|
||||||
return (strip_urls(ret), count, users)
|
return (ret, count, users)
|
||||||
|
|
Loading…
Reference in a new issue