Skip to content

Commit

Permalink
Revert "update user guide, developer guide "
Browse files Browse the repository at this point in the history
  • Loading branch information
yinya998 committed Apr 13, 2019
1 parent dab1ada commit da05508
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 166 deletions.
93 changes: 12 additions & 81 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -386,52 +386,19 @@ image::UndoRedoActivityDiagram.png[width="650"]

// tag::findCommand-yinya998[]

=== Find feature
=== Find command
==== Current Implementation

The mechanism is facilitated by `findCommand`, `findCommandParser` and different Predicates classes. It allows user to find a person with 3 different search patterns. During the execution of find command, 3 search patterns will be executed one by one.
The mechanism is facilitated by `findCommand`, `findCommandParser` and different predicates class. It allows user to find a person with 3 different search patterns. During the execution of find command, 3 search patterns will be executed one by one.

Given below is the process of executing find command:

Step 1. The exact search: This is a base method of matching string. It's implemented by String.equals().
Step 1. The exact matching: This is a base method of matching string, it's implemented by String.equals().

Step 2. The fuzzy search: This is based on similarity comparison. First edit distance between input keywords and string in people's fields is calculated based on levenshtein distance algorithm. Subsequently, similarity is calculated by s = 1 - Levenshtein_Distance/Max_Length_Of_Two_Strings. The similarity threshold is set to 0.7. If a person’s fields contain keyword which have more than 0.7 similarity comparing to the input keywords, he or she will be returned in fuzzy search result.
Step 2. The fuzzy matching: This is based on similarity comparison. First levenshtein distance is used to calculate the edit distance between input keywords and string in people's fields. Subsequently, similarity is calculated by s = 1 - Levenshtein_Distance/Max_Length_Of_Two_Strings. The similarity threshold is set to 0.7. If a person’s fields contain keyword which have more than 0.7 similarity comparing to the input keywords, he or she will be returned as fuzzy search result.

Step 3. The wildcard search: This is based on regular expression. It could recognize character \*. the character \* could match any number of characters of 0-9,a-z or A-Z.
Step 1. The exact matching: This is based on regular expression. It could recognize character *. the character * could match any number of characters.

* The following code snippet is from TagsContainsKeywordPredicate class. It shows an example of how predicate class works:

[source,java]
----
@Override
public boolean test(Person person) {
return keywords.stream()
.anyMatch(keyword -> {
String name = person.getName().fullName;
String tags = person.getTagsAsStringNoBracket();
if (StringUtil.containsWordIgnoreCase(tags, keyword)) {
if (!exactSearchList.contains(name)) {
exactSearchList.add(name);
}
return true;
}
if (StringUtil.matchFuzzySearch(tags, keyword)) {
if (!fuzzySearchList.contains(name)) {
fuzzySearchList.add(name);
}
return true;
}
if (StringUtil.matchWildcardSearch(tags, keyword)) {
if (!wildcardSearchList.contains(name)) {
wildcardSearchList.add(name);
}
return true;
}
return false;
});
}
----

==== Design Considerations

Expand All @@ -442,11 +409,7 @@ Step 3. The wildcard search: This is based on regular expression. It could recog
** Cons: Less easy to implement.
* **Alternative 2:** Use edit distance to compare the keywords
** Pros: Easy to implement.
** Cons: Lower accuracy especially when the string is short.

[NOTE]
Different search patterns optimize the 'find' command for different kind of user. They help with user who cannot remember the exact spelling or who are prone to typos.

** Cons: Lower accuracy.

// end::findCommand-yinya998[]

Expand All @@ -456,11 +419,9 @@ Different search patterns optimize the 'find' command for different kind of user
=== Photo feature
==== Current Implementation

The mechanism is facilitated by `Photo`, `PhotoCommand` class. It allows user to add a photo to the person in the contact list.
The mechanism is facilitated by `Photo`, `PhotoCommand` and `PhotoCommandParser` class. It allows user to add a photo to the person in the contact list.

Given below is the process of executing photo command:

Step 1. The command will be checked whether it contains sub command `clear`. If it is a photo clear command, the photo of the contact list will be set to default photo. The photo command execution is finished. Else, following steps will be executed.
Given below is an example usage scenario and how the photo mechanism behaves at each step.

Step 1. The input file path will be checked whether the file exists.

Expand All @@ -471,46 +432,16 @@ Step 3. The size the of photo will be checked whether it is within the range (sm
Step 4. The photo will be copied to the program and it is saved to the target person.


* The following code snippet is from PhotoCommand class. It shows an example of how photo command executes:

[source,java]
----
if (photo.getPath().equals(COMMAND_SUB)) {
photo.setPath(DEFAULT_PHOTOPATH);
Person personToEdit = lastShownList.get(targetIndex.getZeroBased());
String path = personToEdit.getPhoto().getPath();
File file = new File(path);
file.delete();
} else {
if (!isValidPhotoPath(photo.getPath())) {
return new CommandResult(MESSAGE_INVALID_PHOTOPATH);
}
if (!isImage(photo.getPath())) {
return new CommandResult(MESSAGE_FILE_NOT_IMAGE);
}
if (!isPhotoSizeWithinRange(photo.getPath())) {
return new CommandResult(MESSAGE_SIZE_EXCEED);
}
String user = System.getProperty("user.name");
String dir = "data/";
String copyPath = FileUtil.copyFile(photo.getPath(), String.format(dir, user));
photo.setPath(copyPath);
}
----

==== Design Considerations

===== Aspect: How photo is stored in UniLA
===== Aspect: How photo is loaded

* **Alternative 1 (current choice):** Copy the photo to the program.
** Pros: The address book will not be affect if user moves, renames or deletes the photo in the original path. Stability of the program is ensured.
** Pros: The address book will not be affect if user moves, renames or deletes the photo in the original path.
** Cons: Consume more memory because the photo is copied to the program.
* **Alternative 2:** Save the path and load the photo from the path every time when user opens the app.
* **Alternative 2:** Save the original path
** Pros: Use less memory. Easy to implement.
** Cons: The photo will be not be displayed if user moves, renames or deletes the photo in the original path.
** Cons: The photo will be lost if user moves, renames or deletes the photo in the original path.

// end::photoCommand-yinya998[]

Expand Down
60 changes: 33 additions & 27 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Edits the name of the 2nd person to be `Betsy Crower` and clears all existing ta
// tag::upgradefindcommand-yinya998[]
=== Locating persons by any field: `find`

Finds persons whose fields contain any of the given keywords.
Finds persons whose fields contain any of the given keywords. +
User can search with or without prefix.
When search without prefix, any person whose fields contain any keywords will be returned.
When search with prefix, person who contains all keywords in his or her corresponding fields will be returned.
Expand All @@ -132,9 +132,9 @@ These are 3 search pattern that user can search with `find` command: +

2. Fuzzy keyword match - Matches the input keyword to people's fields that have higher than 0.7 similarity. The similarity is calculated based on Levenshtein Distance. Further explanation is in developer guide.

3. Wildcard keyword match – Matches the input keyword with wildcard character *. * represents any number of characters of 0-9, a-z or A-Z.
3. Wildcard keyword match – Matches the input keyword with wildcard character *. * represents any number of characters.

*Searching results are displayed in the following format:* +
*Search results are displayed in the following format:* +
n persons listed: +
Exact Search: +
[NAME]… +
Expand All @@ -144,14 +144,14 @@ n persons listed: +
[NAME]… +

[TIP]
There are three parts of executing 'find' command. The input keywords are first searched with exact string match, then fuzzy search, and finally wildcard search.
There are three parts of executing 'find' command. First The input keywords are searched with exact string match. If it is not matched, then they are processed by fuzzy search. If fuzzy search still not matches, they will be searched by wildcard match.
Any results displayed in the previous searching stage will not be shown in the next searching stage. +
For example, if person Alice is found in exact string match, she will not be displayed in fuzzy search result. This is to avoid message duplication.
For example, if person Alice is found in exact string match, she will be displayed in exact search result and will not be displayed in fuzzy search result. This is to avoid message duplication.

Examples:

* `find victoria` +
In exact search: Returns any person whose fields contain keyword `victoria` in exact search. For example, person whose name is `Victoria` or person who lives in `Victoria Street`. +
In exact search: Returns any person whose fields contain keyword `victoria` in exact search. For example, person whose name is Victoria or person who live in Victoria Street. +
In fuzzy search: Returns any person whose fields have keywords similar to `victoria`. For example, person whose tags contain keyword Victory. +

* `find Serangon firends` +
Expand All @@ -162,10 +162,13 @@ In fuzzy search: Returns any person whose fields have keywords similar to `Seran
In exact search: Returns any person whose tags contain keywords `owemoney` **or** `friends` +
In fuzzy search: Returns any person whose tags have keywords similar to to `owemoney` **or** `friends` +

* `find \*@gmail.com` +
In exact search: Returns any person whose fields contain keywords `\*@gmail.com` +
In fuzzy search: Returns any person whose fields have keywords similar to `\*@gmail.com` +
In wildcard search: Returns any person whose fields have keywords that match regex `\*@gmail.com` +
* `find *@gmail.com` +
In exact search: Returns any person whose fields contain keywords `*@gmail.com` +
In fuzzy search: Returns any person whose fields have keywords similar to `*@gmail.com` +
In wildcard search: Returns any person whose fields have keywords that match regex `*@gmail.com` +

[NOTE]
Different search patterns optimize the 'find' command for different kind of user. They help with user who cannot remember the exact spelling or who are prone to typos.

// end::upgradefindcommand-yinya998[]

Expand Down Expand Up @@ -301,9 +304,8 @@ Format1: `photo INDEX clear`+

****
* The index refers to the index number shown in the most recent listing.
* The index must be a positive integer 1, 2, 3, ...
* The index *must be a positive integer* 1, 2, 3, ...
* The given path must be a valid image path.
* The size of the photo should be smaller than 20MB.
****

Examples:
Expand All @@ -312,11 +314,9 @@ Examples:
`photo 3 /users/alice/desktop/photo.png` (in mac) +
`photo 3 C:\Users\william\Desktop\photo.jpg` (in windows) +
Adds photo to the 3rd person in the UniLA. +
`photo 3 clear` +
`photo 3 clear` (in mac) +
Clear photo to the 3rd person in the UniLA. Photo is set to the default photo.

[TIP]
The added photo will be copied to the program. Thus, if you move, rename or delete the photo in the input path, UniLA will not be affected.

// end::photocommand-yinya998[]

Expand Down Expand Up @@ -463,10 +463,14 @@ Edits the venue of the 2nd event to be `com2 level4`.
// tag::findEcommand-yinya998[]
=== Locating events by any field: `findE`

Finds events whose fields contain any of the given keywords.
User can search with or without prefix. When search without prefix, any event whose fields contain any keywords will be returned. When search with prefix, event which contains all keywords in the corresponding fields will be returned.
There are three search pattern for `findE` command.

Format1: `find KEYWORD [MORE_KEYWORDS]` +
* * 1. Finds events whose fields contain any of the given keywords. +
User can search with or without prefix.
When search without prefix, any events whose fields contain any keywords will be returned.
When search with prefix, event which contains all keywords in the corresponding fields will be returned.

Format1: `find KEYWORD [MORE_KEYWORDS]`
Format2: `find prefix/KEYWORD, [MORE KEYWORDS]`

****
Expand All @@ -479,18 +483,18 @@ Format2: `find prefix/KEYWORD, [MORE KEYWORDS]`

Examples:

* `findE google` +
Returns any events having fields contain keywords `meeting`. For example, event whose name is 'Google talk' or event whose venue is 'group meeting' will be returned.
* `findE meeting` +
Returns any events having fields contain keywords `meeting`. For example, events 'company meeting' and 'group meeting' will be returned.
* `findE pgp library` +
Returns any events having fields contain keywords `pgp` or `library`. For example, events with venue 'pgp' or 'central library'.
* `findE l/important` +
Returns any event having label contains keyword `important`.


There are two sub command of `findE` command which are `findE time/` and `findE duration/`: +
*1. `findE time/` finds events whose starting date before, equal to or after the searching date. Alternatively user can use ytd, today or tmr to search for events whose starting date is yesterday, today or tomorrow.*
There are two sub command of `findE` command which is `findE time/` and `findE duration/`:
* * 2. `findE time/` finds events whose starting date before, equal to or after the searching date. Alternatively user can use ytd, today or tmr to search for events whose starting date is yesterday, today or tomorrow.

Format3: `findE time/operatorDATE` +
Format3: `findE time/operatorDATE`
Format4: `findE time/alias(ytd, today or tmr)`

****
Expand All @@ -502,15 +506,17 @@ Format4: `findE time/alias(ytd, today or tmr)`

Examples:

* `findE time/>2019-04-01` +
Returns all the events whose starting dates are after 2019,4,1
* `findE time/tmr` +
Returns all the events start in tomorrow
* `findE time/<2019-04-30` +
Returns all the events whose starting dates are before 2019,4,30
* `findE time/=2019–04-01` +
Returns all the events whose starting dates are 2019,4,30


*3. `findE duration/` finds events whose duration is smaller, equal to or larger than the searching period.*
* * 3. `findE duration/` finds events whose duration is smaller, equal to or larger than the searching period

Format5: `findE duration/operatorHOURS`
Format4: `findE duration/operatorHOURS`

****
* operator should be of type ‘<‘, ‘=‘ or ‘>’
Expand Down
20 changes: 9 additions & 11 deletions docs/team/yinya998.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ UniLA is a desktop utilities application designed for typing oriented university

== Summary of contributions

* *Major enhancement*: upgrade *find command* and implement *findE command*

** What it does: These two commands support different search patterns. `find` command allows the user to search for people in contact list easily. User can search a person through exact keyword match, fuzzy keyword match and wildcard keyword match.
The `findE` command allows the user to search for events in event list. User can search an event through exact keyword match, search the event before, happens on or after certain date, and search the event with a certain duration.
* *Major enhancement*: upgrade *find command and implement *findE to support different search patterns in searching contact list and event list*
** What it does: The `find` command allows the user to search for a person in contact list easily. User can search a person through exact keyword match, fuzzy keyword match or wildcard keyword match.
The `findE` command allows the user to search for an event in contact list. User can search an event through exact keyword match, search the event on today, tomorrow and yesterday, and search the event with a certain duration.
** Justification: This feature is significant and efficient for user to manage a large list of contacts and events.
** Highlights: The enhancement and implementation involves reorganizing parse class and adding new predicates classes. The implementation is challenging because different search pattern is used and optimal algorithm is chosen after detailed analysis of the alternatives.
** Credits: levenshtein distance is used to calculate similarity between keywords. [https://www.cnblogs.com/ivanyb/archive/2011/11/25/2263356.html[Original Blogger]]
** Highlights: The enhancement and implementation involves reorganizing parse class and adding new predicates and several other class. The implementation is challenging because different search pattern is used and optimal algorithm is chosen after detailed analysis of the alternatives.
** Credits: levenshtein distance is used to calculate similarity between keywords.
[https://www.cnblogs.com/ivanyb/archive/2011/11/25/2263356.html[Original Blogger]]

* *Minor enhancement*: +
* *Minor enhancement*:
**Implement photo command which allows user to add photo to the person in the contact list.
**Implement personInfo fxml to display personal information on contact list.

Expand All @@ -33,12 +33,10 @@ The `findE` command allows the user to search for events in event list. User can

** Project Management:
*** Setup netlify test
*** Managed releases `v1.2` on GitHub
*** Added issues to issue tracker
*** Updated User Guide, Developer Guide, About Us pages
*** Helped teammates with their problems ?????

** Community:
*** PRs reviewed (with non-trivial review comments): https://github.com/CS2103-AY1819S2-W16-1/main/pull/117[#117], https://github.com/CS2103-AY1819S2-W16-1/main/pull/210[#210]
*** PRs reviewed (with non-trivial review comments): https://github.com/CS2103-AY1819S2-W16-1/main/pull/117[#117]
*** Reported bugs and suggestions for other teams in the class (examples: https://github.com[1], https://github.com[2], https://github.com[3])


Expand Down
Loading

0 comments on commit da05508

Please sign in to comment.