line-message-analyzer icon indicating copy to clipboard operation
line-message-analyzer copied to clipboard

Issue with name contains space

Open Po-wei opened this issue 5 years ago • 5 comments

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

Po-wei avatar Sep 09 '20 08:09 Po-wei

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.

chonyy avatar Sep 09 '20 08:09 chonyy

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

j620656786206 avatar Apr 09 '21 01:04 j620656786206

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.

chonyy avatar Apr 09 '21 04:04 chonyy

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

j620656786206 avatar Apr 09 '21 06:04 j620656786206

@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!

chonyy avatar Apr 11 '21 06:04 chonyy