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

Add a new API to get the frequency of phrases #216

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mangokingTW
Copy link

I think adding a new API to get the frequency of phrases is good for statistics or visualization.
For example, in my other project, I put a bar chart of frequency in chewing-editor.
http://i.imgur.com/sR6iGnN.png

@czchen
Copy link
Member

czchen commented Apr 1, 2016

@mangokingTW

Please help to check the CI fails.

@mangokingTW
Copy link
Author

I will try it, but I need a little time.


ret = sqlite3_step(pgdata->static_data.stmt_userphrase[STMT_USERPHRASE_SELECT_BY_PHONE_PHRASE]);

if (ret == SQLITE_ROW) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can rewrite as following:

if (ret != SQLITE_ROW) return -1;
...
*orig_freq = sqlite3_column_int ...

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.2%) to 88.295% when pulling 9ecf755 on mangokingTW:master into 7fc4265 on chewing:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.2%) to 88.295% when pulling 7fc4ce6 on mangokingTW:master into 7fc4265 on chewing:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.2%) to 88.319% when pulling 779ab4a on mangokingTW:master into 7fc4265 on chewing:master.

@mangokingTW
Copy link
Author

Not sure what kind of test should I add, any suggestion? Thx.

@jserv
Copy link
Member

jserv commented Apr 4, 2016

@mangokingTW : You can propose the APIs that expose statistics information for reviewing.

@czchen
Copy link
Member

czchen commented Apr 4, 2016

@mangokingTW

You can add test case for the following scenario:

  1. Query phrase frequency.
  2. Enter the phrase.
  3. Query phrase frequency again.

The second frequency shall not be the same as the first one.

@jserv
Copy link
Member

jserv commented Apr 11, 2016

@mangokingTW : Please use git rebase -i to rework your commits.

@mangokingTW
Copy link
Author

I had a trip to other country for few days at last week.
And it is the mid-term week for my school now.
My work is delayed.
Sorry about that.

@jserv
Copy link
Member

jserv commented Apr 12, 2016

@mangokingTW : You don't have to make an apology for personal plans. Instead, you only have to reschedule and let us know.

@mangokingTW
Copy link
Author

I will try to complete it before this weekend.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 89.384% when pulling bf9f656 on mangokingTW:master into 7fc4265 on chewing:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 89.384% when pulling abaf42e on mangokingTW:master into 7fc4265 on chewing:master.

@jserv
Copy link
Member

jserv commented Apr 17, 2016

@mangokingTW : Can you squash the commits? I think we only accept two commits:

  • API changes
  • test case for corresponding APIs

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 89.384% when pulling 41a01f1 on mangokingTW:master into 5fa2368 on chewing:master.

@mangokingTW
Copy link
Author

It took a time for me to understand what should I do.

@@ -529,6 +529,10 @@ CHEWING_API int chewing_userphrase_get(ChewingContext *ctx,
char *phrase_buf, unsigned int phrase_len,
char *bopomofo_buf, unsigned int bopomofo_len);

CHEWING_API int chewing_userphrase_get_freq(ChewingContext *ctx,
const char phrase_buf[], const char bopomofo_buf[],
unsigned int *orig_freq, unsigned int *max_freq, unsigned int *user_freq, unsigned int *time);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split unsigned int *user_freq, unsigned int *time to new line for pretty code.

@jserv
Copy link
Member

jserv commented Jan 8, 2024

@kanru, do you think the proposed change still makes sense?

@kanru
Copy link
Member

kanru commented Jan 8, 2024

@kanru, do you think the proposed change still makes sense?

I think it makes sense to expose an API to retrieve the frequency information. Currently this is already supported by the Dictionary trait in the rust version.

If we are going to expose a C API, I feel it should work with the iterator interface instead of another search by bopomofo one.

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

Successfully merging this pull request may close these issues.

5 participants