-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "feat: modifyPegasusQueryContext"
This reverts commit a48a4fd.
- Loading branch information
1 parent
a48a4fd
commit f25d0d5
Showing
2 changed files
with
184 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,143 +1,41 @@ | ||
import { Console } from "@nsnanocat/util"; | ||
|
||
export default function modifyPegasusQueryContext(queryContext, Settings, Query) { | ||
Console.log("☑️ modify PegasusQueryContext"); | ||
const Locale = queryContext.locale; | ||
const [Language, CountryCode] = Locale?.split("_") ?? []; | ||
Console.info(`Locale: ${Locale}`, `Language: ${Language}`, `CountryCode: ${CountryCode}`); | ||
switch (Settings.CountryCode) { | ||
case "AUTO": | ||
queryContext.CountryCode = CountryCode; | ||
break; | ||
default: | ||
queryContext.countryCode = Settings.CountryCode; | ||
break; | ||
} | ||
switch (Settings.Region) { | ||
case "AUTO": | ||
queryContext.region = CountryCode; | ||
break; | ||
default: | ||
queryContext.region = Settings.Region; | ||
break; | ||
} | ||
switch (Settings.SiriLocale) { | ||
case "AUTO": | ||
queryContext.siriLocale = Locale; | ||
break; | ||
default: | ||
queryContext.siriLocale = Settings.SiriLocale; | ||
break; | ||
} | ||
switch (Settings.SiriResponseLanguageVariant) { | ||
case "AUTO": | ||
queryContext.siriResponseLanguageVariant = Locale; | ||
break; | ||
default: | ||
queryContext.siriResponseLanguageVariant = Settings.SiriResponseLanguageVariant; | ||
break; | ||
} | ||
if (queryContext?.skuRegion === "CH") queryContext.skuRegion = "LL"; | ||
if (Query) { | ||
Query = Query.toLowerCase(); | ||
switch (true) { | ||
case Query.includes("什么是") || Query.includes("是什么") || Query.includes("what's ") || Query.includes("what is ") || Query.includes("what does ") || Query.includes("what do "): | ||
case Query.includes("怎么样") || Query.includes("怎样") || Query.includes("如何") || Query.includes("how's ") || Query.includes("how is ") || Query.includes("how does ") || Query.includes("how do "): | ||
case Query.includes("为什么") || Query.includes("why ") || Query.includes("why is ") || Query.includes("why does "): | ||
case Query.includes("搜索") || Query.includes("search "): | ||
case Query.includes(" mean") || | ||
Query.includes("meaning") || | ||
Query.includes("explain") || | ||
Query.includes("look up ") || | ||
Query.includes("translat") || | ||
(Query.includes(" in ") && !Query.includes(" here")) || | ||
Query.includes("web") || | ||
Query.includes(" internet") || | ||
Query.includes("defin") || | ||
Query.includes(" wikipedia") || | ||
Query.includes("解释") || | ||
Query.includes("翻译") || | ||
Query.includes("怎么说") || | ||
Query.includes("意思"): | ||
delete queryContext.location; | ||
break; | ||
/* | ||
case Query.includes("何时") || Query.includes("几时") || Query.includes("when "): | ||
case Query.includes("什么时") || Query.includes("几点") || Query.includes("what time "): | ||
case Query.includes("哪里") || Query.includes("哪儿") || Query.includes("何处") || Query.includes("where "): | ||
case Query.includes("哪个") || Query.includes("哪一个") || Query.includes("which "): | ||
// 反例:"When was the first plane invented?", "Where was Steve Jobs born?", etc. | ||
break; | ||
*/ | ||
case Query.includes("天气") || Query.includes("weather"): | ||
case Query.includes("气压") || Query.includes("air pressure") || Query.includes("barometric pressure") || Query.includes("atmospheric pressure") || Query.includes("atmosphere pressure"): | ||
case Query.includes("湿度") || Query.includes("humidity"): | ||
case Query.includes("温度") || Query.includes("temperature"): | ||
case Query.includes("风速") || Query.includes("wind speed"): | ||
case Query.includes("风向") || Query.includes("wind direction"): | ||
case Query.includes("空气质量") || Query.includes("air quality"): | ||
case Query.includes("月相") || (Query.includes("moon") && Query.includes("phase")): | ||
case Query.includes("紫外线") || Query.includes("uv index") || Query.includes("ultraviolet index outside"): | ||
case Query.includes("能见度") || Query.includes("visibility"): | ||
case Query.includes("日出") || Query.includes("sunrise"): | ||
case Query.includes("日落") || Query.includes("sunset"): | ||
case (Query.includes("sun ") && (Query.includes("rise") || Query.includes("set") || Query.includes("fall"))) || Query.includes("sunrise") || Query.includes("sunset"): | ||
case (Query.includes("太阳") && (Query.includes("升") || Query.includes("落") || Query.includes("下山"))) || Query.includes("日出") || Query.includes("日落"): | ||
case (Query.includes("is it") || Query.includes("it is") || Query.includes("it's")) && | ||
(Query.includes("humid") || | ||
Query.includes("rain") || | ||
Query.includes("shin") || | ||
Query.includes("sunny") || | ||
Query.includes("hot") || | ||
Query.includes("cold") || | ||
Query.includes("freez") || | ||
Query.includes("warm") || | ||
Query.includes("wind") || | ||
Query.includes("fog") || | ||
Query.includes("haz") || | ||
Query.includes("thunder") || | ||
Query.includes("storm") || | ||
Query.includes("lightn") || | ||
Query.includes("snow") || | ||
Query.includes("hail") || | ||
Query.includes("clear") || | ||
Query.includes("tornado") || | ||
Query.includes("hurricane")): | ||
case (Query.includes("有") || Query.includes("会") || Query.includes("吗")) && | ||
(Query.includes("下雨") || | ||
Query.includes("晒") || | ||
Query.includes("晴") || | ||
Query.includes("热") || | ||
Query.includes("冷") || | ||
Query.includes("暖") || | ||
Query.includes("风") || | ||
Query.includes("雾") || | ||
Query.includes("霾") || | ||
Query.includes("雷") || | ||
Query.includes("风暴") || | ||
Query.includes("电") || | ||
Query.includes("雪") || | ||
Query.includes("雹")): | ||
case Query.includes("precipitation") || Query.includes("forecast") || ((Query.includes("chance") || Query.includes("possibilit")) && (Query.includes(" rain") || Query.includes(" snow"))): | ||
case Query.includes("降雪") || Query.includes("降水") || Query.includes("预报") || ((Query.includes("概率") || Query.includes("几率")) && (Query.includes("降水") || Query.includes("降雪"))): | ||
break; | ||
case Query.includes("附近") || Query.includes(" nearby"): | ||
case Query.includes("周围") || Query.includes(" around me") || Query.includes(" around here"): | ||
case Query.includes("导航") || Query.includes("navigat"): | ||
case Query.includes("方向") || Query.includes(" direction"): | ||
case Query.includes("指引") || (Query.includes("direct ") && Query.includes(" to ")): | ||
case Query.includes("指引") || (Query.includes("guide ") && Query.includes(" to ")): | ||
case Query.includes("带我去") || Query.includes("take me to "): | ||
case Query.includes("路线") || Query.includes("route "): | ||
case Query.includes("路径") || Query.includes("path to "): | ||
case (Query.includes("怎样") || Query.includes("如何") || Query.includes("怎么")) && (Query.includes("到") || Query.includes("去") || Query.includes("抵达") || Query.includes("走")): | ||
case Query.includes("how ") && (Query.includes(" get ") || Query.includes(" go ") || Query.includes(" arrive ") || Query.includes(" reach ")): | ||
break; | ||
default: | ||
delete queryContext.location; | ||
break; | ||
} | ||
} | ||
Console.log("✅ modify PegasusQueryContext"); | ||
return queryContext; | ||
} | ||
export default function modifyPegasusQueryContext(queryContext, Settings) { | ||
Console.log("☑️ modify PegasusQueryContext"); | ||
const Locale = queryContext.locale; | ||
const [Language, CountryCode] = Locale?.split("_") ?? []; | ||
Console.info(`Locale: ${Locale}`, `Language: ${Language}`, `CountryCode: ${CountryCode}`); | ||
switch (Settings.CountryCode) { | ||
// biome-ignore lint/suspicious/noFallthroughSwitchClause: <explanation> | ||
case "AUTO": | ||
Settings.CountryCode = CountryCode; | ||
default: | ||
queryContext.countryCode = Settings.CountryCode; | ||
|
||
break; | ||
}; | ||
switch (Settings.Region) { | ||
case "AUTO": | ||
break; | ||
default: | ||
queryContext.region = Settings.CountryCode; | ||
break; | ||
}; | ||
switch (Settings.SiriLocale) { | ||
case "AUTO": | ||
break; | ||
default: | ||
queryContext.siriLocale = Settings.SiriLocale; | ||
break; | ||
}; | ||
switch (Settings.SiriResponseLanguageVariant) { | ||
case "AUTO": | ||
break; | ||
default: | ||
queryContext.siriResponseLanguageVariant = Settings.SiriResponseLanguageVariant; | ||
break; | ||
}; | ||
if (queryContext?.skuRegion === "CH") queryContext.skuRegion = "LL"; | ||
Console.log("✅ modify PegasusQueryContext"); | ||
return queryContext; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters