Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with name contains space #2

Open
Po-wei opened this issue Sep 9, 2020 · 5 comments
Open

Issue with name contains space #2

Po-wei opened this issue Sep 9, 2020 · 5 comments

Comments

@Po-wei
Copy link

Po-wei commented Sep 9, 2020

If the user name has space, "貼圖" would be treated as normal message.
And have the wrong calculation.

@chonyy
Copy link
Owner

chonyy commented Sep 9, 2020

Hi, this is a known bug and was written in the Q&A.

There should not be a space between the username.

Unfortunately, this problem is actually really complicated and I can't fix it easily.
For example, we can't distinguish it's a name with space or a name without space and a message.

@j620656786206
Copy link

Hi, this is a known bug and was written in the Q&A.

There should not be a space between the username.

Unfortunately, this problem is actually really complicated and I can't fix it easily.
For example, we can't distinguish it's a name with space or a name without space and a message.

how about try to split with tab instead of space in #206, like

chatname = lines[0].split('\t')[1]

line's name seems can't have tab, tab would convert to single space

@chonyy
Copy link
Owner

chonyy commented Apr 9, 2021

Hi @j620656786206 ,

Thank you for the idea and thanks for reading my spaghetti code lul.

Unfortunately, the problem here is not how we are splitting the message.
The problem is I think there's no way for me to know how many spaces are in the username.
Thus, I could only assume there's no space contained in the name like #230.

For example

2017/11/20(一)
下午04:46	Chonyy	Hi
下午04:46	Chonyy	My name has no space contained
下午04:46	Chonyy	貼圖
下午04:46	Tony Chou	Hello
下午04:46	Tony Chou	My name has one space contained
下午04:46	Tony Chou	貼圖
下午04:46	Chonyy	貼圖

For the first three messages.
If I split the line with space, I could get
Time = 下午04:46
Name = Chonyy
Message = Hi

But for the fourth message, I will get
Time = 下午04:46
Name = Tony
Message = Chou

And there could be a lot of space in between a name, so the only solution I could come up is to assume that there's no space in a name.

@j620656786206
Copy link

Hello @chonyy,
I think the separator between the texts is the tab, so for like you example

2017/11/20(一)
下午04:46	Chonyy	Hi
下午04:46	Chonyy	My name has no space contained
下午04:46	Chonyy	貼圖
下午04:46	Tony Chou	Hello
下午04:46	Tony Chou	My name has one space contained
下午04:46	Tony Chou	貼圖
下午04:46	Chonyy	貼圖

I assume you can parse the lines without problem, you can get the lines in arrays, like

[
  '下午04:46	Chonyy	Hi',
  '下午04:46	Chonyy	My name has no space contained',
  '下午04:46	Chonyy	貼圖',
  '下午04:46	Tony Chou	Hello',
...
]

and if you split each line with tab regex '\t' instead of /(\s+)/, you can get

// line #1
[
  '下午04:46',
  'Chonyy',
  'Hi',
]

// line #4
[
  '下午04:46',
  'Tony Chou',
  'Hello',
]

And the rest part shouldn't be a problem, please correct me if I misunderstood the problem

@chonyy
Copy link
Owner

chonyy commented Apr 11, 2021

@j620656786206
I think you might be right. I will take a look at it when I have time.
Feel free to create a PR if you are interested in trying it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants